Ansible – Variables

Variables are containers for storing the values. Like any programming language, Ansible does support variables.

Ansible variable names should start with letters. Variable can contain letters, numbers, and underscores.

Types of Ansible variables

  • Default Variables
  • Inventory Variables
  • Facts and Local Facts
  • Registered Variables

Default Variables are variables defined by the ansible. Ansible provides the following default variables,

  • inventory_hostname
  • inventory_hostname_short
  • groups, and groups.key (keys of the group dictionary)

Note: Host variables have higher priority than group variables.