# Problem grouping inventory directory files

**URL:** <https://forum.ansible.com/t/problem-grouping-inventory-directory-files/17689>\
**Category:** Ansible Project\
**Created:** [March 6, 2015, 11:15am UTC](https://forum.ansible.com/t/problem-grouping-inventory-directory-files/17689 "2015-03-06T11:15:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_McNulty](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@John\_McNulty](https://forum.ansible.com/u/John_McNulty)\
**Post date:** [March 6, 2015, 11:15am UTC](https://forum.ansible.com/t/problem-grouping-inventory-directory-files/17689/1 "2015-03-06T11:15:28Z")

</div>

By way of explanation here’s a simple reproducer.

- The Inventory is a directory containing two files - each one contains one group and one host

# inventory/poc-app

[poc-app]  
host1

# inventory/poc-db

[poc-db]  
host2

- A playbook is created to run a couple of roles for each

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [March 6, 2015, 1:13pm UTC](https://forum.ansible.com/t/problem-grouping-inventory-directory-files/17689/2 "2015-03-06T13:13:06Z")

</div>

In a way I expect that to happen. Your files more than likely load in order. poc, poc-app, poc-db.

When in doubt give them names that load in the necessary order. You can’t define children using another group that hasn’t been defined yet.

Often I will prefix files with numbers to get the load order I expect.

---

<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:** [March 6, 2015, 1:24pm UTC](https://forum.ansible.com/t/problem-grouping-inventory-directory-files/17689/3 "2015-03-06T13:24:19Z")

</div>

​Just add to that last file these two empty entries:

[poc-app]  
[poc-db]

The inventories are indeed merged, but before that every single file is  
parsed as if it was the sole inventory.

It's a bit ugly now, but that should get addressed post 2.0​

---

<div class="post-metadata">

**Author:** ![John\_McNulty](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@John\_McNulty](https://forum.ansible.com/u/John_McNulty)\
**Post date:** [March 6, 2015, 2:20pm UTC](https://forum.ansible.com/t/problem-grouping-inventory-directory-files/17689/4 "2015-03-06T14:20:33Z")

</div>

Thanks Serge, that worked. I’ll use that.
