From 6425ea2299ce3e566f82bb66defa50761854d3fd Mon Sep 17 00:00:00 2001 From: Giorgi Zeikidze Date: Fri, 19 Jul 2024 17:43:24 +0300 Subject: [PATCH] add wildcard mask/hostmask to ipaddr filter doc page (#324) * add wildcard mask/hostmask to ipaddr filter doc page This might seem like an unnecessary addition but wildcard filter not being here has cost me couple of hours and a failed exam. I tried to follow convention as much as I could * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add changelog and add a note in readme * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add a note in readme check * update readme * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * correct the link * correct the link * correct the link * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update changelogs/fragments/324.yaml Co-authored-by: Sagar Paul --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sagar Paul Co-authored-by: Ruchi Pakhle <72685035+Ruchip16@users.noreply.github.com> Co-authored-by: Nilashish Chakraborty Co-authored-by: Ruchi Pakhle --- changelogs/fragments/324.yaml | 3 +++ docs/ansible.utils.ipaddr_filter.rst | 1 + docs/docsite/rst/filters_ipaddr.rst | 9 +++++++++ plugins/filter/ipaddr.py | 1 + 4 files changed, 14 insertions(+) create mode 100644 changelogs/fragments/324.yaml 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: