I have 2 groups, each with child groups called dev and test. I am trying to target test hosts in group2 (four.example.com) using the pattern group2:&test.
Given the yaml inventory:
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:
And playbook:
- name: health check
hosts: group2:&test
tasks:
- name: Ping hosts
ping:
I am getting pings back from both two and four.
I expect pings from only four.
Although it's true that two is part of a group called test, it is not part of the group called group2, and I therefore would not expect to see it as part of the intersect.
It's as though it's doing a logical or (||), rather than a logical and (&&)
Is this a limitation of Ansible when using nested groups with non-unique child names?