ansible.windows.win_listen_ports_facts module – Recopilates the facts of the listening ports of the machine
Note
This module is part of the ansible.windows collection (version 3.6.1).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install ansible.windows.
To use it in a playbook, specify: ansible.windows.win_listen_ports_facts.
New in ansible.windows 2.7.0
Synopsis
Recopilates the information of the TCP and UDP ports of the machine and the related processes.
State of the TCP ports could be filtered, as well as the format of the date when the parent process was launched.
The module’s goal is to replicate the functionality of the linux module listen_ports_facts, mantaining the format of the said module.
Parameters
Parameter |
Comments |
|---|---|
The format of the date when the process that owns the port started. The date specification is UFormat Default: |
|
Filter for the state of the TCP ports that will be recopilated. Supports multiple states (Bound, Closed, CloseWait, Closing, DeleteTCB, Established, FinWait1, FinWait2, LastAck, Listen, SynReceived, SynSent and TimeWait), that can be used alone or combined. Note that the Bound state is only available on PowerShell version 4.0 or later. Default: |
Notes
Note
The generated data (tcp_listen and udp_listen) and the fields within follows the listen_ports_facts schema to achieve compatibility with the said module output, even though this module if capable of extracting ports with a state other than Listen
Examples
- name: Recopilate ports facts
ansible.windows.win_listen_ports_facts:
- name: Retrieve only ports with Closing and Established states
ansible.windows.win_listen_ports_facts:
tcp_filter:
- Closing
- Established
- name: Get ports facts with only the year within the date field
ansible.windows.win_listen_ports_facts:
date_uformat: '%Y'
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
List of dicts with the detected TCP ports Returned: success Sample: |
|
List of dicts with the detected UDP ports Returned: success Sample: |