# Use invenvtory\_hosts in templates

**URL:** <https://forum.ansible.com/t/use-invenvtory-hosts-in-templates/18873>\
**Category:** Ansible Project\
**Created:** [July 28, 2015, 11:55am UTC](https://forum.ansible.com/t/use-invenvtory-hosts-in-templates/18873 "2015-07-28T11:55:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sagayaraj\_A](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@Sagayaraj\_A](https://forum.ansible.com/u/Sagayaraj_A)\
**Post date:** [July 28, 2015, 11:55am UTC](https://forum.ansible.com/t/use-invenvtory-hosts-in-templates/18873/1 "2015-07-28T11:55:00Z")

</div>

Hi All,

I’m trying to make use of the values in the inventory file to generate a configuration file out a of a Jinja template. Similarly I’m not able to use the ansible facts as well in the Jinja template (ex: { ansible\_hostanme } ).

Is this supported/possible?  
Is there something that I can do to make this work?

Appreciate your comments/help 🙂

Regards,  
Sagayaraj

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [July 28, 2015, 12:32pm UTC](https://forum.ansible.com/t/use-invenvtory-hosts-in-templates/18873/2 "2015-07-28T12:32:20Z")

</div>

its double mustaches:

{{ ansible\_hostanme }}

also make sure you have gathered facts.

---

<div class="post-metadata">

**Author:** ![Sagayaraj\_A](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@Sagayaraj\_A](https://forum.ansible.com/u/Sagayaraj_A)\
**Post date:** [July 28, 2015, 3:03pm UTC](https://forum.ansible.com/t/use-invenvtory-hosts-in-templates/18873/3 "2015-07-28T15:03:13Z")

</div>

thank you - that did the trick
