From 0eb33c283929f299bd7acef730a77552515a966e Mon Sep 17 00:00:00 2001 From: efrikin Date: Sat, 22 Apr 2023 23:56:13 +0300 Subject: [PATCH] Add support env variables for nmap inventory plugin (#6352) * Add support env variables for nmap inventory plugin * Add changelogs/fragments file * Rename support-env-variables-to-nmap-dynamic-inventoiry to 6351-support-env-variables-to-nmap-dynamic-inventoiry * Add extension for changelog file * Fix https://github.com/ansible-collections/community.general/pull/6352#discussion_r1167973326 Co-authored-by: Felix Fontein * Fix https://github.com/ansible-collections/community.general/pull/6352#discussion_r1167973295 Co-authored-by: Felix Fontein * Fix https://github.com/ansible-collections/community.general/pull/6352#discussion_r1167973265 Co-authored-by: Felix Fontein * Fix https://github.com/ansible-collections/community.general/pull/6352#discussion_r1167973193 * Fix linter * Fix https://github.com/ansible-collections/community.general/pull/6352#discussion_r1168014445 * Fix changelog fragment. --------- Co-authored-by: Felix Fontein --- ...pport-env-variables-to-nmap-dynamic-inventoiry.yaml | 2 ++ plugins/inventory/nmap.py | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/6351-support-env-variables-to-nmap-dynamic-inventoiry.yaml diff --git a/changelogs/fragments/6351-support-env-variables-to-nmap-dynamic-inventoiry.yaml b/changelogs/fragments/6351-support-env-variables-to-nmap-dynamic-inventoiry.yaml new file mode 100644 index 0000000000..043f725387 --- /dev/null +++ b/changelogs/fragments/6351-support-env-variables-to-nmap-dynamic-inventoiry.yaml @@ -0,0 +1,2 @@ +minor_changes: + - nmap inventory plugin - added environment variables for configure ``address`` and ``exclude`` (https://github.com/ansible-collections/community.general/issues/6351). diff --git a/plugins/inventory/nmap.py b/plugins/inventory/nmap.py index 621f047577..a03cf3e6fa 100644 --- a/plugins/inventory/nmap.py +++ b/plugins/inventory/nmap.py @@ -30,10 +30,18 @@ DOCUMENTATION = ''' address: description: Network IP or range of IPs to scan, you can use a simple range (10.2.2.15-25) or CIDR notation. required: true + env: + - name: ANSIBLE_NMAP_ADDRESS + version_added: 6.6.0 exclude: - description: list of addresses to exclude + description: + - List of addresses to exclude. + - For example C(10.2.2.15-25) or C(10.2.2.15,10.2.2.16). type: list elements: string + env: + - name: ANSIBLE_NMAP_EXCLUDE + version_added: 6.6.0 port: description: - Only scan specific port or port range (C(-p)).