# Merging inventories?

**URL:** <https://forum.ansible.com/t/merging-inventories/20568>\
**Category:** Ansible Project\
**Created:** [February 13, 2016, 5:52am UTC](https://forum.ansible.com/t/merging-inventories/20568 "2016-02-13T05:52:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nico\_K](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@Nico\_K](https://forum.ansible.com/u/Nico_K)\
**Post date:** [February 13, 2016, 5:52am UTC](https://forum.ansible.com/t/merging-inventories/20568/1 "2016-02-13T05:52:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [February 14, 2016, 10:17am UTC](https://forum.ansible.com/t/merging-inventories/20568/2 "2016-02-14T10:17:02Z")

</div>

We normally just wrap it in a shell loop:

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

---

<div class="post-metadata">

**Author:** ![Josh\_Smift1](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@Josh\_Smift1](https://forum.ansible.com/u/Josh_Smift1)\
**Post date:** [February 14, 2016, 12:31pm UTC](https://forum.ansible.com/t/merging-inventories/20568/3 "2016-02-14T12:31:54Z")

</div>

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](https://github.com/caredotcom/ansible-quartermaster)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-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.

---

<div class="post-metadata">

**Author:** ![alexey.vazhnov](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@alexey.vazhnov](https://forum.ansible.com/u/alexey.vazhnov)\
**Post date:** [February 15, 2016, 10:42am UTC](https://forum.ansible.com/t/merging-inventories/20568/4 "2016-02-15T10:42:58Z")

</div>

Try to use:

`ansible-playbook -i inventories`

because Ansible can use directories.

You also can use symlinks for more complicated cases.
