ansible.windows.win_firewall_rule_info module – Gather information about Windows firewall rules

Note

This module is part of the ansible.windows collection (version 3.9.1).

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

Synopsis

  • Gathers detailed information about existing Windows firewall rules.

  • Allows filtering rules by display name or group name.

Parameters

Parameter

Comments

group

string

The group name to filter rules by.

If omitted, rules will not be filtered by group.

name

string

The rule’s display name to filter by.

If omitted, rules will not be filtered by name.

See Also

See also

ansible.windows.win_firewall_rule

Windows firewall automation.

Examples

- name: Get information about a specific firewall rule
  ansible.windows.win_firewall_rule_info:
    name: http
  register: http_rule_info

- name: Get information about all firewall rules in a specific group
  ansible.windows.win_firewall_rule_info:
    group: application
  register: app_group_rules

- name: Get information about all firewall rules on the target host
  ansible.windows.win_firewall_rule_info:
  register: all_firewall_rules

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

rules

list / elements=dictionary

List of firewall rules matching the specified criteria.

Returned: always

action

integer

The action for the firewall rule (0 = block, 1 = allow).

Returned: always

Sample: 1

application_name

string

Path to the executable/application associated with the rule, or null if applies to any.

Returned: always

Sample: "%SystemRoot%\\system32\\svchost.exe"

description

string

Description of the firewall rule.

Returned: always

Sample: "Allows inbound HTTP traffic"

direction

integer

Traffic direction (1 = in, 2 = out).

Returned: always

Sample: 1

enabled

boolean

Whether the firewall rule is enabled.

Returned: always

Sample: true

group

string

Group name the firewall rule belongs to.

Returned: always

Sample: "application"

local_addresses

string

Local IP addresses or ranges.

Returned: always

Sample: "*"

local_ports

string

Local port numbers or ranges.

Returned: always

Sample: "80"

name

string

Display name of the firewall rule.

Returned: always

Sample: "http"

profiles

integer

Bitmask representing active profiles (1 = Domain, 2 = Private, 4 = Public).

Returned: always

Sample: 2147483647

protocol

integer

Protocol number associated with the rule (e.g. 6 for TCP, 17 for UDP).

Returned: always

Sample: 6

remote_addresses

string

Remote IP addresses or ranges.

Returned: always

Sample: "*"

remote_ports

string

Remote port numbers or ranges.

Returned: always

Sample: "*"

service_name

string

Service short name associated with the rule.

Returned: always

Authors

  • Timothy Vandenbrande (@TimothyVandenbrande)