# run task based on host network

**URL:** <https://forum.ansible.com/t/run-task-based-on-host-network/36177>\
**Category:** Ansible Project\
**Created:** [January 5, 2022, 7:51pm UTC](https://forum.ansible.com/t/run-task-based-on-host-network/36177 "2022-01-05T19:51:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![user88](https://avatars.discourse-cdn.com/v4/letter/u/d07c76/32.png) [@user88](https://forum.ansible.com/u/user88)\
**Post date:** [January 5, 2022, 7:51pm UTC](https://forum.ansible.com/t/run-task-based-on-host-network/36177/1 "2022-01-05T19:51:12Z")

</div>

Hi  
I am trying to run a task based on ansible facts ipv4 of the host  
currently I am able to do so with “when” and regex  
it works when I am trying to match this for example:  
“192.168.[1,2].”  
but I need another subnet in the same regex for example  
“10.10.[8,9.]”  
how can I combine the 2 ?  
either with regex or maybe create a list of subnets that the IP will match  
like :  
subnets:

- 192.168.1.0/24
- 192.168.2.0.24

and so in

thanks
