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

I’ve found that the documentation at

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:

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

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

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

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

{{ '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:

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

Hope the documentation be updated ASAP.

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


That is not what the documentation says. It says

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:


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

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.

I’ll check this again. Thanks.