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 %}
`
I need Ansible to return only 1 server (random) .
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.
Brian Coca can you be more specific ? I’m trying something like the bellow but I"m stuck, it’s deploying all the servers in every run instead of only a random one …