Hi,
I need help with the bellow configuration in Jinja, I’m using a for loop to populate the hosts from a group defined in my inventory and that’s working good but what my application requires is a letter in front of every host in alphabetical order depending how many host numbers I have :
servers.ini :
[server-slaves]
server1.example.com
server2.example.com
config.conf.j2 :
slaves_hosts={% for host in groups[‘server-slaves’] %}
{{ host }}{% if not loop.last %},{% endif %}
{% endfor %}
output :
slaves_hosts=server1.example.com,server2.example.com,server3.example.com
desired output
slaves_hosts=a:server1.example.com,b:server2.example.com,c:server3.example.com
This is possible in Chef, any idea if I can do the same in Ansible and how ?
Thanks in advance.