# Filtering by arrays within arrays.

**URL:** <https://forum.ansible.com/t/filtering-by-arrays-within-arrays/24808>\
**Category:** Ansible Project\
**Created:** [June 23, 2017, 8:27am UTC](https://forum.ansible.com/t/filtering-by-arrays-within-arrays/24808 "2017-06-23T08:27:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phillip1](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@Phillip1](https://forum.ansible.com/u/Phillip1)\
**Post date:** [June 23, 2017, 8:27am UTC](https://forum.ansible.com/t/filtering-by-arrays-within-arrays/24808/1 "2017-06-23T08:27:27Z")

</div>

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.

I am well aware I can use other variables to get this data they are just examples. Here comes the big question. **How can we filter to sub-arrays like that? where we could get just the prefix or just the address?**

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [June 27, 2017, 7:04am UTC](https://forum.ansible.com/t/filtering-by-arrays-within-arrays/24808/2 "2017-06-27T07:04:41Z")

</div>

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
