Hi,
I have an inventory file with the bellow servers :
# servers
[dbservers]
db01
db02
db03
db04
In my template I want to populate the config by choosing randomly one of
the servers from the dbservers group .
Unfortunately the bellow will return all servers :
{% for host in groups['dbservers'] %}
server_address = {{ hostvars[host]['inventory_hostname'] }}
{% endfor %}
1) I need Ansible to return only 1 server (random) .
2) I will run this on a big cluster of servers so I would like that random
is actually balanced across the cluster equally or else a db servers will
get more connections than the others and could hit a capacity issue.
Can someone help me ?
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/693115dc-9f62-4bf3-855a-3510968d55ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.