From 8db7fcf45c7ab65e8ed9208fd0cc33e89f2f5004 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Wed, 5 Dec 2018 22:44:13 +0530 Subject: [PATCH] ipaddr: Add missing documenation about network/prefix filter (#49532) * ipaddr: Add missing documenation about network/prefix Fixes: #17871 Signed-off-by: Abhijeet Kasurde --- .../rst/user_guide/playbooks_filters_ipaddr.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/docsite/rst/user_guide/playbooks_filters_ipaddr.rst b/docs/docsite/rst/user_guide/playbooks_filters_ipaddr.rst index d809c2dfefd..d9d0ea30b7c 100644 --- a/docs/docsite/rst/user_guide/playbooks_filters_ipaddr.rst +++ b/docs/docsite/rst/user_guide/playbooks_filters_ipaddr.rst @@ -324,6 +324,21 @@ This result can be converted to canonical form with ``ipaddr()`` to produce a su # {{ net_mask | ipaddr('net') }} '192.168.0.0/24' +Getting information about the network in CIDR notation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Given an IP address, the ``ipaddr()`` filter can produce the network address in CIDR notation. +This can be useful when you want to obtain the network address from the IP address in CIDR format. + +Here's an example of IP address:: + + ip_address = "{{ ansible_default_ipv4.address }}/{{ ansible_default_ipv4.netmask }}" + '192.168.0.11/255.255.255.0' + +This can be used to obtain the network address in CIDR notation format:: + + # {{ ip_address | ipaddr('network/prefix') }} + '192.168.0.0/24' IP address conversion ^^^^^^^^^^^^^^^^^^^^^