Select Page

To see all available variables try command

ansible -m setup hostname

To get variables from remote instance you have to set “gather_facts: yes” in playbook.

Here are some interesting ones:

  • ansible_all_ipv4_addresses – array of IPv4 addresses
  • ansible_all_ipv6_addresses – array of IPv6
  • “ansible_architecture”: “x86_64”
  • “ansible_bios_date”: “08/06/2015”
  • “ansible_bios_version”: “F2”
  • “ansible_date_time”: {
    “date”: “2017-07-28”,
    “day”: “28”,
    “epoch”: “1501229129”,
    “hour”: “10”,
    “iso8601”: “2017-07-28T08:05:29Z”,
    “iso8601_basic”: “20170728T100529132973”,
    “iso8601_basic_short”: “20170728T100529”,
    “iso8601_micro”: “2017-07-28T08:05:29.133035Z”,
    “minute”: “05”,
    “month”: “07”,
    “second”: “29”,
    “time”: “10:05:29”,
    “tz”: “CEST”,
    “tz_offset”: “+0200”,
    “weekday”: “Freitag”,
    “weekday_number”: “5”,
    “weeknumber”: “30”,
    “year”: “2017”
    }
  • “ansible_default_ipv4”: {
    “address”: “192.168.xxx.xx”,
    “alias”: “eth0”,
    “broadcast”: “192.168.xxx.xxx”,
    “gateway”: “192.168.178.1”,
    “interface”: “eth0”,
    “macaddress”: “xx:xx:xx:xx:xx:xx”,
    “mtu”: 1500,
    “netmask”: “255.255.255.0”,
    “network”: “192.168.178.0”,
    “type”: “ether”
    }
  • ansible_default_ipv6
  • ansible_devices – sda, sdb
  • “ansible_distribution”: “Ubuntu”
  • “ansible_distribution_major_version”: “16”
  • “ansible_distribution_release”: “xenial”
  • “ansible_distribution_version”: “16.04”
  • “ansible_dns”: {
    “nameservers”: [
    “127.0.1.1”
    ],
    “search”: [
    “fritz.box”
    ]
    }
  • ansible_env – ansible_env.LANG, ansible_env.PATH, ansible_env.USER, …
  • ansible_eth0
  • ansible_memtotal_mb
  • ansible_mounts
  • “ansible_nodename”: “josef-B85M-D2V”
  • “ansible_os_family”: “Debian”
  • “ansible_pkg_mgr”: “apt”
  • “ansible_processor_cores”: 4
  • “ansible_processor_count”: 1
  • “ansible_processor_threads_per_core”: 2
  • “ansible_processor_vcpus”: 8
  • ansible_ssh_host_key_dsa_public
  • ansible_ssh_host_key_ecdsa_public
  • ansible_ssh_host_key_ed25519_public
  • ansible_ssh_host_key_rsa_public
  • “ansible_swapfree_mb”: 16283
  • “ansible_swaptotal_mb”: 16283
  • “ansible_system”: “Linux”
  • ansible_user_dir
  • ansible_user_id
  • ansible_user_shell
  • ansible_hostname – hostname of remote machine based on facts
  • inventory_hostname – hostname of remote machine based on inventory file