Debian Codegraph @

ansible_collections/community/windows/plugins/modules/win_firewall_rule.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2014, Timothy Vandenbrande <[email protected]>
5 # Copyright: (c) 2017, Artem Zinenko <[email protected]>
6 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
7
8 DOCUMENTATION = r'''
9 ---
10 module: win_firewall_rule
11 short_description: Windows firewall automation
12 description:
13 - Allows you to create/remove/update firewall rules.
14 options:
15 enabled:
16 description:
17 - Whether this firewall rule is enabled or disabled.
18 - Defaults to C(true) when creating a new rule.
19 type: bool
20 aliases: [ enable ]
21 state:
22 description:
23 - Should this rule be added or removed.
24 type: str
25 choices: [ absent, present ]
26 default: present
27 name:
28 description:
29 - The rule's display name.
30 - This is required unless I(group) is specified.
31 type: str
32 group:
33 description:
34 - The group name for the rule.
35 - If I(name) is not specified then the module will set the firewall options for all the rules in this group.
36 type: str
37 direction:
38 description:
39 - Whether this rule is for inbound or outbound traffic.
40 - Defaults to C(in) when creating a new rule.
41 type: str
42 choices: [ in, out ]
43 action:
44 description:
45 - What to do with the items this rule is for.
46 - Defaults to C(allow) when creating a new rule.
47 type: str
48 choices: [ allow, block ]
49 description:
50 description:
51 - Description for the firewall rule.
52 type: str
53 localip:
54 description:
55 - The local ip address this rule applies to.
56 - Set to C(any) to apply to all local ip addresses.
57 - Defaults to C(any) when creating a new rule.
58 type: str
59 remoteip:
60 description:
61 - The remote ip address/range this rule applies to.
62 - Set to C(any) to apply to all remote ip addresses.
63 - Defaults to C(any) when creating a new rule.
64 type: str
65 localport:
66 description:
67 - The local port this rule applies to.
68 - Set to C(any) to apply to all local ports.
69 - Defaults to C(any) when creating a new rule.
70 - Must have I(protocol) set
71 type: str
72 remoteport:
73 description:
74 - The remote port this rule applies to.
75 - Set to C(any) to apply to all remote ports.
76 - Defaults to C(any) when creating a new rule.
77 - Must have I(protocol) set
78 type: str
79 program:
80 description:
81 - The program this rule applies to.
82 - Set to C(any) to apply to all programs.
83 - Defaults to C(any) when creating a new rule.
84 type: str
85 service:
86 description:
87 - The service this rule applies to.
88 - Set to C(any) to apply to all services.
89 - Defaults to C(any) when creating a new rule.
90 type: str
91 protocol:
92 description:
93 - The protocol this rule applies to.
94 - Set to C(any) to apply to all services.
95 - Defaults to C(any) when creating a new rule.
96 type: str
97 profiles:
98 description:
99 - The profile this rule applies to.
100 - Defaults to C(domain,private,public) when creating a new rule.
101 type: list
102 elements: str
103 aliases: [ profile ]
104 icmp_type_code:
105 description:
106 - The ICMP types and codes for the rule.
107 - This is only valid when I(protocol) is C(icmpv4) or C(icmpv6).
108 - Each entry follows the format C(type:code) where C(type) is the type
109 number and C(code) is the code number for that type or C(*) for all
110 codes.
111 - Set the value to just C(*) to apply the rule for all ICMP type codes.
112 - See U(https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml)
113 for a list of ICMP types and the codes that apply to them.
114 - ICMP types and codes for IPV6 can be found at U(https://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml).
115 type: list
116 elements: str
117 notes:
118 - Multiple firewall rules can share the same I(name), if there are multiple matches then the module will set the user
119 defined options for each matching rule.
120 seealso:
121 - module: community.windows.win_firewall
122 author:
123 - Artem Zinenko (@ar7z1)
124 - Timothy Vandenbrande (@TimothyVandenbrande)
125 '''
126
127 EXAMPLES = r'''
128 - name: Firewall rule to allow SMTP on TCP port 25
129 community.windows.win_firewall_rule:
130 name: SMTP
131 localport: 25
132 action: allow
133 direction: in
134 protocol: tcp
135 state: present
136 enabled: true
137
138 - name: Firewall rule to allow RDP on TCP port 3389
139 community.windows.win_firewall_rule:
140 name: Remote Desktop
141 localport: 3389
142 action: allow
143 direction: in
144 protocol: tcp
145 profiles: private
146 state: present
147 enabled: true
148
149 - name: Firewall rule to be created for application group
150 community.windows.win_firewall_rule:
151 name: SMTP
152 group: application
153 localport: 25
154 action: allow
155 direction: in
156 protocol: tcp
157 state: present
158 enabled: true
159
160 - name: Enable all the Firewall rules in application group
161 win_firewall_rule:
162 group: application
163 enabled: true
164
165 - name: Firewall rule to allow port range
166 community.windows.win_firewall_rule:
167 name: Sample port range
168 localport: 5000-5010
169 action: allow
170 direction: in
171 protocol: tcp
172 state: present
173 enabled: true
174
175 - name: Firewall rule to allow ICMP v4 echo (ping)
176 community.windows.win_firewall_rule:
177 name: ICMP Allow incoming V4 echo request
178 enabled: true
179 state: present
180 profiles: private
181 action: allow
182 direction: in
183 protocol: icmpv4
184 icmp_type_code:
185 - '8:*'
186
187 - name: Firewall rule to alloc ICMP v4 on all type codes
188 community.windows.win_firewall_rule:
189 name: ICMP Allow incoming V4 echo request
190 enabled: true
191 state: present
192 profiles: private
193 action: allow
194 direction: in
195 protocol: icmpv4
196 icmp_type_code: '*'
197 '''