This article covers the various types of variables used in Ansible. In fact, they are very useful for increasing the flexibility and comprehensibility of a code when used in an appropriate manner.
Basically, The use of variables simplifies the management of dynamic values throughout an Ansible project and can potentially reduce the number of human errors.
Different types of variables in Ansible:
- Global: this is set by config, environment variables and the command line.
- Play: each play and contained structures, vars entries, include_vars, role defaults and vars.
- Host: variables directly associated to a host, like inventory, facts or registered task outputs.