Variables in `group_vars/webservers.yml` are silently ignored
BeginnerTroubleshootingVariables, Facts and Precedence Problems
Answer
Likely causes → Ansible only loads group_vars/ and host_vars/ from two places: next to the inventory source and next to the playbook. A group_vars/ folder anywhere else (repo root, roles/) is not read. A filename that does not match the group name exactly (webserver.yml against group webservers) is also skipped.
Diagnose →
ansible-inventory -i inventories/prod/hosts.yml --host web01 --vars
ansible-inventory -i inventories/prod/hosts.yml --graph
If the variable is not shown, Ansible never loaded it.
Fix → Move the folder to inventories/prod/group_vars/webservers.yml, or next to the playbook. Make the filename match the group name.
Prevent → Use the standard layout of one inventory directory per environment, each with its own group_vars/ and host_vars/.
More on Variables, Facts and Precedence Problems
You set `nginx_port: 8443` in inventory `group_vars`, but the role still uses `80`Intermediate`set_fact: release_tag=v2` runs, but later tasks still see `v1`Intermediate`'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_default_ipv4'` when templating `hostvars['db01']`Intermediate`'ansible_eth0' is undefined` on new cloud instancesBeginnerFacts like `ansible_hostname` became undefined after someone changed `ansible.cfg`Intermediate`web01` is in both `prod` and `eu` groups, and `ntp_server` has a different value on every run you checkAdvanced