ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
827 stars 1.53k forks source link

listen_ports_facts extension #4762

Open PKehnel opened 2 years ago

PKehnel commented 2 years ago

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

ansibullbot commented 2 years ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 2 years ago

cc @russoz click here for bot help

ansibullbot commented 2 years ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 2 years ago

cc @ndavison click here for bot help

PKehnel commented 2 years ago

Hey together, any option for me to get some feedback on the idea?

felixfontein commented 2 years ago

@PKehnel this module seems not to be actively maintained, so there won't be much feedback unless someone interested in this module takes a look at this.

CC @moonrail and @gaetan-craft who recently worked on this module, and thus might be interested in this.

gaetan-craft commented 2 years ago

The code is already done for ss, it's just adding them to the return, job has to be done for netstat. I unfortunately have no time to work on it right now

ansibullbot commented 2 years ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help