From 9d7fe2f0aec7c7879a7f7723fe544a765bf32369 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 28 Dec 2025 21:15:32 +0100 Subject: [PATCH] [PR #11332/280d269d backport][stable-11] fix: listen_ports_facts return no facts when using with podman (#11334) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: listen_ports_facts return no facts when using with podman (#11332) * fix: listen_ports_facts return no facts when using with podman * Update changelogs/fragments/listen-ports-facts-return-no-facts.yml --------- (cherry picked from commit 280d269d789da31534eb93cba186c2342f5871d1) Co-authored-by: Daniel Gonçalves Co-authored-by: Felix Fontein --- changelogs/fragments/listen-ports-facts-return-no-facts.yml | 2 ++ plugins/modules/listen_ports_facts.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/listen-ports-facts-return-no-facts.yml diff --git a/changelogs/fragments/listen-ports-facts-return-no-facts.yml b/changelogs/fragments/listen-ports-facts-return-no-facts.yml new file mode 100644 index 0000000000..57d0f8602c --- /dev/null +++ b/changelogs/fragments/listen-ports-facts-return-no-facts.yml @@ -0,0 +1,2 @@ +bugfixes: + - listen_ports_facts - fix handling of empty PID lists when ``command=ss`` (https://github.com/ansible-collections/community.general/pull/11332). \ No newline at end of file diff --git a/plugins/modules/listen_ports_facts.py b/plugins/modules/listen_ports_facts.py index a33c78be3c..feb7b30788 100644 --- a/plugins/modules/listen_ports_facts.py +++ b/plugins/modules/listen_ports_facts.py @@ -302,10 +302,10 @@ def ss_parse(raw): conns = regex_conns.search(local_addr_port) pids = regex_pid.findall(process) - if conns is None and pids is None: + if conns is None and not pids: continue - if pids is None: + if not pids: # likely unprivileged user, so add empty name & pid # as we do in netstat logic to be consistent with output pids = [(str(), 0)]