On Friday, 18 January 2019 07:36:41 CET coach rhca wrote:
> Hi,
> 
> I have created a role for the ntp with the ntp.j2 and ntp1.j2 templates in 
> templates diretory . 
> 
> with ntp.j2 consisting of 
> 
> server 2.2.2.1 iburst 
> 
> and with tp.
> ntp1.j2 consist of 
> 
> server 1.2.1.3 iburst 
> 
> 
> In the task under the 
> 
> - name:
>   template:
>     src: ntp.conf.j2
>     dest: /etc/ntp.conf
>   notify: restart ntp
> 
> I want to use the template for different hosts if the hosts are say test1 
> testops1 db-client1 ans 10 others etc .apply ntp.j2 and if the hosts are 
> dev1 devops1 db-devclien1 app-devclient2 and others .. how do we use the 
> when clause to achieve this . this hosts are randomly mentioned in the 
> inventory in different groups.

You could add a group and put them like ntp_grp and ntp1_grp

Then the when will be
  when: inventory_hostname in group['ntp_grp']

If you don't want to have groups then you need to list every host like so
  when: inventory_hostname in ['test1','testops1','db-client1']
  


-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/53386831.S9lhg9mtCV%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to