Debian Codegraph @

ansible_collections/cisco/meraki/plugins/modules/networks_switch_access_policies.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2021, Cisco Systems
5 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 DOCUMENTATION = r"""
8 module: networks_switch_access_policies
9 short_description: Resource module for networks _switch _accesspolicies
10 description:
11 - Manage operations create, update and delete of the resource networks _switch _accesspolicies.
12 - >
13 Create an access policy for a switch network. If you would like to enable Meraki
14 Authentication, set radiusServers to empty array.
15 - Delete an access policy for a switch network.
16 - >
17 Update an access policy for a switch network. If you would like to enable Meraki
18 Authentication, set radiusServers to empty array.
19 version_added: '1.0.0'
20 extends_documentation_fragment:
21 - cisco.meraki.module
22 author: Francisco Munoz (@fmunoz)
23 options:
24 accessPolicyNumber:
25 description: AccessPolicyNumber path parameter. Access policy number.
26 type: str
27 accessPolicyType:
28 description: Access Type of the policy. Automatically 'Hybrid authentication'
29 when hostMode is 'Multi-Domain'.
30 type: str
31 dot1x:
32 description: 802.1x Settings.
33 suboptions:
34 controlDirection:
35 description: Supports either 'both' or 'inbound'. Set to 'inbound' to allow
36 unauthorized egress on the switchport. Set to 'both' to control both traffic
37 directions with authorization. Defaults to 'both'.
38 type: str
39 type: dict
40 guestGroupPolicyId:
41 description: Group policy Number for guest group policy.
42 type: str
43 guestPortBouncing:
44 description: If enabled, Meraki devices will periodically send access-request
45 messages to these RADIUS servers.
46 type: bool
47 guestSgtId:
48 description: Security Group Tag ID for guest group policy.
49 type: int
50 guestVlanId:
51 description: ID for the guest VLAN allow unauthorized devices access to limited
52 network resources.
53 type: int
54 hostMode:
55 description: Choose the Host Mode for the access policy.
56 type: str
57 increaseAccessSpeed:
58 description: Enabling this option will make switches execute 802.1X and MAC-bypass
59 authentication simultaneously so that clients authenticate faster. Only required
60 when accessPolicyType is 'Hybrid Authentication.
61 type: bool
62 name:
63 description: Name of the access policy(max length 255).
64 type: str
65 networkId:
66 description: NetworkId path parameter. Network ID.
67 type: str
68 radius:
69 description: Object for RADIUS Settings.
70 suboptions:
71 authentication:
72 description: Object for authentication mode settings.
73 suboptions:
74 mode:
75 description: Authentication mode of the policy ( Open | Closed ).
76 type: str
77 type: dict
78 cache:
79 description: Object for RADIUS Cache Settings.
80 suboptions:
81 enabled:
82 description: Enable to cache authorization and authentication responses
83 on the RADIUS server.
84 type: bool
85 timeout:
86 description: If RADIUS caching is enabled, this value dictates how long
87 the cache will remain in the RADIUS server, in hours, to allow network
88 access without authentication.
89 type: int
90 type: dict
91 criticalAuth:
92 description: Critical auth settings for when authentication is rejected by
93 the RADIUS server.
94 suboptions:
95 dataGroupPolicyId:
96 description: Group policy Number for data VLAN.
97 type: str
98 dataSgtId:
99 description: Security Group Tag ID for data VLAN.
100 type: int
101 dataVlanId:
102 description: VLAN that clients who use data will be placed on when RADIUS
103 authentication fails. Will be null if hostMode is Multi-Auth.
104 type: int
105 suspendPortBounce:
106 description: Disable port bounce when RADIUS servers are unreachable.
107 type: bool
108 voiceGroupPolicyId:
109 description: Group policy Number for voice VLAN.
110 type: str
111 voiceSgtId:
112 description: Security Group Tag ID for voice VLAN.
113 type: int
114 voiceVlanId:
115 description: VLAN that clients who use voice will be placed on when RADIUS
116 authentication fails. Will be null if hostMode is Multi-Auth.
117 type: int
118 type: dict
119 failedAuthGroupPolicyId:
120 description: Group policy Number for failed authentication group policy.
121 type: str
122 failedAuthSgtId:
123 description: Security Group Tag ID for failed authentication group policy.
124 type: int
125 failedAuthVlanId:
126 description: VLAN that clients will be placed on when RADIUS authentication
127 fails. Will be null if hostMode is Multi-Auth.
128 type: int
129 preAuthenticationGroupPolicyId:
130 description: Group policy Number for pre-authentication group policy.
131 type: str
132 reAuthenticationInterval:
133 description: Re-authentication period in seconds. Will be null if hostMode
134 is Multi-Auth.
135 type: int
136 type: dict
137 radiusAccountingEnabled:
138 description: Enable to send start, interim-update and stop messages to a configured
139 RADIUS accounting server for tracking connected clients.
140 type: bool
141 radiusAccountingServers:
142 description: List of RADIUS accounting servers to require connecting devices to
143 authenticate against before granting network access.
144 elements: dict
145 suboptions:
146 host:
147 description: Public IP address of the RADIUS accounting server.
148 type: str
149 organizationRadiusServerId:
150 description: Organization wide RADIUS server ID. If this field is provided,
151 the host, port and secret field will be ignored.
152 type: str
153 port:
154 description: UDP port that the RADIUS Accounting server listens on for access
155 requests.
156 type: int
157 secret:
158 description: RADIUS client shared secret.
159 type: str
160 type: list
161 radiusCoaSupportEnabled:
162 description: Change of authentication for RADIUS re-authentication and disconnection.
163 type: bool
164 radiusGroupAttribute:
165 description: Acceptable values are `""` for None, or `"11"` for Group Policies
166 ACL.
167 type: str
168 radiusServers:
169 description: List of RADIUS servers to require connecting devices to authenticate
170 against before granting network access.
171 elements: dict
172 suboptions:
173 host:
174 description: Public IP address of the RADIUS server.
175 type: str
176 organizationRadiusServerId:
177 description: Organization wide RADIUS server ID. If this field is provided,
178 the host, port and secret field will be ignored.
179 type: str
180 port:
181 description: UDP port that the RADIUS server listens on for access requests.
182 type: int
183 secret:
184 description: RADIUS client shared secret.
185 type: str
186 type: list
187 radiusTestingEnabled:
188 description: If enabled, Meraki devices will periodically send access-request
189 messages to these RADIUS servers.
190 type: bool
191 urlRedirectWalledGardenEnabled:
192 description: Enable to restrict access for clients to a specific set of IP addresses
193 or hostnames prior to authentication.
194 type: bool
195 urlRedirectWalledGardenRanges:
196 description: IP address ranges, in CIDR notation, to restrict access for clients
197 to a specific set of IP addresses or hostnames prior to authentication.
198 elements: str
199 type: list
200 voiceVlanClients:
201 description: CDP/LLDP capable voice clients will be able to use this VLAN. Automatically
202 true when hostMode is 'Multi-Domain'.
203 type: bool
204 requirements:
205 - meraki >= 2.4.9
206 - python >= 3.5
207 seealso:
208 - name: Cisco Meraki documentation for switch createNetworkSwitchAccessPolicy
209 description: Complete reference of the createNetworkSwitchAccessPolicy API.
210 link: https://developer.cisco.com/meraki/api-v1/#!create-network-switch-access-policy
211 - name: Cisco Meraki documentation for switch deleteNetworkSwitchAccessPolicy
212 description: Complete reference of the deleteNetworkSwitchAccessPolicy API.
213 link: https://developer.cisco.com/meraki/api-v1/#!delete-network-switch-access-policy
214 - name: Cisco Meraki documentation for switch updateNetworkSwitchAccessPolicy
215 description: Complete reference of the updateNetworkSwitchAccessPolicy API.
216 link: https://developer.cisco.com/meraki/api-v1/#!update-network-switch-access-policy
217 notes:
218 - SDK Method used are
219 switch.Switch.create_network_switch_access_policy,
220 switch.Switch.delete_network_switch_access_policy,
221 switch.Switch.update_network_switch_access_policy,
222 - Paths used are
223 post /networks/{networkId}/switch/accessPolicies,
224 delete /networks/{networkId}/switch/accessPolicies/{accessPolicyNumber},
225 put /networks/{networkId}/switch/accessPolicies/{accessPolicyNumber},
226 """
227
228 EXAMPLES = r"""
229 - name: Create
230 cisco.meraki.networks_switch_access_policies:
231 meraki_api_key: "{{ meraki_api_key }}"
232 meraki_base_url: "{{ meraki_base_url }}"
233 meraki_single_request_timeout: "{{ meraki_single_request_timeout }}"
234 meraki_certificate_path: "{{ meraki_certificate_path }}"
235 meraki_requests_proxy: "{{ meraki_requests_proxy }}"
236 meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}"
237 meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}"
238 meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}"
239 meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}"
240 meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}"
241 meraki_maximum_retries: "{{ meraki_maximum_retries }}"
242 meraki_output_log: "{{ meraki_output_log }}"
243 meraki_log_file_prefix: "{{ meraki_log_file_prefix }}"
244 meraki_log_path: "{{ meraki_log_path }}"
245 meraki_print_console: "{{ meraki_print_console }}"
246 meraki_suppress_logging: "{{ meraki_suppress_logging }}"
247 meraki_simulate: "{{ meraki_simulate }}"
248 meraki_be_geo_id: "{{ meraki_be_geo_id }}"
249 meraki_caller: "{{ meraki_caller }}"
250 meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}"
251 meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}"
252 state: present
253 accessPolicyType: Hybrid authentication
254 dot1x:
255 controlDirection: inbound
256 guestGroupPolicyId: '1234'
257 guestPortBouncing: false
258 guestSgtId: 1284392014819
259 guestVlanId: 100
260 hostMode: Single-Host
261 increaseAccessSpeed: false
262 name: 'Access policy #1'
263 networkId: string
264 radius:
265 authentication:
266 mode: Open
267 cache:
268 enabled: false
269 timeout: 24
270 criticalAuth:
271 dataGroupPolicyId: '1234'
272 dataSgtId: 1234
273 dataVlanId: 100
274 suspendPortBounce: true
275 voiceGroupPolicyId: '1234'
276 voiceSgtId: 1234
277 voiceVlanId: 100
278 failedAuthGroupPolicyId: '1234'
279 failedAuthSgtId: 1284392014819
280 failedAuthVlanId: 100
281 preAuthenticationGroupPolicyId: '1234'
282 reAuthenticationInterval: 120
283 radiusAccountingEnabled: true
284 radiusAccountingServers:
285 - host: 1.2.3.4
286 organizationRadiusServerId: '42'
287 port: 22
288 secret: secret
289 radiusCoaSupportEnabled: false
290 radiusGroupAttribute: '11'
291 radiusServers:
292 - host: 1.2.3.4
293 organizationRadiusServerId: '42'
294 port: 22
295 secret: secret
296 radiusTestingEnabled: false
297 urlRedirectWalledGardenEnabled: true
298 urlRedirectWalledGardenRanges:
299 - 192.168.1.0/24
300 voiceVlanClients: true
301 - name: Update by id
302 cisco.meraki.networks_switch_access_policies:
303 meraki_api_key: "{{ meraki_api_key }}"
304 meraki_base_url: "{{ meraki_base_url }}"
305 meraki_single_request_timeout: "{{ meraki_single_request_timeout }}"
306 meraki_certificate_path: "{{ meraki_certificate_path }}"
307 meraki_requests_proxy: "{{ meraki_requests_proxy }}"
308 meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}"
309 meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}"
310 meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}"
311 meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}"
312 meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}"
313 meraki_maximum_retries: "{{ meraki_maximum_retries }}"
314 meraki_output_log: "{{ meraki_output_log }}"
315 meraki_log_file_prefix: "{{ meraki_log_file_prefix }}"
316 meraki_log_path: "{{ meraki_log_path }}"
317 meraki_print_console: "{{ meraki_print_console }}"
318 meraki_suppress_logging: "{{ meraki_suppress_logging }}"
319 meraki_simulate: "{{ meraki_simulate }}"
320 meraki_be_geo_id: "{{ meraki_be_geo_id }}"
321 meraki_caller: "{{ meraki_caller }}"
322 meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}"
323 meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}"
324 state: present
325 accessPolicyNumber: string
326 accessPolicyType: Hybrid authentication
327 dot1x:
328 controlDirection: inbound
329 guestGroupPolicyId: '1234'
330 guestPortBouncing: false
331 guestSgtId: 1284392014819
332 guestVlanId: 100
333 hostMode: Single-Host
334 increaseAccessSpeed: false
335 name: 'Access policy #1'
336 networkId: string
337 radius:
338 authentication:
339 mode: Open
340 cache:
341 enabled: false
342 timeout: 24
343 criticalAuth:
344 dataGroupPolicyId: '1234'
345 dataSgtId: 1234
346 dataVlanId: 100
347 suspendPortBounce: true
348 voiceGroupPolicyId: '1234'
349 voiceSgtId: 1234
350 voiceVlanId: 100
351 failedAuthGroupPolicyId: '1234'
352 failedAuthSgtId: 1284392014819
353 failedAuthVlanId: 100
354 preAuthenticationGroupPolicyId: '1234'
355 reAuthenticationInterval: 120
356 radiusAccountingEnabled: true
357 radiusAccountingServers:
358 - host: 1.2.3.4
359 organizationRadiusServerId: '42'
360 port: 22
361 secret: secret
362 serverId: '2'
363 radiusCoaSupportEnabled: false
364 radiusGroupAttribute: '11'
365 radiusServers:
366 - host: 1.2.3.4
367 organizationRadiusServerId: '42'
368 port: 22
369 secret: secret
370 serverId: '1'
371 radiusTestingEnabled: false
372 urlRedirectWalledGardenEnabled: true
373 urlRedirectWalledGardenRanges:
374 - 192.168.1.0/24
375 voiceVlanClients: true
376 - name: Delete by id
377 cisco.meraki.networks_switch_access_policies:
378 meraki_api_key: "{{ meraki_api_key }}"
379 meraki_base_url: "{{ meraki_base_url }}"
380 meraki_single_request_timeout: "{{ meraki_single_request_timeout }}"
381 meraki_certificate_path: "{{ meraki_certificate_path }}"
382 meraki_requests_proxy: "{{ meraki_requests_proxy }}"
383 meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}"
384 meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}"
385 meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}"
386 meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}"
387 meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}"
388 meraki_maximum_retries: "{{ meraki_maximum_retries }}"
389 meraki_output_log: "{{ meraki_output_log }}"
390 meraki_log_file_prefix: "{{ meraki_log_file_prefix }}"
391 meraki_log_path: "{{ meraki_log_path }}"
392 meraki_print_console: "{{ meraki_print_console }}"
393 meraki_suppress_logging: "{{ meraki_suppress_logging }}"
394 meraki_simulate: "{{ meraki_simulate }}"
395 meraki_be_geo_id: "{{ meraki_be_geo_id }}"
396 meraki_caller: "{{ meraki_caller }}"
397 meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}"
398 meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}"
399 state: absent
400 accessPolicyNumber: string
401 networkId: string
402 """
403 RETURN = r"""
404 meraki_response:
405 description: A dictionary or list with the response returned by the Cisco Meraki Python SDK
406 returned: always
407 type: dict
408 sample: >
409 {
410 "accessPolicyNumber": "string",
411 "name": "string",
412 "radiusServers": [
413 {
414 "serverId": "string",
415 "organizationRadiusServerId": "string",
416 "host": "string",
417 "port": 0
418 }
419 ],
420 "radius": {
421 "criticalAuth": {
422 "dataVlanId": 0,
423 "voiceVlanId": 0,
424 "suspendPortBounce": true,
425 "dataGroupPolicyId": "string",
426 "voiceGroupPolicyId": "string",
427 "dataSgtId": 0,
428 "voiceSgtId": 0
429 },
430 "failedAuthVlanId": 0,
431 "failedAuthGroupPolicyId": "string",
432 "failedAuthSgtId": 0,
433 "reAuthenticationInterval": 0,
434 "cache": {
435 "enabled": true,
436 "timeout": 0
437 },
438 "authentication": {
439 "mode": "string"
440 },
441 "preAuthenticationGroupPolicyId": "string"
442 },
443 "enforceRadiusMonitoring": true,
444 "guestPortBouncing": true,
445 "radiusTestingEnabled": true,
446 "radiusCoaSupportEnabled": true,
447 "radiusAccountingEnabled": true,
448 "radiusAccountingServers": [
449 {
450 "serverId": "string",
451 "organizationRadiusServerId": "string",
452 "host": "string",
453 "port": 0
454 }
455 ],
456 "radiusGroupAttribute": "string",
457 "hostMode": "string",
458 "accessPolicyType": "string",
459 "increaseAccessSpeed": true,
460 "guestVlanId": {},
461 "dot1x": {
462 "controlDirection": "string"
463 },
464 "voiceVlanClients": true,
465 "urlRedirectWalledGardenEnabled": true,
466 "urlRedirectWalledGardenRanges": [
467 "string"
468 ],
469 "counts": {
470 "ports": {
471 "withThisPolicy": 0
472 }
473 },
474 "guestGroupPolicyId": "string",
475 "guestSgtId": 0
476 }
477 """