On 14.08.2019 20:24, Harrymosco wrote:
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 %}
Lets say you have a variable myvar that contain the group name you can
do groups[myvar]
--
Kai Stian Olstad
--
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/6945932303bd14079fcd0e264b06c936%40olstad.com.