community.general icon indicating copy to clipboard operation
community.general copied to clipboard

listen_ports_facts extension

Open PKehnel opened this issue 2 years ago • 7 comments

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

  • [X] I agree to follow the Ansible Code of Conduct

PKehnel avatar Jun 02 '22 10:06 PKehnel

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 avatar Jun 02 '22 10:06 ansibullbot

cc @russoz click here for bot help

ansibullbot avatar Jun 02 '22 10:06 ansibullbot

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 avatar Jun 03 '22 07:06 ansibullbot

cc @ndavison click here for bot help

ansibullbot avatar Jun 03 '22 07:06 ansibullbot

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

PKehnel avatar Jun 20 '22 09:06 PKehnel

@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.

felixfontein avatar Jun 20 '22 11:06 felixfontein

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

gaetan-craft avatar Jul 04 '22 09:07 gaetan-craft

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 avatar Nov 09 '22 10:11 ansibullbot