# A list of variables that are available for reference from template

**URL:** <https://forum.ansible.com/t/a-list-of-variables-that-are-available-for-reference-from-template/12041>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [October 27, 2012, 8:49pm UTC](https://forum.ansible.com/t/a-list-of-variables-that-are-available-for-reference-from-template/12041 "2012-10-27T20:49:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [October 27, 2012, 8:49pm UTC](https://forum.ansible.com/t/a-list-of-variables-that-are-available-for-reference-from-template/12041/1 "2012-10-27T20:49:14Z")

</div>

> I'd like to use the templating for a simple tasks, but what variables are  
> there (outside the one you can setup in a playbook) for me to use? I  
> installed facter, but there should be a few ansible\_XXXX variables right?  
> Is there a way to produce a list to see what I can reference?

Easiest way to do this is:

ansible hostname -m setup

It will show you all of the variables that are available. Ansible  
provides a ton of it's own facts, so you do not need facter or ohai  
unless you just remember what facts they provide or they provide  
something we don't (though we'd really like to add those things you  
find  
missing, if any)

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [October 27, 2012, 8:54pm UTC](https://forum.ansible.com/t/a-list-of-variables-that-are-available-for-reference-from-template/12041/2 "2012-10-27T20:54:42Z")

</div>

Wow that was fast 😉

Thank you for the answer, and to jump straight in: I seem to be missing a domain variable, could that be correct?

I’m really enjoying this, it’s like a breath of fresh air!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [October 27, 2012, 8:56pm UTC](https://forum.ansible.com/t/a-list-of-variables-that-are-available-for-reference-from-template/12041/3 "2012-10-27T20:56:33Z")

</div>

> Thank you for the answer, and to jump straight in: I seem to be missing a  
> domain variable, could that be correct?

Yeah, we should add that. Want to send me a pull request to the  
library/setup module to add one?

--Michael

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [October 28, 2012, 8:39am UTC](https://forum.ansible.com/t/a-list-of-variables-that-are-available-for-reference-from-template/12041/4 "2012-10-28T08:39:10Z")

</div>

One day I want to be able to do those things (Currently do not even know what it means) I’ve only recently started learning python. (Which is also how I discovered ansible)…

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [October 28, 2012, 11:08am UTC](https://forum.ansible.com/t/a-list-of-variables-that-are-available-for-reference-from-template/12041/5 "2012-10-28T11:08:06Z")

</div>

[https://github.com/ansible/ansible/pull/1466](https://github.com/ansible/ansible/pull/1466)

---

<div class="post-metadata">

**Author:** ![Nigel\_Metheringham](https://avatars.discourse-cdn.com/v4/letter/n/3ec8ea/32.png) [@Nigel\_Metheringham](https://forum.ansible.com/u/Nigel_Metheringham)\
**Post date:** [October 28, 2012, 11:25am UTC](https://forum.ansible.com/t/a-list-of-variables-that-are-available-for-reference-from-template/12041/6 "2012-10-28T11:25:31Z")

</div>

Mark Maas wrote:

> &nbsp;&nbsp;&nbsp;&nbsp;\> Thank you for the answer, and to jump straight in: I seem to be  
> &nbsp;&nbsp;&nbsp;&nbsp;missing a  
> &nbsp;&nbsp;&nbsp;&nbsp;\> domain variable, could that be correct?  
> &nbsp;&nbsp;&nbsp;&nbsp;\>  
> &nbsp;&nbsp;&nbsp;&nbsp;Yeah, we should add that. Want to send me a pull request to the  
> &nbsp;&nbsp;&nbsp;&nbsp;library/setup module to add one?
> 
> One day I want to be able to do those things (Currently do not even know  
> what it means) I've only recently started learning python. (Which is  
> also how I discovered ansible)....

Pull request is a git or rather github term - basically a way to hand  
over a patch to code.

If you have a look at library/setup in ansible, you will see the python  
that builds the various facts, and in get\_platform\_facts there is the  
basic stuff like hostname etc.  
Serge got a version of domainname contributed just before I did - see  
[https://github.com/ansible/ansible/pull/1466](https://github.com/ansible/ansible/pull/1466)

For those starting python (or at least for me) the only peculiar thing  
in there is that the join method applies to a string and not to the  
list, so giving:-  
&nbsp;&nbsp;self.facts['domainname'] = '.'.join(self.facts['fqdn'].split('.')[1:])

Hope that helps

&nbsp;&nbsp;Nigel.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [October 28, 2012, 1:49pm UTC](https://forum.ansible.com/t/a-list-of-variables-that-are-available-for-reference-from-template/12041/7 "2012-10-28T13:49:48Z")

</div>

Serge just sent a patch over, so we'll have this soon 🙂

If you want to learn about how to use pull requests, github has some  
very good documentation on it:

[https://help.github.com/articles/using-pull-requests](https://help.github.com/articles/using-pull-requests)
