Interview Prep/Ansible/Variables, Facts and Precedence

What are the lowest and highest precedence sources, and why does that matter?

IntermediateConceptVariables, Facts and Precedence
Answer

Lowest is role defaults/main.yml, designed to be overridden by anything. Highest is extra vars (-e), which beat everything including set_fact and role vars.

This is why role defaults hold tunable settings, and why -e is a reliable override for a one-off run. It is also a trap in AWX: a job template's extra variables silently override your playbook logic, and an -e value cannot be changed from inside the play.

All Ansible questions Roadmap: Ansible

More on Variables, Facts and Precedence