The generated `upstream {}` block contains `web01` instead of IPs, and Nginx cannot resolve the names
BeginnerTroubleshootingVariables, Facts and Precedence Problems
Answer
Likely causes → The template uses inventory_hostname, which is the inventory alias. The address to connect to is ansible_host, and the real interface IP is a fact.
Fix →
{% for h in groups['app'] %}
server {{ hostvars[h]['ansible_host'] | default(h) }}:8080;
{% endfor %}
Or use hostvars[h]['ansible_facts']['default_ipv4']['address'] if facts for those hosts have been gathered.
Prevent → Use inventory_hostname for labels and logs, and ansible_host or IP facts for network addresses.
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