[ansible-project] Re: Using the magic variable groups

2019-08-15 Thread Harrymosco
Thanks Kai Stian,

Absolutely what I want. Fantastic!!

All I am doing now is use "--extra-vars" and assign any   I 
want to configure to the variable, and that's it.
The code does not need to be modified anymore for different s.

Appreciated!!

-Harrymosco.  

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/7dc6745d-18b7-411c-aef4-35eebe6d999e%40googlegroups.com.


Re: [ansible-project] Re: Using the magic variable groups

2019-08-14 Thread Kai Stian Olstad

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 .
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['']%}"{{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.


[ansible-project] Re: Using the magic variable groups

2019-08-14 Thread Harrymosco
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 .
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['']%}"{{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 >",“"]

where there are 3 hosts in the .

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.