Last Updated: September 09, 2019
· mpdehaan

See what variables you can use in templates

Various facts about the remote system are available as variables for use in templates. The easiest way to check what those values are is to execute the setup module on the remote host, like so.

ansible -m setup

You will get back JSON information with all of the values available.

centos2 | success >> {
    "ansible_facts": {
        "ansible_all_ipv4_addresses": [
        "ansible_all_ipv6_addresses": [
        "ansible_architecture": "x86_64", 
        "ansible_bios_date": "09/20/2012", 
        "ansible_bios_version": "6.00", 

This means in a playbook you can use variables like:


or in a Jinja2 template this is just:

{{ ansible_architecture }}

2 Responses
Add your response

with ansible 0.9 if there is no /etc/ansible/hosts file on your executing host you will get a Traceback from Python complaining about the global inventory file being no present, if you don't have an /etc/ansible/hosts instead do a: 'ansible -i someinventoryfile -m setup'

over 1 year ago ·

@elee think maybe you wanted to start a new tip versus commenting on this one maybe.

Latest released is 1.0 and 1.1 is the current development branch, which doesn't present an error if that file is missing.

over 1 year ago ·