# Strategies for testing if network range available

**URL:** <https://forum.ansible.com/t/strategies-for-testing-if-network-range-available/24970>\
**Category:** Ansible Project\
**Created:** [July 12, 2017, 9:54pm UTC](https://forum.ansible.com/t/strategies-for-testing-if-network-range-available/24970 "2017-07-12T21:54:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josef\_Fortier](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@Josef\_Fortier](https://forum.ansible.com/u/Josef_Fortier)\
**Post date:** [July 12, 2017, 9:54pm UTC](https://forum.ansible.com/t/strategies-for-testing-if-network-range-available/24970/1 "2017-07-12T21:54:40Z")

</div>

My goal is to fail early and warn if storage network not set up (and set up mounts if it is set up).

I’ve an approach that seems to work OK, but was wondering if there is a preferred/better path

set\_fact:  
has\_storage\_lan: ‘{{ ansible\_all\_ipv4\_addresses|join()|match(“10.0.20.”) }}’

This amounts to flattening the IP address array and converting to string values to then match on leading network range.

Is there a better way?

(thanks)

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [July 13, 2017, 10:54am UTC](https://forum.ansible.com/t/strategies-for-testing-if-network-range-available/24970/2 "2017-07-13T10:54:56Z")

</div>

Yes, use the dedicated 'ipaddr' filter:

&nbsp;&nbsp;- set\_fact:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;has\_storage\_lan: "{{ ansible\_all\_ipv4\_addresses |  
ipaddr('10.0.20.0/24') }}"

[http://docs.ansible.com/ansible/playbooks\_filters\_ipaddr.html#getting-information-about-hosts-and-networks](http://docs.ansible.com/ansible/playbooks_filters_ipaddr.html#getting-information-about-hosts-and-networks)
