# Ansible-play reference a local hosts file

**URL:** <https://forum.ansible.com/t/ansible-play-reference-a-local-hosts-file/21980>\
**Category:** Ansible Project\
**Created:** [July 10, 2016, 6:22pm UTC](https://forum.ansible.com/t/ansible-play-reference-a-local-hosts-file/21980 "2016-07-10T18:22:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Marquez](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@Eric\_Marquez](https://forum.ansible.com/u/Eric_Marquez)\
**Post date:** [July 10, 2016, 6:22pm UTC](https://forum.ansible.com/t/ansible-play-reference-a-local-hosts-file/21980/1 "2016-07-10T18:22:36Z")

</div>

How do I get Ansible-play to reference a local hosts files? I created a hosts file in the same directly with my site.yaml file but it doesn’t seem to reference it. Is there a way to get it to use a local vs the /etc/Ansible/hosts?

I would like to have a local version and not need to update the master with a priv account.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 10, 2016, 6:36pm UTC](https://forum.ansible.com/t/ansible-play-reference-a-local-hosts-file/21980/2 "2016-07-10T18:36:00Z")

</div>

In the same directory as your site.yaml and host file, create a ansible.cfg file with the following content:

[defaults]  
hostfile = \<name of your hostfile\>

---

<div class="post-metadata">

**Author:** ![Eric\_Marquez](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@Eric\_Marquez](https://forum.ansible.com/u/Eric_Marquez)\
**Post date:** [July 10, 2016, 6:40pm UTC](https://forum.ansible.com/t/ansible-play-reference-a-local-hosts-file/21980/3 "2016-07-10T18:40:37Z")

</div>

Great thanks. I like that better than using the inventory argument.
