This way it can be easily used in chained filters. Ipaddr() is designed to return the input value if a query is True, and False if a query is False. Converts the address to IPv4 if it is an IPv4-mapped IPv6 address (RFC 4291 Section 2.5.5.2), otherwise returns the address as-is.
Converting IPv4 address to a 6to4 address.Getting information about the network in CIDR notation.Converting subnet masks to CIDR notation.Getting information from host/prefix values.Getting information about hosts and networks.It can usually be installed with either your system package manager or using pip: pip install netaddr
To use this filter in Ansible, you need to install the netaddr Python library on a computer on which you use Ansible (it is not required on remote hosts). There are also additional functions available to manipulate IP subnets and MAC addresses. The IPAddress class is used to identify individual IP addresses. This library fully supports both IPv4 and the new IPv6 standards. ipaddr() works with both IPv4 and IPv6 addresses in various forms. An IP address is a virtual address used to identify the source and destination of (layer 3) packets being transferred between hosts in a switched network. Here’s the conversion process step by step: take the mac address: for example 52:74:f2:b1:a8:7f. It can operate on strings or lists of items, test various data to check if they are valid IP addresses, and manipulate the input data to extract requested information. A mac address is 48 bits, an IPv6 address is 128 bits. Ipaddr() is a Jinja2 filter designed to provide an interface to the netaddr Python package from within Ansible.