I just solved this for me today. I’m away from work so I can’t copy my code. I created ip0, ip1 and ip2 in vars, set gather facts and did a set facts using a when is defined.
Mike > On Jan 29, 2021, at 16:18, Aris Aguirre <[email protected]> wrote: > > > NO funky.... it is just not working if it is being user in FOR LOOP. As ive > said..its working fine in Jinja template or 2.3 2.7. But its not workin in > the for loop like before. > > ansible dev -m setup |grep -i ipv4 > "ansible_all_ipv4_addresses": [ > "ansible_default_ipv4": { > "tx_checksum_ipv4": "off [fixed]", > "ipv4": { > "tx_checksum_ipv4": "off [fixed]", > "tx_checksum_ipv4": "off [fixed]", > "ipv4": { > > > >> On Friday, January 29, 2021 at 2:34:17 PM UTC-6 [email protected] wrote: >> On Fri, Jan 29, 2021 at 10:46 AM Aris Aguirre <[email protected]> wrote: >> > >> > Below is working when I was still using ansible 2.3 or maybe 2.7 But no >> > longer ansible 2.8 or 2.9. Please be advise no matter what it is not >> > working. >> > Thanks >> > >> > {% for host in groups.all %} >> > {{ hostvars[host]['ansible_all_ipv4_addresses'][0] }} {{ >> > hostvars[host]['ansible_fqdn'] }} {{ >> > hostvars[host]['inventory_hostname_short'] }} >> > {% endfor %} >> > >> > Below is the actual error. >> > >> > FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: >> > 'ansible.vars.hostvars.HostVarsVars object' has no attribute >> > 'ansible_all_ipv4_addresses'"} >> > >> Something else might be funky there: >> >> raub@desktop:~/dev/ansible$ ansible dns2 -m setup |grep -i ipv4 >> "ansible_all_ipv4_addresses": [ >> "ansible_default_ipv4": { >> "tx_checksum_ipv4": "off [fixed]", >> "ipv4": { >> "tx_checksum_ipv4": "off [fixed]", >> "ipv4": { >> "tx_checksum_ipv4": "off [fixed]", >> "ipv4": { >> raub@desktop:~/dev/ansible$ ansible --version >> ansible 2.9.17 >> config file = /home/raub/dev/ansible/ansible.cfg >> configured module search path = >> [u'/home/raub/.ansible/plugins/modules', >> u'/usr/share/ansible/plugins/modules'] >> ansible python module location = /usr/lib/python2.7/dist-packages/ansible >> executable location = /usr/bin/ansible >> python version = 2.7.12 (default, Oct 5 2020, 13:56:01) [GCC 5.4.0 20160609] >> raub@desktop:~/dev/ansible$ >> >> > -- >> > 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/0bc08e12-07aa-4df5-854c-4bcba9324605n%40googlegroups.com. >> > > > -- > 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/9e77fa1d-66b5-4959-a933-01cea5110053n%40googlegroups.com. -- 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/8D858536-AC3A-4455-8FEE-8DD93E54591E%40gmail.com.
