# Q: Obscure standard variables?

**URL:** <https://forum.ansible.com/t/q-obscure-standard-variables/25410>\
**Category:** Ansible Project\
**Created:** [September 5, 2017, 4:59pm UTC](https://forum.ansible.com/t/q-obscure-standard-variables/25410 "2017-09-05T16:59:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sieds\_Pallas](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Sieds\_Pallas](https://forum.ansible.com/u/Sieds_Pallas)\
**Post date:** [September 5, 2017, 4:59pm UTC](https://forum.ansible.com/t/q-obscure-standard-variables/25410/1 "2017-09-05T16:59:01Z")

</div>

Hi,  
I am working trhough some tutorials, and I have a question; I hope this is the proper forum to post it.  
In the solution provided with the tutorial I see some variables used that I do not understand:

inventory\_hostname  
and:  
groups[“webservers”]

I do not find these in the ansible facts (`ansible servera -m setup`).  
Also I cannot evaluate them using JINJA2 template “{{ inventory\_hostname }}”, apparently they are something else.  
“webservers” is a group in my inventory, but where is the hash “groups” defined or coming from?

The documentation appears to be silent about these things.

On a related note, how am I supposed to evaluate variables from the facts? e.g. “{{ ansible\_memory\_mb}}” gives an error stating that I am not allowed to use JINJA2 templates here.

Tom

---

<div class="post-metadata">

**Author:** ![Tom\_Bartsch](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@Tom\_Bartsch](https://forum.ansible.com/u/Tom_Bartsch)\
**Post date:** [September 6, 2017, 6:02am UTC](https://forum.ansible.com/t/q-obscure-standard-variables/25410/2 "2017-09-06T06:02:33Z")

</div>

Hi,

groups[“webservers”] means that you have to define a group named webservers within your hosts file.

_inventory\_hostname_ is the name of the hostname as configured in Ansible’s inventory hosts file.

Regards,  
Tom

---

<div class="post-metadata">

**Author:** ![Sieds\_Pallas](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Sieds\_Pallas](https://forum.ansible.com/u/Sieds_Pallas)\
**Post date:** [September 6, 2017, 7:34am UTC](https://forum.ansible.com/t/q-obscure-standard-variables/25410/3 "2017-09-06T07:34:48Z")

</div>

Hi Tom,  
I suspected that much. My questions are:

- Where are these coming from? I do not find documented that if you make a section [webservers] in your inventory, that automagically an array “groups” is created that has “webservers” as a member. Nor that there is such a thing as inventory\_hostname. In my inventory file I know I can specify ungrouped hosts and named groups of hosts: but I find no references to the variable inventory\_hostname. From the way it is used in the examples I gather it is the current hostname that ansible is working on plucked from the inventory.
- Also these variables appear to be used differently as other variables, i.e. not with “{{ }}”, so they are really odd. What syntax do we need to use for which items?

---

<div class="post-metadata">

**Author:** ![Sieds\_Pallas](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Sieds\_Pallas](https://forum.ansible.com/u/Sieds_Pallas)\
**Post date:** [September 8, 2017, 7:39am UTC](https://forum.ansible.com/t/q-obscure-standard-variables/25410/4 "2017-09-08T07:39:35Z")

</div>

A colleague of mine explained that these variables are created when the inventory is read.  
You can get to see those with:  
ansible -m debug -a “var=vars”  
This “vars” appears to be undocumented.  
HTH
