# One hosts file per cookbook

**URL:** <https://forum.ansible.com/t/one-hosts-file-per-cookbook/15463>\
**Category:** Ansible Project\
**Created:** [June 15, 2014, 11:36am UTC](https://forum.ansible.com/t/one-hosts-file-per-cookbook/15463 "2014-06-15T11:36:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Navid\_Paya2](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@Navid\_Paya2](https://forum.ansible.com/u/Navid_Paya2)\
**Post date:** [June 15, 2014, 11:36am UTC](https://forum.ansible.com/t/one-hosts-file-per-cookbook/15463/1 "2014-06-15T11:36:15Z")

</div>

Hi  
I use ansible in various environments and I don’t want to mix them up. My question is, is there a way to tell asnible to look in the playbook root directory for a hosts file instead of using only one hosts file and switching that using the environment variable? I also propose to have something like this for picking up the hosts file when running a playbook:

- Look for it in the root directory of the project
- Look a the ANSIBLE\_HOSTS variable
- Look at /etc/ansible/hosts  
This way I can also ship my hosts file with the project which is very convenient instead of having to keep everything in one hosts file or changing the environment variable.

---

<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:** [June 15, 2014, 2:22pm UTC](https://forum.ansible.com/t/one-hosts-file-per-cookbook/15463/2 "2014-06-15T14:22:52Z")

</div>

ansible-playbook -i hostfile site.yml

works fine for me.

---

<div class="post-metadata">

**Author:** ![Navid\_Paya1](https://avatars.discourse-cdn.com/v4/letter/n/3da27b/32.png) [@Navid\_Paya1](https://forum.ansible.com/u/Navid_Paya1)\
**Post date:** [June 15, 2014, 3:59pm UTC](https://forum.ansible.com/t/one-hosts-file-per-cookbook/15463/3 "2014-06-15T15:59:03Z")

</div>

Thanks, Dick. I really would have deserved an “RTFM” here. It was right in the help of the command 🙂
