# hostvars\[some\_ip\] does not contain \`ansible\_hostname\`

**URL:** <https://forum.ansible.com/t/hostvars-some-ip-does-not-contain-ansible-hostname/28936>\
**Category:** Ansible Project\
**Created:** [November 3, 2018, 8:15pm UTC](https://forum.ansible.com/t/hostvars-some-ip-does-not-contain-ansible-hostname/28936 "2018-11-03T20:15:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [November 3, 2018, 8:15pm UTC](https://forum.ansible.com/t/hostvars-some-ip-does-not-contain-ansible-hostname/28936/1 "2018-11-03T20:15:23Z")

</div>

Why would this be? It has lots and lots of ansible\_\* variables, but some others like ansible\_hostname or ansible\_mounts.

This is not the case for hosts though, just some.

---

<div class="post-metadata">

**Author:** ![Uwe\_Sauter](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@Uwe\_Sauter](https://forum.ansible.com/u/Uwe_Sauter)\
**Post date:** [November 3, 2018, 8:20pm UTC](https://forum.ansible.com/t/hostvars-some-ip-does-not-contain-ansible-hostname/28936/2 "2018-11-03T20:20:11Z")

</div>

In order to access some ansible\_\* variables you need to gather facts on the host before.

See e.g. [https://stackoverflow.com/questions/45908067/whats-the-difference-between-inventory-hostname-and-ansible-hostname](https://stackoverflow.com/questions/45908067/whats-the-difference-between-inventory-hostname-and-ansible-hostname)
