Hello All!
For many of my plays, I use groups of groups to handle items common to several systems. For example, given an inventory file such as:
[jenkins_masters]
host1
[jenkins_slaves]
slave1
slave2
slave3
[jenkins_servers:children]
jenkins_masters
jenkins_slaves
The playbook might look like:
- hosts: jenkins_servers
roles:
- java
- hosts: jenkins_masters
roles:
- jenkins
- hosts: jenkins_slaves
roles:
- java_buildtools
I'm looking for a way to centralize the population of these top level groups; meaning, no matter what inventory is used, all hosts in jenkins_masters and jenkins_slaves are added to jenkins_servers.
When using dynamic inventory, I found it was very convenient to add a static inventory file called rollup_groups that contains no hosts, but just:
[jenkins_masters]
[jenkins_slaves]
[jenkins_servers:children]
jenkins_masters
jenkins_slaves
When referring to the directory that contains this and the dynamic inventory script, the hosts and basic group membership come from the cloud, and the parent group gets taken care by this file.
To re-use this same method with static host inventories, the only way I can see is to put each inventory file in a separate directory along with a copy of rollup groups. But I don't feel awesome about that solution - having many copies of the same file bothers me.
Does anybody have ideas about how else to tackle this?
Thanks,
Matt