`host_vars/web01.yml` is ignored for one host
BeginnerTroubleshootingVariables, Facts and Precedence Problems
Answer
Likely causes → The host's inventory name is web01.example.com (or an IP address), and the host_vars filename has to match the inventory hostname exactly, not ansible_host or the short name.
Diagnose → ansible-inventory --list | jq '._meta.hostvars | keys'
Fix → Rename the file to host_vars/web01.example.com.yml, or change the inventory to use a short alias with ansible_host set:
web01 ansible_host=web01.example.com
Prevent → Use short, stable aliases as inventory names, and keep FQDNs and IPs in ansible_host.
More on Variables, Facts and Precedence Problems
Variables in `group_vars/webservers.yml` are silently ignoredBeginnerYou 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