win_firewall_rule - Windows firewall automation

New in version 2.0.

Synopsis

  • Allows you to create/remove/update firewall rules.

Options

parameter required default choices comments
action
yes
  • allow
  • block
  • bypass
What to do with the items this rule is for.
description
no
Description for the firewall rule.
direction
yes
  • in
  • out
Is this rule for inbound or outbound traffic.
enabled
no yes
  • yes
  • no
Is this firewall rule enabled or disabled.
aliases: enable
localip
no any
The local ip address this rule applies to.
localport
no
The local port this rule applies to.
name
yes
The rules name
profiles
no domain,private,public
The profile this rule applies to.
aliases: profile
program
no
The program this rule applies to.
protocol
no any
The protocol this rule applies to.
remoteip
no any
The remote ip address/range this rule applies to.
remoteport
no
The remote port this rule applies to.
service
no
The service this rule applies to.
state
no present
  • present
  • absent
Should this rule be added or removed.

Examples

- name: Firewall rule to allow SMTP on TCP port 25
  win_firewall_rule:
    name: SMTP
    localport: 25
    action: allow
    direction: in
    protocol: tcp
    state: present
    enabled: yes

- name: Firewall rule to allow RDP on TCP port 3389
  win_firewall_rule:
    name: Remote Desktop
    localport: 3389
    action: allow
    direction: in
    protocol: tcp
    profiles: private
    state: present
    enabled: yes

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/win_firewall_rule_module.html