mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-03 04:34:24 -07:00
Add basic examples of ipaddr filter use
This commit is contained in:
parent
71dae62b2a
commit
25ef581a90
1 changed files with 20 additions and 3 deletions
|
@ -27,7 +27,15 @@ Basic tests
|
||||||
|
|
||||||
``ipaddr()`` is designed to return the input value if a query is True, and
|
``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
|
``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
|
# These values are valid IP addresses or network ranges
|
||||||
'192.168.0.1' -> 192.168.0.1
|
'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
|
'fe80:/10' -> False
|
||||||
|
|
||||||
Sometimes you need either IPv4 or IPv6 addresses. To filter only for particular
|
Sometimes you need either IPv4 or IPv6 addresses. To filter only for particular
|
||||||
type, ``ipaddr()`` filter has two "aliases", ``ipv4()`` and ``ipv6()``. Here's
|
type, ``ipaddr()`` filter has two "aliases", ``ipv4()`` and ``ipv6()``.
|
||||||
an example test to look for IPv4 addresses::
|
|
||||||
|
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.0.1' -> 192.168.0.1
|
||||||
'192.168.32.0/24' -> 192.168.32.0/24
|
'192.168.32.0/24' -> 192.168.32.0/24
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue