I am looking to run the same task on multiple inventory groups, for eg:
[big_group]
greenhat
localhost
redhat
linux
[small_group]
localhost
[redhat_group]
redhat
From my playbook I need to run a task on both small_group
and redhat_group
My task is as below
- name: Disable HTTPS service from firewalld
firewalld:
service: https
permanent: false
state: disabled
zone: public
immediate: true
when: inventory_hostname in groups['small_group']
when: inventory_hostname in groups['redhat_group']
Received a warning as
[WARNING]: While constructing a mapping from firewall.yml, line 6, column 5, found a duplicate dict key (when). Using last defined value only.
Playbook result :
TASK [Disable HTTPS service from firewalld] **************************************************************************************************************************************************
skipping: [localhost]
skipping: [redhat]
How can I specify multiple groups in when: inventory_hostname in groups[]