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.