# Ansible facts inside templates

**URL:** <https://forum.ansible.com/t/ansible-facts-inside-templates/12876>\
**Category:** Ansible Project\
**Created:** [May 27, 2013, 11:25am UTC](https://forum.ansible.com/t/ansible-facts-inside-templates/12876 "2013-05-27T11:25:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dmitry\_Horbach](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@Dmitry\_Horbach](https://forum.ansible.com/u/Dmitry_Horbach)\
**Post date:** [May 27, 2013, 11:25am UTC](https://forum.ansible.com/t/ansible-facts-inside-templates/12876/1 "2013-05-27T11:25:44Z")

</div>

Hi,

Could someone please point me to the proper way of using ansible facts inside templates?  
I’m at latest devel and have the following content inside template:

{{ inventory\_hostname }}  
{{ ansible\_hostname }}

With template action it results in just IP for first variable and empty ansible\_hostname (other facts doesn’t work too)  
Setup module correctly displays ansible\_hostname during test run.

Thanks,  
Dmitry

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 27, 2013, 3:14pm UTC](https://forum.ansible.com/t/ansible-facts-inside-templates/12876/2 "2013-05-27T15:14:30Z")

</div>

You need to tell me a bit more about your setup.

Can I see a snippet of your playbook? Have you disabled facts? What OS are you managing?

---

<div class="post-metadata">

**Author:** ![Dmitry\_Horbach](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@Dmitry\_Horbach](https://forum.ansible.com/u/Dmitry_Horbach)\
**Post date:** [May 27, 2013, 8:53pm UTC](https://forum.ansible.com/t/ansible-facts-inside-templates/12876/3 "2013-05-27T20:53:15Z")

</div>

Thanks Michael, that was indeed disabled facts at the top of playbook. After enabling it all worked as expected.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 27, 2013, 9:06pm UTC](https://forum.ansible.com/t/ansible-facts-inside-templates/12876/4 "2013-05-27T21:06:51Z")

</div>

Great! Glad it is all working!
