1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add basic examples of ipaddr filter use

This commit is contained in:
Maciej Delmanowski 2015-02-21 13:34:22 +01:00
parent 71dae62b2a
commit 25ef581a90

View file

@ -27,7 +27,15 @@ Basic tests
``ipaddr()`` is designed to return the input value if a query is True, and
``False`` if query is False. This way it can be very easily used in chained
filters. Here are some example tests of various input strings::
filters. To use the filter, pass a string to it::
{{ '192.0.2.0' | ipaddr }}
You can also pass the values as variables::
{{ myvar | ipaddr }}
Here are some example tests of various input strings::
# These values are valid IP addresses or network ranges
'192.168.0.1' -> 192.168.0.1
@ -46,8 +54,17 @@ filters. Here are some example tests of various input strings::
'fe80:/10' -> False
Sometimes you need either IPv4 or IPv6 addresses. To filter only for particular
type, ``ipaddr()`` filter has two "aliases", ``ipv4()`` and ``ipv6()``. Here's
an example test to look for IPv4 addresses::
type, ``ipaddr()`` filter has two "aliases", ``ipv4()`` and ``ipv6()``.
Example us of an IPv4 filter::
{{ myvar | ipv4 }}
And similar example of an IPv6 filter::
{{ myvar | ipv6 }}
Here's an example test to look for IPv4 addresses::
'192.168.0.1' -> 192.168.0.1
'192.168.32.0/24' -> 192.168.32.0/24