NMAP Inventory Plugin: Added option for specifying DNS servers for name resolution (#9849)

* Added option for specifying DNS servers for name resolution in NMAP inventory plugin.

* Added option for specifying DNS servers for name resolution in NMAP inventory plugin.

* NMAP Inventory Plugin: Added option for specifying DNS servers for name resolution.

* Update plugins/inventory/nmap.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* NMAP Inventory Plugin: Added option for specifying DNS servers for name resolution.

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Jim Anderson 2025-03-14 23:37:31 -07:00 committed by GitHub
parent dd0a2cbff9
commit add892aa45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
minor_changes:
- nmap inventory plugin - adds ``dns_servers`` option for specifying DNS servers for name resolution. Accepts hostnames or IP addresses in the same format as the ``exclude`` option (https://github.com/ansible-collections/community.general/pull/9849).

View file

@ -86,6 +86,11 @@ DOCUMENTATION = '''
type: boolean type: boolean
default: false default: false
version_added: 6.1.0 version_added: 6.1.0
dns_servers:
description: Specify which DNS servers to use for name resolution.
type: list
elements: string
version_added: 10.5.0
use_arp_ping: use_arp_ping:
description: Whether to always (V(true)) use the quick ARP ping or (V(false)) a slower but more reliable method. description: Whether to always (V(true)) use the quick ARP ping or (V(false)) a slower but more reliable method.
type: boolean type: boolean
@ -231,6 +236,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
if self.get_option('dns_resolve'): if self.get_option('dns_resolve'):
cmd.append('-n') cmd.append('-n')
if self.get_option('dns_servers'):
cmd.append('--dns-servers')
cmd.append(','.join(self.get_option('dns_servers')))
if self.get_option('udp_scan'): if self.get_option('udp_scan'):
cmd.append('-sU') cmd.append('-sU')