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