Merging inventories?

123 views
Skip to first unread message

Nico K.

unread,
Feb 13, 2016, 12:52:08 AM2/13/16
to Ansible Project
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.

Dick Davies

unread,
Feb 14, 2016, 5:17:17 AM2/14/16
to ansible list
We normally just wrap it in a shell loop:

for i in inventories/*/hosts
do
ansible-playbook -i $i foo.yml
done
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/7bfb3916-51cd-4963-94c4-1043d9cccdb6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Josh Smift

unread,
Feb 14, 2016, 7:32:19 AM2/14/16
to ansible...@googlegroups.com
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 (j...@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.

Alexey Vazhnov

unread,
Feb 15, 2016, 5:42:59 AM2/15/16
to Ansible Project
Try to use:

ansible-playbook -i inventories

because Ansible can use directories.
You also can use symlinks for more complicated cases.
Reply all
Reply to author
Forward
0 new messages