Hi,
I’m having problems with the ansible inventory, filters and hosts in multiple roles. Let’s assume I have two customers, each with a machine that can be a http server and/or a samba server.This is my inventory:
[customer1]
host1.customer1.com
[customer2]
host1.customer2.com
host2.customer2.com
[http-servers]
host1.customer1.com
host1.customer2.com
[samba-servers]
host1.customer1.com
host2.customer1.com
As you can see, customer1 only has a single machine that fulfills both roles and customer2 has a separate machine for each role.
Now I’m trying to run the playbook with filters:
% ansible-playbook -i ./hosts --list-hosts --limit customer1 ./site.yml
playbook: ./site.yml
play #1 (customer1): host count=1
host1.customer1.com
play #3 (http-servers): host count=1
host1.customer1.com
play #4 (samba-servers): host count=1
host1.customer1.com
Why on earth do I get play #3 and #4? I specifically asked for customer1 which only has one entry.
The same goes for role-based groups:
% ansible-playbook -i ./hosts --limit http-servers --list-hosts ./site.yml
playbook: ./site.yml
play #1 (customer1): host count=1
host1.customer1.com
play #2 (customer2): host count=1
host1.customer2.com
play #3 (http-servers): host count=2
host1.customer1.com
host1.customer2.com
play #4 (samba-servers): host count=1
host1.customer1.com
What’s going on here?
I did read the documentation on inventory, groups and patterns but that page only has examples for hosts in single roles. What am I doing wrong?
-dirk