小编Jea*_*ean的帖子

在多个清单主机组上运行 ansible 任务

我希望在多个库存组上运行相同的任务,例如:

[big_group]
greenhat
localhost
redhat
linux

[small_group]
localhost

[redhat_group]
redhat
Run Code Online (Sandbox Code Playgroud)

在我的剧本中,我需要在[small_group][redhat_group]上运行一个任务

我的任务如下

[big_group]
greenhat
localhost
redhat
linux

[small_group]
localhost

[redhat_group]
redhat
Run Code Online (Sandbox Code Playgroud)

收到警告作为

 [WARNING]: While constructing a mapping from firewall.yml, line 6, column 5, found a duplicate dict key (when). Using last defined value only.
Run Code Online (Sandbox Code Playgroud)

剧本结果:

TASK [Disable HTTPS service from firewalld] **************************************************************************************************************************************************
skipping: [localhost]
skipping: [redhat]
Run Code Online (Sandbox Code Playgroud)

如何指定多个组 when: inventory_hostname in groups[]

谢谢

ansible ansible-inventory

3
推荐指数
1
解决办法
2249
查看次数

标签 统计

ansible ×1

ansible-inventory ×1