From 6a7811f6963ad1f5f92342b786e70a809e1c9e08 Mon Sep 17 00:00:00 2001 From: gaetan-craft <97035736+gaetan-craft@users.noreply.github.com> Date: Mon, 31 Jan 2022 19:33:11 +0100 Subject: [PATCH] Fix local port regex in listen_ports_facts (#4092) * Fix local port regex Thsi PR fix the bug reported in #4091 * Update changelogs/fragments/4092-fix_local_ports_regex_listen_ports_facts.yaml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .../4092-fix_local_ports_regex_listen_ports_facts.yaml | 2 ++ plugins/modules/system/listen_ports_facts.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/4092-fix_local_ports_regex_listen_ports_facts.yaml 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()