community.windows.win_firewall (2.2.0) — module

Enable or disable the Windows Firewall

Authors: Michael Eaton (@michaeldeaton)

Install collection

Install with ansible-galaxy collection install community.windows:==2.2.0


Add to requirements.yml

  collections:
    - name: community.windows
      version: 2.2.0

Description

Enable or Disable Windows Firewall profiles.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Enable firewall for Domain, Public and Private profiles
  community.windows.win_firewall:
    state: enabled
    profiles:
    - Domain
    - Private
    - Public
  tags: enable_firewall
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Disable Domain firewall
  community.windows.win_firewall:
    state: disabled
    profiles:
    - Domain
  tags: disable_firewall
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Enable firewall for Domain profile and block outbound connections
  community.windows.win_firewall:
    profiles: Domain
    state: enabled
    outbound_action: block
  tags: block_connection

Inputs

    
state:
    choices:
    - disabled
    - enabled
    description:
    - Set state of firewall for given profile.
    type: str

profiles:
    choices:
    - Domain
    - Private
    - Public
    default:
    - Domain
    - Private
    - Public
    description:
    - Specify one or more profiles to change.
    elements: str
    type: list

inbound_action:
    choices:
    - allow
    - block
    - not_configured
    description:
    - Set to C(allow) or C(block) inbound network traffic in the profile.
    - C(not_configured) is valid when configuring a GPO.
    type: str
    version_added: 1.1.0
    version_added_collection: community.windows

outbound_action:
    choices:
    - allow
    - block
    - not_configured
    description:
    - Set to C(allow) or C(block) inbound network traffic in the profile.
    - C(not_configured) is valid when configuring a GPO.
    type: str
    version_added: 1.1.0
    version_added_collection: community.windows

Outputs

enabled:
  description: Current firewall status for chosen profile (after any potential change).
  returned: always
  sample: true
  type: bool
profiles:
  description: Chosen profile.
  returned: always
  sample: Domain
  type: str
state:
  description: Desired state of the given firewall profile(s).
  returned: always
  sample: enabled
  type: list

See also