Junior — Middle
Where in Ansible are variables with the highest priority defined?
sobes.tech AI
Answer from AI
In Ansible, variables with the highest priority are determined in the following places (from lower to higher priority):
- Variables defined in inventory files
- Variables defined in group_vars
- Variables defined in host_vars
- Variables passed via the command line using the
-e(extra vars) parameter
The variables passed through -e (extra vars) at playbook run have the highest priority. They override any other variables defined in playbooks, roles, or inventory.
Example of running with a high-priority variable:
ansible-playbook site.yml -e "variable_name=value"