# How to make Ansible use ALL inventory files in a directory?

**URL:** <https://forum.ansible.com/t/how-to-make-ansible-use-all-inventory-files-in-a-directory/26454>\
**Category:** Ansible Project\
**Created:** [January 10, 2018, 7:40pm UTC](https://forum.ansible.com/t/how-to-make-ansible-use-all-inventory-files-in-a-directory/26454 "2018-01-10T19:40:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [January 10, 2018, 7:40pm UTC](https://forum.ansible.com/t/how-to-make-ansible-use-all-inventory-files-in-a-directory/26454/1 "2018-01-10T19:40:36Z")

</div>

I’m segregating my development from my production inventories, and somewhat following the advice given in [Laying out roles, inventories and playbooks](https://leucos.github.io/ansible-files-layout). I therefore have the following directory structure.

`  
/path\_to\_playbook/inventories  
/path\_to\_playbook/inventories/development/hosts  
/path\_to\_playbook/inventories/development/hosts/host\_file\_1  
/path\_to\_playbook/inventories/development/hosts/host\_file\_2  
/path\_to\_playbook/inventories/production/hosts  
/path\_to\_playbook/inventories/production/hosts/host\_file\_1  
/path\_to\_playbook/inventories/production/hosts/host\_file\_2

`

Now how can I write an ansible ad-hoc command to ping all the hosts in the /path\_to\_playbook/inventories/development/hosts directory? I don’t want to create a /path\_to\_playbook/inventories/development/hosts/all\_hosts file that will contain the hosts in the host\_file\_\* files since that will be hard to maintain

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [January 10, 2018, 8:58pm UTC](https://forum.ansible.com/t/how-to-make-ansible-use-all-inventory-files-in-a-directory/26454/2 "2018-01-10T20:58:16Z")

</div>

Just pass the directory to -i, ansible will use all the files contained within.
