Skip to content

listen_ports_facts extension #4762

@PKehnel

Description

@PKehnel

Summary

Hey we are currently using the modul listen_ports_facts:

- name: Gather facts on listening ports
  listen_ports_facts:

- name: List TCP ports
  debug:
    msg: "{{ ansible_facts.tcp_listen  }}"

Which gives us for tcp following output:

[{
    "address": "::",
    "name": "sshd",
    "pid": 937,
    "port": 22,
    "protocol": "tcp",
    "stime": "Thu Jun  2 09:49:16 2022",
    "user": "root"
}, ...]

It would be cool to include more infos from netstat or ss.
Mainly state, local_address and foreign_address something like:

 [{
  "local_address": "0.0.0.0",   <----
  "foreign_address": "0.0.0.0" <----
  "pid": "1152",
  "port": "52583",
  "state": "Bound", <----
  "protocol": "tcp",
  "stime": "Thu Jun  2 09:49:16 2022",
  "user": "root"
  "process": "AzureADConnectAuthenticationAgentService", <----
  "service": "AzureADConnectAuthenticationAgent", <----
 }, ...]

Finally finding process and service would also be a nice bonus (not in the netstat scope).

Hope this is understandable.
Greetings

Issue Type

Feature Idea

Component Name

plugins/modules/system/listen_ports_facts.py

Additional Information

No response

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureThis issue/PR relates to a feature requesthas_prmodulemodulepluginsplugin (any type)system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions