# hosts file pattern

**URL:** <https://forum.ansible.com/t/hosts-file-pattern/11594>\
**Category:** Ansible Project\
**Created:** [June 1, 2012, 8:47am UTC](https://forum.ansible.com/t/hosts-file-pattern/11594 "2012-06-01T08:47:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan\_Palley](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Jonathan\_Palley](https://forum.ansible.com/u/Jonathan_Palley)\
**Post date:** [June 1, 2012, 8:47am UTC](https://forum.ansible.com/t/hosts-file-pattern/11594/1 "2012-06-01T08:47:37Z")

</div>

All -  
&nbsp;&nbsp;New to ansible and trying to understand the pattern of putting hosts  
in the /etc/ansible directory.

I want ansible accessible from multiple machines and my intuition is  
to put something like a .hosts file in the root directory of my  
ansible git playbooks and have ansible by default look there (if /  
etc/... doesn't exist). Then its just a checkout and a command to get  
going. Why not allow this?

(If this is of interest, I'm happy to contribute the code for it).

Thanks

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [June 1, 2012, 11:56am UTC](https://forum.ansible.com/t/hosts-file-pattern/11594/2 "2012-06-01T11:56:38Z")

</div>

--Michael

---

<div class="post-metadata">

**Author:** ![Jonathan\_Palley](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Jonathan\_Palley](https://forum.ansible.com/u/Jonathan_Palley)\
**Post date:** [June 1, 2012, 2:58pm UTC](https://forum.ansible.com/t/hosts-file-pattern/11594/3 "2012-06-01T14:58:20Z")

</div>

Yes, I got this. Was just curious why not having it first search  
global and then local directory, or if I was missing another design  
goal.

Regardless, brilliant software...finally feel like I can automate  
server tasks in a logical way. Thanks for getting it out here.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [June 1, 2012, 3:05pm UTC](https://forum.ansible.com/t/hosts-file-pattern/11594/4 "2012-06-01T15:05:55Z")

</div>

> Yes, I got this. Was just curious why not having it first search  
> global and then local directory, or if I was missing another design  
> goal.

Yeah, I suspect folks will have only one inventory file.

It can be set by the ANSIBLE\_HOSTS environment variable if you want.

> Regardless, brilliant software…finally feel like I can automate  
> server tasks in a logical way. Thanks for getting it out here.

Glad to hear it, thanks!
