I took out the curly brackets  from the groups and and the normal 
bracks..its works fine 





On Tuesday, 26 July 2016 20:33:34 UTC-4, GANA SAGAR wrote:
>
> Hi,
>
> I am trying to write a task to be executed over 4 groups. 2 of them are 
> based on location 'sb' 'ada' and 2 of them based on distribution. each 
> combination has separate template.
> sb - redhat - template 1
> sb - aix      - template 2
> ada - redhat - template 3
> ada - aix     - template 4
>
> hosts
> [redhat]
> redhat1
> redhat2
>
> [sb]
> sdbcf1
> aix2
> aix2
>
> However when I am executing the tasks with the template module using 
> 'when' as below. The challenge is, the tasks are being run on 1st group the 
> distribution and are being skipped on the second condition. Where I want 
> the task to be in run only when a server is in both the groups not just 
> one.In this case I dont have a a server thats common. HOw can this be done 
> ? What am I doing wrong ? 
>
> - name: Copying our rsyslog template to Redhat servers in sb
>   template: src=rsyslog.conf.sb.lx.j2
>                 dest=/etc/rsyslog.conf.test
>                 owner=root
>                 mode=0600
>   when: (ansible_distribution == "RedHat"  and  "'sb' in {{group_names}}")
>   notify:  restart rsyslog
>
>
>
>

-- 
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/0e6b88de-6656-4b0c-accb-dac613f074bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to