diff --git a/changelogs/fragments/nmap_bytes_fix.yml b/changelogs/fragments/nmap_bytes_fix.yml new file mode 100644 index 00000000000..309fc1cb153 --- /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 f9e709ee644..72f2a140b47 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: