summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Israelsson <dennis.israelsson@gmail.com>2020-02-05 23:29:59 +0100
committerGitHub <noreply@github.com>2020-02-05 23:29:59 +0100
commit68b981ae21f85e96d951aefac6acd1b0d169cefe (patch)
tree627641d6abe2a6871c02fc32d8a1a3b525681eca
parentNuke all removed_module stubs (#67139) (diff)
downloadansible-68b981ae21f85e96d951aefac6acd1b0d169cefe.tar.xz
ansible-68b981ae21f85e96d951aefac6acd1b0d169cefe.zip
update nmap inventory plugin to not depend on rdns (#56457)
-rw-r--r--lib/ansible/plugins/inventory/nmap.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/ansible/plugins/inventory/nmap.py b/lib/ansible/plugins/inventory/nmap.py
index d2c54fe84e..002c0aef43 100644
--- a/lib/ansible/plugins/inventory/nmap.py
+++ b/lib/ansible/plugins/inventory/nmap.py
@@ -65,7 +65,7 @@ from ansible.module_utils.common.process import get_bin_path
class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
NAME = 'nmap'
- find_host = re.compile(r'^Nmap scan report for ([\w,.,-]+) \(([\w,.,:,\[,\]]+)\)')
+ find_host = re.compile(r'^Nmap scan report for ([\w,.,-]+)(?: \(([\w,.,:,\[,\]]+)\))?')
find_port = re.compile(r'^(\d+)/(\w+)\s+(\w+)\s+(\w+)')
def __init__(self):
@@ -140,7 +140,11 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
else:
host = hits.group(1)
- ip = hits.group(2)
+ # if no reverse dns exists, just use ip instead as hostname
+ if hits.group(2) is not None:
+ ip = hits.group(2)
+ else:
+ ip = hits.group(1)
if host is not None:
# update inventory