diff --git a/docs/docsite/rst/user_guide/playbooks_filters_ipaddr.rst b/docs/docsite/rst/user_guide/playbooks_filters_ipaddr.rst index 1560fcc556a..95950023128 100644 --- a/docs/docsite/rst/user_guide/playbooks_filters_ipaddr.rst +++ b/docs/docsite/rst/user_guide/playbooks_filters_ipaddr.rst @@ -405,6 +405,34 @@ be automatically converted to a router address (with a ``::1/48`` host address): .. _6to4: https://en.wikipedia.org/wiki/6to4 +Finding IP addresses within a range +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To find usable IP addresses within an IP range, try these ``ipaddr`` filters: + +To find the next usable IP address in a range, use ``next_usable`` :: + + # {{ '192.168.122.1/24' | ipaddr('next_usable') }} + 192.168.122.2 + +To find the last usable IP address from a range, use ``last_usable``:: + + # {{ '192.168.122.1/24' | ipaddr('last_usable') }} + 192.168.122.254 + +To find the available range of IP addresses from the given network address, use ``range_usable``:: + + # {{ '192.168.122.1/24' | ipaddr('range_usable') }} + 192.168.122.1-192.168.122.254 + +To find the next nth usable IP address within a range, use ``next_nth_usable``:: + + # {{ '192.168.122.1/24' | next_nth_usable(2) }} + 192.168.122.3 + +In this example, ``next_nth_usable`` returns the second usable IP address for the given IP range. + + IP Math ^^^^^^^