When executing the role, it is necessary that the names of hostnames be substituted into the variables. It is also important to take into account the number of hosts and the places in the variables where they are substituted. Is it possible to do this only by means of ansible?
Example: (host.ini)
host1 ansible_host='10.33.15.15' ansible_ssh_user='ben'
host2 ansible_host='10.33.15.16' ansible_ssh_user='ben'
host3 ansible_host='10.33.15.17' ansible_ssh_user='ben'
host4 ansible_host='10.33.15.18' ansible_ssh_user='ben'
host5 ansible_host='10.33.15.19' ansible_ssh_user='ben'
...
...
Example: (roles/post_install/defaults/main.yml)
if the input is Only: host1 - only monitoring was deployed
monitoring:
nodes: ['host1']
logging:
nodes: []
If the input is host1 / host2 In this case, these same sections were:
monitoring:
nodes: ['host1']
logging:
nodes: ['host2']
if the input is host1 / host2 / host3 In this case, these same sections were:
monitoring:
nodes: ['host1', 'host2']
logging:
nodes: ['host3']
if the input is host1 / host2 / host3 / host4 In this case, these same sections were:
monitoring:
nodes: ['host1', 'host2']
logging:
nodes: ['host3', 'host4']
if the input is host1 / host2 / host3 / host4 / host5 In this case, these same sections were:
monitoring:
nodes: ['host1', 'host2', 'host5']
logging:
nodes: ['host3', 'host4']
if the input is host1 / host2 / host3 / host4 / host5 / ... / ... / ... In this case, these same sections were:
monitoring:
nodes: ['host1', 'host2', 'host5', ...]
logging:
nodes: ['host3', 'host4' ...]