I have three hosts in my invenotry file to configure HAPROXY setup. using below ansible tempalte I was able populate the IP address in the configurtion file. I also want to change the name with index value. how can I change kube-1 to variable like (kube-1, kube-2, kube-3)
template
{% for host in groups['master'] %}
server kube-1 {{ hostvars[host]["ansible_default_ipv4"]["address"] }}:30549 check verify none
{% endfor %}
sample output
server kube-1 x.x.x.x:30549 check verify none
server kube-1 x.x.x.x:30549 check verify none
server kube-1 x.x.x.x:30549 check verify none
Required output
server kube-1 x.x.x.x:30549 check verify none
server kube-2 x.x.x.x:30549 check verify none
server kube-3 x.x.x.x:30549 check verify none
Thanks SR