【发布时间】:2020-11-16 23:30:48
【问题描述】:
我有 2 个组,每个组都有名为 dev 和 test 的子组。我正在尝试使用group2:&test 模式定位group2 (four.example.com) 中的test 主机。
鉴于 yaml 库存:
all:
children:
group1:
children:
dev:
hosts:
one.example.com:
test:
hosts:
two.example.com:
group2:
children:
dev:
hosts:
three.example.com:
test:
hosts:
four.example.com:
还有剧本:
- name: health check
hosts: group2:&test
tasks:
- name: Ping hosts
ping:
我收到了来自two 和four 的回复。
我希望 仅 four 发送 ping。
虽然two 确实是名为test 的组的一部分,但它不属于名为group2 的组,因此我不希望将其视为一部分相交。
就好像它在做一个逻辑或 (||),而不是一个逻辑与 (&&)
在使用具有非唯一子名称的嵌套组时,这是 Ansible 的限制吗?
【问题讨论】: