diff --git a/changelogs/fragments/4092-fix_local_ports_regex_listen_ports_facts.yaml b/changelogs/fragments/4092-fix_local_ports_regex_listen_ports_facts.yaml new file mode 100644 index 0000000000..15d6d60fcb --- /dev/null +++ b/changelogs/fragments/4092-fix_local_ports_regex_listen_ports_facts.yaml @@ -0,0 +1,2 @@ +bugfixes: + - listen_ports_facts - local port regex was not handling well IPv6 only binding. Fixes the regex for ``ss`` (https://github.com/ansible-collections/community.general/pull/4092). diff --git a/plugins/modules/system/listen_ports_facts.py b/plugins/modules/system/listen_ports_facts.py index 1c12989d20..40adeb9e16 100644 --- a/plugins/modules/system/listen_ports_facts.py +++ b/plugins/modules/system/listen_ports_facts.py @@ -197,7 +197,7 @@ def netStatParse(raw): def ss_parse(raw): results = list() - regex_conns = re.compile(pattern=r'\[?(.+?)\]?:([0-9]+)') + regex_conns = re.compile(pattern=r'\[?(.+?)\]?:([0-9]+)$') regex_pid = re.compile(pattern=r'"(.*?)",pid=(\d+)') lines = raw.splitlines()