Merging inventories?

Hi,

When one has multiple inventories like:

inventories/a/hosts
inventories/b/hosts
inventories/…

Is there an easy way to run a task or playbook against all of them without explicitly having to define each inventory on the command-line?

The use case here is that all those groups contain machines for different departments or even sub-companies, however they all share certain SSL-certificates that I would like to be able to deploy to all hosts at once.

Thanks,
Nico.

We normally just wrap it in a shell loop:

for i in inventories/*/hosts
  do
    ansible-playbook -i $i foo.yml
  done

We wrote a way to merge static and dynamic inventories; you could also use
it to have static inventories in multiple files, and merge them together.
https://github.com/caredotcom/ansible-quartermaster

                                      -Josh (jbs@care.com)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

Try to use:

ansible-playbook -i inventories

because Ansible can use directories.

You also can use symlinks for more complicated cases.