Got it, Ill just call the {{ ip0 }} in Jinja. Hope there's other way to
figure it out using the for LOOP.
Thank you
On Saturday, January 30, 2021 at 9:37:42 AM UTC-6 [email protected] wrote:
> I don’t mind at all. :)
>
> —
> - hosts: all
> gather_facts: yes
>
> vars:
> ip0: “”
> ip1: “”
> ip2: “”
>
> tasks:
> - set_fact:
> ip0: “{{ansible_all_ipv4_addressess[0]}}”
> when: ansible_all_ipv4_addresses[0] is defined
>
> And the same for 1 and 2.
>
> Mike
>
> On Jan 30, 2021, at 09:13, Aris Aguirre <[email protected]> wrote:
>
> DO you mind showing me, Is this a new problem?
>
> On Friday, January 29, 2021 at 5:28:09 PM UTC-6 [email protected] wrote:
>
>> 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
>>
>> <https://groups.google.com/d/msgid/ansible-project/9e77fa1d-66b5-4959-a933-01cea5110053n%40googlegroups.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/f1053ed2-8a14-42d1-ae13-191758235a60n%40googlegroups.com
>
> <https://groups.google.com/d/msgid/ansible-project/f1053ed2-8a14-42d1-ae13-191758235a60n%40googlegroups.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/61cd5398-164a-457a-b133-35e9c91add16n%40googlegroups.com.