我正在尝试运行一个以数据库组作为主机的
database.yaml
playbook,其中包含清单中的所有 db-* 主机。
- name: Install PostgreSQL
hosts: databases
---
all:
children:
group1:
children:
subgroup1:
hosts:
db-host1:
ansible_host: 192.168.0.1
cache-host2:
ansible_host: 192.168.0.2
subgroup2:
hosts:
db-host3:
ansible_host: 192.168.0.3
cache-host4:
ansible_host: 192.168.0.4
group2:
children:
subgroup1:
hosts:
db-host5:
ansible_host: 192.168.0.5
cache-host6:
ansible_host: 192.168.0.6
subgroup2:
hosts:
db-host7:
ansible_host: 192.168.0.7
cache-host8:
ansible_host: 192.168.0.8
databases:
hosts:
db-host1:
db-host3:
db-host5:
db-host7:
cache:
hosts:
cache-host2:
cache-host4:
cache-host6:
cache-host8:
但是我只需要在组“group1,subgroup1”中的那些主机上运行,我无法绑定到主机的名称,因为在组中
subgroup1
主机db-*可以有很多。
启动时指定限制:
ansible-playbook -i inventory/demo database.yml --limit "group1,subgroup1"
该剧本在“数据库”组中的所有主机上运行 您能告诉我如何在多个组上正确运行剧本吗?