mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[PR #7323/53978b74 backport][stable-7] nmap: fix get_option calls (#7329)
nmap: fix get_option calls (#7323)
Fix get_option calls.
(cherry picked from commit 53978b7440
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
14a86ed0ad
commit
7fa84e8ec7
2 changed files with 17 additions and 15 deletions
2
changelogs/fragments/7323-nmap.yml
Normal file
2
changelogs/fragments/7323-nmap.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- "nmap inventory plugin - fix ``get_option`` calls (https://github.com/ansible-collections/community.general/pull/7323)."
|
|
@ -201,43 +201,43 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||||
# setup command
|
# setup command
|
||||||
cmd = [self._nmap]
|
cmd = [self._nmap]
|
||||||
|
|
||||||
if self.get_option['sudo']:
|
if self.get_option('sudo'):
|
||||||
cmd.insert(0, 'sudo')
|
cmd.insert(0, 'sudo')
|
||||||
|
|
||||||
if self.get_option['port']:
|
if self.get_option('port'):
|
||||||
cmd.append('-p')
|
cmd.append('-p')
|
||||||
cmd.append(self.get_option['port'])
|
cmd.append(self.get_option('port'))
|
||||||
|
|
||||||
if not self.get_option['ports']:
|
if not self.get_option('ports'):
|
||||||
cmd.append('-sP')
|
cmd.append('-sP')
|
||||||
|
|
||||||
if self.get_option['ipv4'] and not self.get_option['ipv6']:
|
if self.get_option('ipv4') and not self.get_option('ipv6'):
|
||||||
cmd.append('-4')
|
cmd.append('-4')
|
||||||
elif self.get_option['ipv6'] and not self.get_option['ipv4']:
|
elif self.get_option('ipv6') and not self.get_option('ipv4'):
|
||||||
cmd.append('-6')
|
cmd.append('-6')
|
||||||
elif not self.get_option['ipv6'] and not self.get_option['ipv4']:
|
elif not self.get_option('ipv6') and not self.get_option('ipv4'):
|
||||||
raise AnsibleParserError('One of ipv4 or ipv6 must be enabled for this plugin')
|
raise AnsibleParserError('One of ipv4 or ipv6 must be enabled for this plugin')
|
||||||
|
|
||||||
if self.get_option['exclude']:
|
if self.get_option('exclude'):
|
||||||
cmd.append('--exclude')
|
cmd.append('--exclude')
|
||||||
cmd.append(','.join(self.get_option['exclude']))
|
cmd.append(','.join(self.get_option('exclude')))
|
||||||
|
|
||||||
if self.get_option['dns_resolve']:
|
if self.get_option('dns_resolve'):
|
||||||
cmd.append('-n')
|
cmd.append('-n')
|
||||||
|
|
||||||
if self.get_option['udp_scan']:
|
if self.get_option('udp_scan'):
|
||||||
cmd.append('-sU')
|
cmd.append('-sU')
|
||||||
|
|
||||||
if self.get_option['icmp_timestamp']:
|
if self.get_option('icmp_timestamp'):
|
||||||
cmd.append('-PP')
|
cmd.append('-PP')
|
||||||
|
|
||||||
if self.get_option['open']:
|
if self.get_option('open'):
|
||||||
cmd.append('--open')
|
cmd.append('--open')
|
||||||
|
|
||||||
if not self.get_option['use_arp_ping']:
|
if not self.get_option('use_arp_ping'):
|
||||||
cmd.append('--disable-arp-ping')
|
cmd.append('--disable-arp-ping')
|
||||||
|
|
||||||
cmd.append(self.get_option['address'])
|
cmd.append(self.get_option('address'))
|
||||||
try:
|
try:
|
||||||
# execute
|
# execute
|
||||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
|
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
|
||||||
|
|
Loading…
Reference in a new issue