# ability to gather CIDR ( /24 aswell as 255.255.255.0) from remote server.

**URL:** <https://forum.ansible.com/t/ability-to-gather-cidr-24-aswell-as-255-255-255-0-from-remote-server/16675>\
**Category:** Ansible Developer\
**Created:** [November 3, 2014, 8:40pm UTC](https://forum.ansible.com/t/ability-to-gather-cidr-24-aswell-as-255-255-255-0-from-remote-server/16675 "2014-11-03T20:40:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_Eriksson](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@Stefan\_Eriksson](https://forum.ansible.com/u/Stefan_Eriksson)\
**Post date:** [November 3, 2014, 8:40pm UTC](https://forum.ansible.com/t/ability-to-gather-cidr-24-aswell-as-255-255-255-0-from-remote-server/16675/1 "2014-11-03T20:40:35Z")

</div>

I would like facts to gather CIDR as well as netmask for my IPv4, Its useful for a lot of config files where it doesn’t take 255.255.255.0 but rather only allow /24, like quagga’s ospfd.conf

Sample config:

router ospf

ospf router-id 192.168.0.4  
redistribute kernel route-map only-lo  
redistribute connected route-map only-lo  
network 192.168.0.0/24 area 0.0.0.255

So I want my jinja2 template to have a CIDR variable so I can use:

router ospf  
ospf router-id {{ ansible\_bond0[‘ipv4’][‘address’] }}  
redistribute kernel route-map only-lo  
redistribute connected route-map only-lo  
network {{ ansible\_bond0[‘ipv4’][‘network’] }}{{ ansible\_bond0[‘ipv4’][‘cidr’] }} area 0.0.0.255

What do you think?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 3, 2014, 8:44pm UTC](https://forum.ansible.com/t/ability-to-gather-cidr-24-aswell-as-255-255-255-0-from-remote-server/16675/2 "2014-11-03T20:44:20Z")

</div>

To me, a filter makes much more sense ipv4\_netmask\_to\_cidr as the information is already there, you just want to change the format

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [November 3, 2014, 11:10pm UTC](https://forum.ansible.com/t/ability-to-gather-cidr-24-aswell-as-255-255-255-0-from-remote-server/16675/3 "2014-11-03T23:10:04Z")

</div>

perhaps even just “to\_cidr” as a filter.

python-netaddr can do this pretty easily, I would even be ok with adding python-netaddr as a setup.py requirement (though it would be nice if it safely caught the import and let other functions continue to work if not installed, maybe?)
