summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2019-02-28 17:51:15 +0100
committerGitHub <noreply@github.com>2019-02-28 17:51:15 +0100
commit55dc63be3a76b31c227582c9a403133a1be492e5 (patch)
tree5d922ee5b24b30c64679b95a60a62555a1968bfa
parentadding quiet option to assert (ansible#27124) (#52032) (diff)
downloadansible-55dc63be3a76b31c227582c9a403133a1be492e5.tar.xz
ansible-55dc63be3a76b31c227582c9a403133a1be492e5.zip
properly convert inputs to handle bytes/unicode (#53072)
* properly convert inputs to handle bytes/unicode fixes #52186 * Update changelogs/fragments/nmap_bytes_fix.yml Co-Authored-By: bcoca <bcoca@users.noreply.github.com>
-rw-r--r--changelogs/fragments/nmap_bytes_fix.yml2
-rw-r--r--lib/ansible/plugins/inventory/nmap.py3
2 files changed, 4 insertions, 1 deletions
diff --git a/changelogs/fragments/nmap_bytes_fix.yml b/changelogs/fragments/nmap_bytes_fix.yml
new file mode 100644
index 0000000000..309fc1cb15
--- /dev/null
+++ b/changelogs/fragments/nmap_bytes_fix.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - convert input into text to ensure valid comparisons in nmap inventory plugin
diff --git a/lib/ansible/plugins/inventory/nmap.py b/lib/ansible/plugins/inventory/nmap.py
index f9e709ee64..72f2a140b4 100644
--- a/lib/ansible/plugins/inventory/nmap.py
+++ b/lib/ansible/plugins/inventory/nmap.py
@@ -57,7 +57,7 @@ from subprocess import Popen, PIPE
from ansible import constants as C
from ansible.errors import AnsibleParserError
-from ansible.module_utils._text import to_native
+from ansible.module_utils._text import to_native, to_text
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
@@ -127,6 +127,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
ip = None
ports = []
for line in stdout.splitlines():
+ line = to_text(line)
hits = self.find_host.match(line)
if hits:
if host is not None: