* nmap.py: Add sudo nmap
* Update plugins/inventory/nmap.py
Change description of new plugin option adding version_added
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/inventory/nmap.py
Change boolean values of sudo option in example
Co-authored-by: Felix Fontein <felix@fontein.de>
* Create 4506-sudo-in-nmap-inv-plugin.yaml
* Fix typo in yaml format
* Update changelogs/fragments/4506-sudo-in-nmap-inv-plugin.yaml
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
* Update changelogs/fragments/4506-sudo-in-nmap-inv-plugin.yaml
Co-authored-by: Felix Fontein <felix@fontein.de>
* Document default as false.
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
(cherry picked from commit 3cce1217db
)
Co-authored-by: ottobits <vindemaio@gmail.com>
pull/4547/head
parent
12f2ba251b
commit
3876df9052
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- nmap inventory plugin - add ``sudo`` option in plugin in order to execute ``sudo nmap`` so that ``nmap`` runs with elevated privileges (https://github.com/ansible-collections/community.general/pull/4506).
|
|
@ -21,6 +21,11 @@ DOCUMENTATION = '''
|
||||||
description: token that ensures this is a source file for the 'nmap' plugin.
|
description: token that ensures this is a source file for the 'nmap' plugin.
|
||||||
required: True
|
required: True
|
||||||
choices: ['nmap', 'community.general.nmap']
|
choices: ['nmap', 'community.general.nmap']
|
||||||
|
sudo:
|
||||||
|
description: Set to C(true) to execute a C(sudo nmap) plugin scan.
|
||||||
|
version_added: 4.8.0
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
address:
|
address:
|
||||||
description: Network IP or range of IPs to scan, you can use a simple range (10.2.2.15-25) or CIDR notation.
|
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
|
required: True
|
||||||
|
@ -49,6 +54,13 @@ EXAMPLES = '''
|
||||||
plugin: community.general.nmap
|
plugin: community.general.nmap
|
||||||
strict: False
|
strict: False
|
||||||
address: 192.168.0.0/24
|
address: 192.168.0.0/24
|
||||||
|
|
||||||
|
|
||||||
|
# a sudo nmap scan to fully use nmap scan power.
|
||||||
|
plugin: community.general.nmap
|
||||||
|
sudo: true
|
||||||
|
strict: False
|
||||||
|
address: 192.168.0.0/24
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -135,6 +147,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||||
if not user_cache_setting or cache_needs_update:
|
if not user_cache_setting or cache_needs_update:
|
||||||
# setup command
|
# setup command
|
||||||
cmd = [self._nmap]
|
cmd = [self._nmap]
|
||||||
|
|
||||||
|
if self._options['sudo']:
|
||||||
|
cmd.insert(0, 'sudo')
|
||||||
|
|
||||||
if not self._options['ports']:
|
if not self._options['ports']:
|
||||||
cmd.append('-sP')
|
cmd.append('-sP')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue