Ansible host variables and group variables
As you learned previously, like many other automation tools, Ansible allows you to use variables for dynamically executing playbooks. It is possible to configure the same playbook so that it can be executed for different desired states using variables and values. We can keep the variables inside the playbooks, external variable files, inventory files, and many other places. You learned more about variables in Chapter 6, Automating Microsoft Windows and Network Devices.
The same variable can be specified in multiple places but depending on the location of your variable and variable precedence, Ansible will apply the appropriate value for the variable.
Ansible uses the appropriate variable values and executes the playbooks based on them; the following diagram shows the typical flow where Ansible combines the variable values with the playbook:
Figure 16.9 – Ansible combines playbooks and variables for the final...