How to use group_vars in ansible templates

Hi there,

Could someone help me with how to template this config like below please?

cluster_formation.classic_config.nodes.1 = rabbit@rabbitmq-1
cluster_formation.classic_config.nodes.2 = rabbit@rabbitmq-2
cluster_formation.classic_config.nodes.3 = rabbit@rabbitmq-3

I would like to change nodes.1,2,3 & rabbit@anisble_hostname

Thanks

Hi there,

Could someone help me with how to template this config like below please?

cluster_formation.classic_config.nodes.1 = rabbit@rabbitmq-1
cluster_formation.classic_config.nodes.2 = rabbit@rabbitmq-2
cluster_formation.classic_config.nodes.3 = rabbit@rabbitmq-3

I would like to change nodes.1,2,3 & rabbit@anisble_hostname

So you want to loop over a host group to get this configuration above?

Regards
       Racke

Hi there ,

i am getting following issue to connect with my Cisco CISCO2951/K9 (revision 1.1) router any one please help me !

Yes. I managed get the config as below.

{% for host in groups[‘rabbitmq’] %}
cluster_formation.classic_config.nodes.{{ loop.index }} = rabbit@{{ hostvars[host][‘ansible_hostname’] }}
{% endfor %}

You forgot to post your playbook