Thank you Brian.

I have looked at "group_by" and I am still trying to figure out how to use 
it in my case.

Maybe you can help me with how to make the piece of code below to be more 
generically used for any <group_name>.
I am using it in a template, to build a list of IP of hosts in a group so 
that I can use them to configure a cluster of servers.

Or if there is a better way of achieving the same purpose, please let me 
know.


 {%for host in 
groups['<group_name>']%}"{{hostvars[host]['ansible_default_ipv4']['address']}}"{%
 
if not loop.last %},{% endif %}{% endfor %}


I want to achieve having a config line like below:
#discovery.zen.ping.unicast.hosts: ["IP_Node1","< IP_Node2 >",“<IP_Node3>"]

where there are 3 hosts in the <group_name>.

Thanks.

On Friday, August 9, 2019 at 10:11:41 AM UTC-5, Harrymosco wrote:
>
> Can I use a variable to insert inventory group when using groups; e.g.  
> groups['$groupname']?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/97cff29f-7d16-40f5-a58c-8c65b5a0b929%40googlegroups.com.

Reply via email to