我正在多个库存组上运行相同的任务,例如:
[big_group]
greenhat
localhost
redhat
linux
[small_group]
localhost
[redhat_group]
redhat
从我的剧本中,我需要同时在[small_group]和[redhat_group]]上运行任务
我的任务如下
- 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']
收到警告为
[WARNING]: While constructing a mapping from firewall.yml, line 6, column 5, found a duplicate dict key (when). Using last defined value only.
Playbook结果:
TASK [Disable HTTPS service from firewalld] ************************************************************************************************************************************************** skipping: [localhost] skipping: [redhat]
如何在“以下时间中指定多个组:组[]中的库存主机名]]
谢谢
我正在多个清单组上运行相同的任务,例如:[big_group] greenhat localhost redhat linux [small_group] localhost [redhat_group] redhat从我的剧本中,我需要运行一个...
您在一个任务中不能有多个when
子句。对于您的情况,您只需要加入两个组(+
)并删除多个条目(如果有)(使用unique
filter,以便将来更改库存)。
unique