on-internet
← Community

ansible play_hosts template loop

Stack Overflow ·

I'm trying to use the play_hosts variable in an ansible template. I'm trying to setup a master / slave domain setup for wildfly. So I wish to loop over all hosts in the inventory group, without having to specify a group. This is what I'm trying: {%- for host in play_hosts %} {%- if 'master' in hostvars[host][ansible_hostname + '_alias'] %} <remote protocol="remote" host="{{ hostvars[host]['ansible_default_ipv4']['address'] }}" port="9999" /> {%- endif %} {%- endfor %} I get the below error: failed: [atllvjksap012d.hughestelematics.net] (item=host) => {"failed": true, "item": "host", "msg": "An

Comments

Sign in or sign up to comment and upvote.

No comments yet.