Variables
Referenced in the playbook as {{ name }} variables allow for consolidation of playbooks as well as flexibility.
Variables can be defined:
- In the inventory file. Particular values per host or group can be defined and will be picked up
[mygroup]
1.2.3.4 apache_package=apache2
[mygroup:vars]
other_var=somethingIn playbooks themselves using
varsblock orvars_filefor external filesIn a
host_varsdirectory. In this standard directory, each file corresponds to a host (either IP or hostname) and ansible will pick up automatically the variables defined there for each host. Similarly agroup_varsdirectory can be used where the name of the files are the name of the groups in the inventory. More info here