A variable you set in `group_vars` is being overridden and you do not know where. How do you find the source?
IntermediateScenarioVariables, Facts and Templates
Answer
Situation read → Precedence conflict across up to 22 levels.
What I'd do →
- Print the final value:
ansible web01 -m debug -a "var=app_port". - Search the repo:
grep -rn "app_port" .. - Check the usual suspects:
-eextra vars,set_fact, rolevars/(higher thangroup_vars), playvars:, andhost_vars. - Run with
-vvvand look at where each var file loads.
Why → Role vars/main.yml, set_fact, include_vars and -e all outrank group_vars.
Interview tip → Say you keep tunable defaults in role defaults/ precisely because it has the lowest precedence.
More on Variables, Facts and Templates
You need different values per environment without copying playbooks.BeginnerYou must render an Nginx config with one `server` block per site from a list.IntermediateA template needs the IPs of all hosts in the `db` group, for example for a replication config.IntermediateNothing should be rendered unless a mandatory variable is supplied.BeginnerPer-host values, like `server_id` for MySQL, must be unique and stable.IntermediateA fact you need is not collected by default, such as a custom application version.Intermediate