2018-03-21 16:41:01 +00:00
|
|
|
#!/usr/bin/python
|
2018-02-25 02:09:54 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# Copyright: (c) 2014, Timothy Vandenbrande <timothy.vandenbrande@gmail.com>
|
|
|
|
# Copyright: (c) 2017, Artem Zinenko <zinenkoartem@gmail.com>
|
2017-08-29 20:18:03 +00:00
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
2015-03-16 10:34:07 +00:00
|
|
|
|
2017-08-16 03:16:38 +00:00
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
2017-03-14 16:07:22 +00:00
|
|
|
'status': ['preview'],
|
|
|
|
'supported_by': 'community'}
|
|
|
|
|
2017-01-19 01:57:33 +00:00
|
|
|
DOCUMENTATION = r'''
|
2015-03-16 10:34:07 +00:00
|
|
|
---
|
2015-10-06 09:47:27 +00:00
|
|
|
module: win_firewall_rule
|
2015-07-02 08:00:33 +00:00
|
|
|
version_added: "2.0"
|
2015-03-16 10:34:07 +00:00
|
|
|
short_description: Windows firewall automation
|
|
|
|
description:
|
2017-08-29 20:18:03 +00:00
|
|
|
- Allows you to create/remove/update firewall rules.
|
2015-10-06 13:03:27 +00:00
|
|
|
options:
|
2017-08-29 20:18:03 +00:00
|
|
|
enabled:
|
|
|
|
description:
|
2019-01-03 16:50:44 +00:00
|
|
|
- Whether this firewall rule is enabled or disabled.
|
2017-08-29 20:18:03 +00:00
|
|
|
type: bool
|
2019-01-03 16:50:44 +00:00
|
|
|
default: yes
|
2018-02-25 02:09:54 +00:00
|
|
|
aliases: [ enable ]
|
2017-08-29 20:18:03 +00:00
|
|
|
state:
|
|
|
|
description:
|
|
|
|
- Should this rule be added or removed.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2018-02-25 02:09:54 +00:00
|
|
|
choices: [ absent, present ]
|
|
|
|
default: present
|
2017-08-29 20:18:03 +00:00
|
|
|
name:
|
|
|
|
description:
|
2019-01-03 16:50:44 +00:00
|
|
|
- The rules name.
|
|
|
|
type: str
|
2018-02-25 02:09:54 +00:00
|
|
|
required: yes
|
2017-08-29 20:18:03 +00:00
|
|
|
direction:
|
|
|
|
description:
|
2019-01-03 16:50:44 +00:00
|
|
|
- Whether this rule is for inbound or outbound traffic.
|
|
|
|
type: str
|
2018-02-25 02:09:54 +00:00
|
|
|
required: yes
|
|
|
|
choices: [ in, out ]
|
2017-08-29 20:18:03 +00:00
|
|
|
action:
|
|
|
|
description:
|
|
|
|
- What to do with the items this rule is for.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2018-02-25 02:09:54 +00:00
|
|
|
required: yes
|
2018-12-21 02:05:28 +00:00
|
|
|
choices: [ allow, block ]
|
2017-08-29 20:18:03 +00:00
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Description for the firewall rule.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2017-08-29 20:18:03 +00:00
|
|
|
localip:
|
|
|
|
description:
|
|
|
|
- The local ip address this rule applies to.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2018-02-25 02:09:54 +00:00
|
|
|
default: any
|
2017-08-29 20:18:03 +00:00
|
|
|
remoteip:
|
|
|
|
description:
|
|
|
|
- The remote ip address/range this rule applies to.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2018-02-25 02:09:54 +00:00
|
|
|
default: any
|
2017-08-29 20:18:03 +00:00
|
|
|
localport:
|
|
|
|
description:
|
|
|
|
- The local port this rule applies to.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2017-08-29 20:18:03 +00:00
|
|
|
remoteport:
|
|
|
|
description:
|
|
|
|
- The remote port this rule applies to.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2017-08-29 20:18:03 +00:00
|
|
|
program:
|
|
|
|
description:
|
|
|
|
- The program this rule applies to.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2017-08-29 20:18:03 +00:00
|
|
|
service:
|
|
|
|
description:
|
|
|
|
- The service this rule applies to.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2017-08-29 20:18:03 +00:00
|
|
|
protocol:
|
|
|
|
description:
|
|
|
|
- The protocol this rule applies to.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2018-02-25 02:09:54 +00:00
|
|
|
default: any
|
2017-08-29 20:18:03 +00:00
|
|
|
profiles:
|
2015-03-16 10:34:07 +00:00
|
|
|
description:
|
2017-08-29 20:18:03 +00:00
|
|
|
- The profile this rule applies to.
|
2018-07-17 21:29:05 +00:00
|
|
|
type: list
|
2018-02-25 02:09:54 +00:00
|
|
|
default: domain,private,public
|
|
|
|
aliases: [ profile ]
|
2017-10-10 06:23:08 +00:00
|
|
|
force:
|
|
|
|
description:
|
|
|
|
- Replace any existing rule by removing it first.
|
2019-01-03 16:50:44 +00:00
|
|
|
- This is no longer required in Ansible 2.4 as rules no longer need replacing when being modified.
|
|
|
|
- DEPRECATED in Ansible 2.4 and will be removed in Ansible 2.9.
|
2018-02-25 02:09:54 +00:00
|
|
|
type: bool
|
2019-01-03 16:50:44 +00:00
|
|
|
default: no
|
2018-12-15 02:23:59 +00:00
|
|
|
seealso:
|
|
|
|
- module: win_firewall
|
|
|
|
author:
|
|
|
|
- Artem Zinenko (@ar7z1)
|
|
|
|
- Timothy Vandenbrande (@TimothyVandenbrande)
|
2015-03-16 10:34:07 +00:00
|
|
|
'''
|
|
|
|
|
2017-01-19 01:57:33 +00:00
|
|
|
EXAMPLES = r'''
|
2017-05-30 23:10:34 +00:00
|
|
|
- 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
|
2015-03-16 10:34:07 +00:00
|
|
|
|
2017-05-30 23:10:34 +00:00
|
|
|
- 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
|
2015-06-30 06:39:19 +00:00
|
|
|
'''
|