# How to acces ansible\_host from the inventory?

**URL:** <https://forum.ansible.com/t/how-to-acces-ansible-host-from-the-inventory/23456>\
**Category:** Ansible Project\
**Created:** [January 13, 2017, 4:00pm UTC](https://forum.ansible.com/t/how-to-acces-ansible-host-from-the-inventory/23456 "2017-01-13T16:00:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cev\_Ing](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Cev\_Ing](https://forum.ansible.com/u/Cev_Ing)\
**Post date:** [January 13, 2017, 4:00pm UTC](https://forum.ansible.com/t/how-to-acces-ansible-host-from-the-inventory/23456/1 "2017-01-13T16:00:27Z")

</div>

I have an inventory with IP addresses:

[myhosts]  
host1 ansible\_host=10.0.0.1  
host2 ansible\_host=10.0.0.2

This makes me independent from the /etc/hosts file, which I want to manage with Ansible.

I wrote a bootstrap playbook to grab all SSH keys. This has to be run before anything else.

---

<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:** [January 13, 2017, 7:13pm UTC](https://forum.ansible.com/t/how-to-acces-ansible-host-from-the-inventory/23456/2 "2017-01-13T19:13:11Z")

</div>

Have you tried "{{ ansible\_host }}" ?

---

<div class="post-metadata">

**Author:** ![Cev\_Ing](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Cev\_Ing](https://forum.ansible.com/u/Cev_Ing)\
**Post date:** [January 16, 2017, 8:50am UTC](https://forum.ansible.com/t/how-to-acces-ansible-host-from-the-inventory/23456/3 "2017-01-16T08:50:28Z")

</div>

No. Thanks that was easy! Probably too easy for me 😉
