# Inventory variables and fact variables fixed up -- I think

**URL:** <https://forum.ansible.com/t/inventory-variables-and-fact-variables-fixed-up-i-think/11687>\
**Category:** Ansible Project\
**Created:** [July 16, 2012, 11:34pm UTC](https://forum.ansible.com/t/inventory-variables-and-fact-variables-fixed-up-i-think/11687 "2012-07-16T23:34:35Z")\
**Posts on this page:** 1\
**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:** [July 16, 2012, 11:34pm UTC](https://forum.ansible.com/t/inventory-variables-and-fact-variables-fixed-up-i-think/11687/1 "2012-07-16T23:34:35Z")

</div>

I have confirmed that:

\* playbooks now substitute inventory variables  
\* playbook templates can see facts

In fixing this -- I'm actually pretty happy about this -- all the stupid ways we figure out what template dictionary to use on what were able to be cleaned up, so there is just one place that dictionary is built -- executor\_internal\_inner in Runner.py. This will result in even more consistent tempting behavior. For instance, I caught that you probably couldn't use the "groups" hash in a template, and fixed that.

One small incompatible note -- previously groups magic variable returned a list of hashes like:

groups = {  
&nbsp;&nbsp;&nbsp;&nbsp;groupname1 : {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hostname1: { all facts for this host }  
&nbsp;&nbsp;&nbsp;&nbsp;},  
}

This passed my code review radar initialy and needed to be fixed for a few reasons.

One, this was totally redundant with "hostvars" and duplicated a copy of all the variables in the template dictionary, which is a waste of RAM and processing really.  
Two, more so, it was calling the "get\_variables" function on a host way too much, which would have been pretty slow.

So it's now just:

groups = {  
&nbsp;&nbsp;&nbsp;&nbsp;groupname1: [hostname1, hostname2, hostname3],  
&nbsp;&nbsp;&nbsp;&nbsp;groupname2: […]  
}

Anyway, I \*THINK\* all issues are resolved, but help testing is welcome -- I'm going to test more on my end and if you don't hear from me, consider that a good thing.

--Michael
