Facts like `ansible_hostname` became undefined after someone changed `ansible.cfg`
IntermediateTroubleshootingVariables, Facts and Precedence Problems
Answer
Likely causes → inject_facts_as_vars = False was set. Facts are then only available under ansible_facts, not as top-level ansible_* variables. Recent ansible-core releases also warn about relying on the injected names.
Diagnose → ansible-config dump --only-changed | grep -i inject
Fix → Update the code to the namespaced form:
"{{ ansible_facts['hostname'] }}" # not ansible_hostname
"{{ ansible_facts['os_family'] }}" # not ansible_os_family
Prevent → Write all new roles with ansible_facts[...]. It is future-proof and does not collide with your own variables.
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 instancesBeginner`web01` is in both `prod` and `eu` groups, and `ntp_server` has a different value on every run you checkAdvanced