Hi I found my answer ...

Because I needed default variable to be attached to a specific 
host/inventory group during that group run I needed to add them into the 
inventory file itself.... for this case it works perfect.

[P1-CI]
server01

#####################################################
### variables that must be applied per host group ###
#####################################################

[P1-CI:vars]
data_mon='P1'
data_env='CI'


On Monday, March 12, 2018 at 1:01:59 PM UTC+2, Naftali Burnham wrote:
>
> Hi,
>    Im not finding exactly what Im trying to do, or maybe Im not getting 
> how to accomplish this.  Ive been playing with different ways to do this.
>
> I need so set some different variable in a template. 
>
> this is content of j2 file.
>
> ---
> monitoring:
>   -
>     lpmonitoring: {{ data_mon }}
>     lpenvironment: {{ data_env }}
>
> When I have a run that pulls the above template I need that item.mon and 
> item.env variable to be set accoring to which hosts: GROUP is running....
> as in when I run the playbook against the hosts in group P1-CI I want the 
> variables to be item.mon=P1 and item.env=CI   and when it runs in P1-QA i 
> want to  variable to be item.mon=P1 item.env=QA
>
>
> ---
> - name: generate lpmonitoringYaml facter file
>   hosts: P1-CI,P1-QA
>
>
>
>
>
> Thanks very much
>
>
>
>
-- 
This message may contain confidential and/or privileged information. 
If you are not the addressee or authorized to receive this on behalf of the 
addressee you must not use, copy, disclose or take action based on this 
message or any information herein. 
If you have received this message in error, please advise the sender 
immediately by reply email and delete this message. Thank you.

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1293d71b-74d3-4d94-9e33-dbf9691a99ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to