Variable precedence
We specified variable defaults, used them in inventory files, and defined the same variable from different places (for example, defaults, vars, and inventory). Let's now analyze the output of the templates to understand what happened with all those variables.
The following is the figure showing the my.cnf
file on Ubuntu:
The following is the analysis of the screenshot:
- The file has a notice in the comments section. This can deter admins from making manual changes to the file.
- Most of the variables come from the defaults in a role. This is because Debian is our default family of operating systems and we already have sane defaults set for it. Similarly, for other operating system platforms, we are setting variable defaults from the
vars
directory in a role. - Even though the
bind_address
parameter is specified in the defaults andgroup_vars
, it takes a value from the playbook's role parameter, which has a higher precedence over the other two levels.
The following diagram...