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 5d0f7a33d3..6c923e99bf 100644 --- a/plugins/modules/listen_ports_facts.py +++ b/plugins/modules/listen_ports_facts.py @@ -305,10 +305,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 = [("", 0)]