On 23.06.2017 10:27, Phillip wrote:
I've run into a snag and feel like an idiot because I can't seem to figure
it out. you can filter through complex data by doing {{ var.sub.data }}
this works great but what about when that data has it's own array? A
perfect example would be something like eth0 data.

        "ipv4": {
            "address": "192.168.1.50",
            "broadcast": "192.168.1.255",
            "netmask": "255.255.255.0",
            "network": "192.168.1.0"
        },
        "ipv6": [
            {
                "address": "fe80::XXXX:XXXX:XXXX:94f7",
                "prefix": "64",
                "scope": "link"
            }
        ],

If we do {{ ansible_eth0.ipv4.address }} we get back the correct
192.168.1.50. What if we do {{ ansible_eth0.ipv6.address }}? We get an
error. Any data that has an array that is in another array can't seem to be
filtered out by standard filtering rules.

The ipv6 is a list of arrays, list is identified by [].
So to get the first entry in the list you could use this ansible_eth0.ipv6.0.address

--
Kai Stian Olstad

--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/61ba3d9b63c8b372161e5d62aefebf2e%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to