diff --git a/changelogs/fragments/324.yaml b/changelogs/fragments/324.yaml new file mode 100644 index 0000000..dd3f9c1 --- /dev/null +++ b/changelogs/fragments/324.yaml @@ -0,0 +1,3 @@ +--- +doc_changes: + - Add a wildcard mask/hostmask documentation to ipaddr filter doc page to obtain an IP address's wildcard mask/hostmask. diff --git a/docs/ansible.utils.ipaddr_filter.rst b/docs/ansible.utils.ipaddr_filter.rst index 006f078..169caf6 100644 --- a/docs/ansible.utils.ipaddr_filter.rst +++ b/docs/ansible.utils.ipaddr_filter.rst @@ -19,6 +19,7 @@ Synopsis -------- - This filter is designed to return the input value if a query is True, and False if a query is False - This way it can be easily used in chained filters +- For more details on how to use this plugin, please refer to ``_ diff --git a/docs/docsite/rst/filters_ipaddr.rst b/docs/docsite/rst/filters_ipaddr.rst index 79ede7a..07a1f0d 100644 --- a/docs/docsite/rst/filters_ipaddr.rst +++ b/docs/docsite/rst/filters_ipaddr.rst @@ -340,6 +340,15 @@ If needed, you can extract subnet and prefix information from the 'host/prefix' # {{ host_prefix | ansible.utils.ipaddr('host/prefix') | ansible.utils.ipaddr('prefix') }} [64, 24] +To get the wildcard mask from host_prefix + +.. code-block:: jinja + + wildcard {{ host_prefix | ansible.utils.ipaddr('hostmask')}} + + # from host_prefix '192.0.2.0/24' following will be generated + wildcard 0.0.0.255 + Converting subnet masks to CIDR notation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/plugins/filter/ipaddr.py b/plugins/filter/ipaddr.py index 33f496a..29dc189 100644 --- a/plugins/filter/ipaddr.py +++ b/plugins/filter/ipaddr.py @@ -51,6 +51,7 @@ DOCUMENTATION = """ description: - This filter is designed to return the input value if a query is True, and False if a query is False - This way it can be easily used in chained filters + - For more details on how to use this plugin, please refer to ``_ options: value: description: