Hi,
I have an inventory with groups this configuration the DB Servers:
[db]
192.168.0.1
192.168.0.2
192.168.0.3
I want to do loop the groups and get variable ipaddress in template.j2. My loop is:
{% for host in groups[‘db’] -%}
host all postgres {{ hostvars[host].ansible_hostname }}/32 trust
{% endfor %}
My error
“msg”: “AnsibleUndefinedVariable: ‘ansible.vars.hostvars.HostVarsVars object’ has no attribute ‘ansible_hostname’”,
What`s correct configuration?