Hi remove hostvars[host].ansible_hostname and try with hostvars[host].ansible_facts.hostname if you are doing it from setup module or gayher_facts
If it’s not fixed put your playbook here On Tue, 27 Aug 2019 at 5:36 PM, Rafael Tomelin <[email protected]> wrote: > > 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? > > > > -- > Atenciosamente, > > Rafael Tomelin > Tel.: 51-984104084 > Skype: rafael.tomelin > > LPI ID: LPI000191271 > Red Hat Certified Engineer > Puppet Professional 2017 Certification > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CAGEUqbCW9GZVwGQ%2BtqQopQBpOAEV-c7_08ud0TWu-AawmEDiRA%40mail.gmail.com > <https://groups.google.com/d/msgid/ansible-project/CAGEUqbCW9GZVwGQ%2BtqQopQBpOAEV-c7_08ud0TWu-AawmEDiRA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ%2BRxtRneB6nrP680LhkiQ9WRBJ-r3KDo1u9EVFkzE8MUsbapQ%40mail.gmail.com.
