# Can we put /etc/ansible/hosts file in other place?

**URL:** <https://forum.ansible.com/t/can-we-put-etc-ansible-hosts-file-in-other-place/17289>\
**Category:** Ansible Project\
**Created:** [January 16, 2015, 1:32am UTC](https://forum.ansible.com/t/can-we-put-etc-ansible-hosts-file-in-other-place/17289 "2015-01-16T01:32:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zixu\_mo](https://avatars.discourse-cdn.com/v4/letter/z/e79b87/32.png) [@zixu\_mo](https://forum.ansible.com/u/zixu_mo)\
**Post date:** [January 16, 2015, 1:32am UTC](https://forum.ansible.com/t/can-we-put-etc-ansible-hosts-file-in-other-place/17289/1 "2015-01-16T01:32:13Z")

</div>

Can we put /etc/ansible/hosts file in other place?

such as /home/tomy/ansible/hosts

?

I would not like to run ansible on my pc with root access.

---

<div class="post-metadata">

**Author:** ![Tom\_Bamford](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@Tom\_Bamford](https://forum.ansible.com/u/Tom_Bamford)\
**Post date:** [January 16, 2015, 2:04pm UTC](https://forum.ansible.com/t/can-we-put-etc-ansible-hosts-file-in-other-place/17289/2 "2015-01-16T14:04:50Z")

</div>

You can place your inventory file(s) anywhere you like. Reference them [from ansible.cfg](http://docs.ansible.com/intro_configuration.html#hostfile), or using `-i /path/to/inventory`

​

---

<div class="post-metadata">

**Author:** ![Michel\_Blanc](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@Michel\_Blanc](https://forum.ansible.com/u/Michel_Blanc)\
**Post date:** [January 16, 2015, 4:59pm UTC](https://forum.ansible.com/t/can-we-put-etc-ansible-hosts-file-in-other-place/17289/3 "2015-01-16T16:59:08Z")

</div>

As stated by Tom, you can use -i but you can also change your  
~/.ansible.cfg :

&nbsp;&nbsp;&nbsp;&nbsp;[defaults]

&nbsp;&nbsp;&nbsp;&nbsp;# location of inventory file, eliminates need to specify -i  
&nbsp;&nbsp;&nbsp;&nbsp;hostfile = /home/tomy/ansible/hosts

Note that you can put a .ansible.cfg file in your "projects" directory,  
so you can ahave a "per-project" specific inventory.

M
