# Built-in facts for use in templates and actions! (goodbye Ruby deps!)

**URL:** <https://forum.ansible.com/t/built-in-facts-for-use-in-templates-and-actions-goodbye-ruby-deps/11421>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [April 19, 2012, 1:40am UTC](https://forum.ansible.com/t/built-in-facts-for-use-in-templates-and-actions-goodbye-ruby-deps/11421 "2012-04-19T01:40:51Z")\
**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:** [April 19, 2012, 1:40am UTC](https://forum.ansible.com/t/built-in-facts-for-use-in-templates-and-actions-goodbye-ruby-deps/11421/1 "2012-04-19T01:40:51Z")

</div>

Hi all,

So I know a lot of you like to run relatively minimal nodes and often  
don't need a Ruby interpreter, except that (until now) if you wanted  
things like facter and ohai gave you, you had to run Ohai and facter  
to get information about the host to bubble up.

This has now changed with an excellent patch from Stephen Fromm (now  
available on the integration branch)

You can use these variables (see below) in both action lines and  
templates, and I will soon update the web page to reflect this.

You get a lot of top level facts like below, all prefixed with  
"ansible\_". Note that the setup module still gets facts from facter  
and ohai if you have them installed, (facter also requires  
rubygem-json), so technically you could intermix all three if you  
really wanted..

Stephen and I have decided to just concentrate on the core facts most  
people need at first, but we can take patches to take more.  
Keep in mind these must be cross platform, so the second any of these  
don't work on your OS, please file a ticket. It is ok if some  
facts aren't available on all platforms, but for every Unix/Linux  
platform, I expect the ansible setup module to still work perfectly.

Testing welcome. Easiest way to test is just:

ansible all -m setup

Or just use a playbook

And then look at /etc/ansible/setup to see what variables it determined

You should see stuff like:

{  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_architecture": "x86\_64",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_distribution": "CentOS",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_distribution\_release": "Final",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_distribution\_version": "6.2",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_eth0": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ipv4": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"address": "REDACTED",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"netmask": "255.255.255.0"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ipv6": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"address": "REDACTED",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"prefix": "64",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"scope": "link"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"macaddress": "REDACTED"  
&nbsp;&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_form\_factor": "Other",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_fqdn": "localhost.localdomain",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_hostname": "localhost",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_interfaces": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"lo",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"eth0"  
&nbsp;&nbsp;&nbsp;&nbsp;],  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_kernel": "2.6.32-220.2.1.el6.x86\_64",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_lo": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ipv4": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"address": "127.0.0.1",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"netmask": "255.0.0.0"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ipv6": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"address": "::1",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"prefix": "128",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"scope": "host"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],  
&nbsp;&nbsp;&nbsp;"ansible\_machine": "x86\_64",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_memfree\_mb": 89,  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_memtotal\_mb": 993,  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_processor": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Intel(R) Core(TM) i7-2677M CPU @ 1.80GHz"  
&nbsp;&nbsp;&nbsp;&nbsp;],  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_processor\_cores": "NA",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_processor\_count": 1,  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_product\_name": "VMware Virtual Platform",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_product\_serial": "REDACTED",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_product\_uuid": "REDACTED",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_product\_version": "None",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_python\_version": "2.6.6",  
&nbsp;&nbsp;&nbsp;"ansible\_product\_version": "None",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_python\_version": "2.6.6",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_ssh\_host\_key\_dsa\_public": REDACTED",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_ssh\_host\_key\_rsa\_public": "REDACTED",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_swapfree\_mb": 1822,  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_swaptotal\_mb": 2015,  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_system": "Linux",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_system\_vendor": "VMware, Inc.",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_virtualization\_role": "None",  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_virtualization\_type": "None",

Thanks Stephen for a really awesome addition!

--Michael
