# Combine multiple inventory sources?

**URL:** <https://forum.ansible.com/t/combine-multiple-inventory-sources/15353>\
**Category:** Ansible Project\
**Created:** [May 28, 2014, 1:56pm UTC](https://forum.ansible.com/t/combine-multiple-inventory-sources/15353 "2014-05-28T13:56:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joost\_Cassee](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Joost\_Cassee](https://forum.ansible.com/u/Joost_Cassee)\
**Post date:** [May 28, 2014, 1:56pm UTC](https://forum.ansible.com/t/combine-multiple-inventory-sources/15353/1 "2014-05-28T13:56:43Z")

</div>

Hi all,

[Sorry for the barrage of mails, I am restructuring my Ansible layout and running into several things at once.]

I thought it was possible to combine inventory sources like this:

hosts/static1

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 28, 2014, 3:48pm UTC](https://forum.ansible.com/t/combine-multiple-inventory-sources/15353/2 "2014-05-28T15:48:27Z")

</div>

I am confused why you have group definitions inside a file that seems to describe a host.

Should the “hosts/” directory just be named “inventory” ?

Anyway, yes, if you feed -i a path to a directory, it will load all inventory sources therein.

It is however true there are some unmerged things that will address what happens when the individual inventory files have information overlap. svg worked on this and it’s in queue after we smite some other various buglets.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [May 28, 2014, 4:00pm UTC](https://forum.ansible.com/t/combine-multiple-inventory-sources/15353/3 "2014-05-28T16:00:56Z")

</div>

​Joost,​

> hosts/static1  
> ---  
> [group1]  
> host1
> 
> hosts/static2  
> ---  
> [group2]  
> host1
> 
> test.yml  
> ---  
> - hosts: all  
> &nbsp;&nbsp;connection: local  
> &nbsp;&nbsp;gather\_facts: no  
> &nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;- debug: var=hostvars
> 
> It looks like group1 is somehow masking group2 during limiting:
> 
> $ ansible-playbook test.yml -i hosts -l group1
> 
> PLAY [all]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> TASK: [debug var=group\_names]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> ok: [host1] =\> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"group\_names": [  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"group1",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"group2"  
> &nbsp;&nbsp;&nbsp;&nbsp;]  
> }
> 
> ​This is correct.

​

> $ ansible-playbook test.yml -i hosts -l group2  
> ERROR: provided hosts list is empty

​I can reproduce this with standard ansible.  
I get expected output with my integration branch that holds the different  
patches Michael mentioned:  
[https://github.com/sergevanginderachter/ansible/tree/INTEGRATION](https://github.com/sergevanginderachter/ansible/tree/INTEGRATION)

> Is this a bug?

​Yes, and it will get solved 🙂

Serge

---

<div class="post-metadata">

**Author:** ![Joost\_Cassee](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Joost\_Cassee](https://forum.ansible.com/u/Joost_Cassee)\
**Post date:** [May 28, 2014, 7:08pm UTC](https://forum.ansible.com/t/combine-multiple-inventory-sources/15353/4 "2014-05-28T19:08:43Z")

</div>

> I am confused why you have group definitions inside a file that seems to  
> describe a host.
> 
> Should the "hosts/" directory just be named "inventory" ?

Yes, it should be named "inventory".

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [May 28, 2014, 8:54pm UTC](https://forum.ansible.com/t/combine-multiple-inventory-sources/15353/5 "2014-05-28T20:54:53Z")

</div>

​No, I believe it's planned for review in this release cycle, but they're  
tackling higher priority tickets first.​

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 29, 2014, 6:02pm UTC](https://forum.ansible.com/t/combine-multiple-inventory-sources/15353/6 "2014-05-29T18:02:13Z")

</div>

Yes, this exactly.

This is at the head of the feature list (we’ll it’s got some fixes in it for sure, but its’ well into the refactoring tickets), though we are currently working P2 tickets regarding some of the higher priority bugs in the system.
