# \`ansible.utils.ipaddr\` filter documentation is out-of-date

**URL:** <https://forum.ansible.com/t/ansible-utils-ipaddr-filter-documentation-is-out-of-date/39540>\
**Category:** Project Discussions\
**Tags:** documentation\
**Created:** [January 10, 2025, 5:40am UTC](https://forum.ansible.com/t/ansible-utils-ipaddr-filter-documentation-is-out-of-date/39540 "2025-01-10T05:40:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnu4cn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/gnu4cn/32/7171_2.png) [@gnu4cn](https://forum.ansible.com/u/gnu4cn)\
**Post date:** [January 10, 2025, 5:40am UTC](https://forum.ansible.com/t/ansible-utils-ipaddr-filter-documentation-is-out-of-date/39540/1 "2025-01-10T05:40:33Z")

</div>

I’ve found that the documentation at

[https://docs.ansible.com/ansible/latest/collections/ansible/utils/docsite/filters\_ipaddr.html](https://docs.ansible.com/ansible/latest/collections/ansible/utils/docsite/filters_ipaddr.html)

is out-of-date. My `ansible.utils` collection is at version 5.1.2.

E.g. to get the network address from an IP address, in the doc:

```auto
{{ '192.168.1.1/25' | ansible.utils.ipaddr('net') }}

```

For `ansible.utils` v5.1.2, it does not work. But works as the following:

```auto
{{ '192.168.1.1/25' | ansible.utils.ipaddr('network') }}

```

And to get the network size from an IP address, in the current doc:

```auto
{{ '192.168.1.1/25' | ansible.utils.ipaddr('net') | ansible.utils.ipaddr('size') }}

```

It also does not work in `ansible.utils` v5.1.2，but the following will work:

```auto
{{ '192.168.1.1/25' | ansible.utils.ipaddr('size') }}

```

Hope the documentation be updated ASAP.

---

<div class="post-metadata">

**Author:** ![flowerysong](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flowerysong/32/2305_2.png) [@flowerysong](https://forum.ansible.com/u/flowerysong)\
**Post date:** [January 10, 2025, 6:32am UTC](https://forum.ansible.com/t/ansible-utils-ipaddr-filter-documentation-is-out-of-date/39540/2 "2025-01-10T06:32:56Z")

</div>

This appears to just be you misreading what `ansible.utils.ipaddr('net')` does, not the examples being out of date or incorrect.

* * *

> [@gnu4cn](#):
>
> E.g. to get the network address from an IP address, in the doc:
> 
> ```auto
> {{ '192.168.1.1/25' | ansible.utils.ipaddr('net') }}
> 
> ```

That is not what the documentation says. It says

> [@](#):
>
> You can check which values are specifically network ranges:
> 
> ```auto
> # {{ test_list | ansible.utils.ipaddr('net') }}
> ['192.168.32.0/24', '2001:db8:32c:faad::/64']
> 
> ```

`192.168.1.1/25` is not a network range (it’s a specific IP within the range `192.168.1.0/25`) so it is not returned. This is not the operation you wanted to perform, but it is a valid one and is still supported by the filter so this documentation is not out of date.

Later in the document (when it’s actually talking about how to extract information from a host/prefix value) it has an example of what you’re trying to do:

> [@](#):
>
> ```
> network {{ ipv4_host | ansible.utils.ipaddr('network') }}
> 
> ```

* * *

> [@gnu4cn](#):
>
> And to get the network size from an IP address, in the current doc:
> 
> ```auto
> {{ '192.168.1.1/25' | ansible.utils.ipaddr('net') | ansible.utils.ipaddr('size') }}
> 
> ```

Again, you’ve changed the actual example to something that doesn’t work. Here’s what it says:

> [@](#):
>
> ```auto
> # Example list of values
> test_list: ['192.24.2.1', 'host.fqdn', '::1', '192.168.32.0/24', 'fe80::100/10', True, '', '42540766412265424405338506004571095040/64']
> 
> ```
> 
> […]  
> You can also check how many IP addresses can be in a certain range.
> 
> ```auto
> # {{ test_list | ansible.utils.ipaddr('net') | ansible.utils.ipaddr('size') }}
> 
> ```

This is taking a list of various things and filtering it down to specifically the network ranges and then calculating the size of those ranges. This is, again, a valid and up-to-date example.

---

<div class="post-metadata">

**Author:** ![gnu4cn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/gnu4cn/32/7171_2.png) [@gnu4cn](https://forum.ansible.com/u/gnu4cn)\
**Post date:** [January 10, 2025, 6:41am UTC](https://forum.ansible.com/t/ansible-utils-ipaddr-filter-documentation-is-out-of-date/39540/3 "2025-01-10T06:41:38Z")

</div>

I’ll check this again. Thanks.
