Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_acl_interfaces.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2019 Red Hat
4 # GNU General Public License v3.0+
5 # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 #############################################
8 # WARNING #
9 #############################################
10 #
11 # This file is auto generated by the resource
12 # module builder playbook.
13 #
14 # Do not edit this file manually.
15 #
16 # Changes to this file will be over written
17 # by the resource module builder.
18 #
19 # Changes should be made in the model used to
20 # generate this file or in the resource module
21 # builder template.
22 #
23 #############################################
24
25 """
26 The module file for nxos_acl_interfaces
27 """
28
29 from __future__ import absolute_import, division, print_function
30
31
32 __metaclass__ = type
33
34
35 DOCUMENTATION = """
36 module: nxos_acl_interfaces
37 short_description: ACL interfaces resource module
38 description: Add and remove Access Control Lists on interfaces in NX-OS platform
39 version_added: 1.0.0
40 author: Adharsh Srivats Rangarajan (@adharshsrivatsr)
41 notes:
42 - Tested against NX-OS 7.3.(0)D1(1) on VIRL
43 - Unsupported for Cisco MDS
44 options:
45 running_config:
46 description:
47 - This option is used only with state I(parsed).
48 - The value of this option should be the output received from the NX-OS device
49 by executing the command B(show running-config | section '^interface').
50 - The state I(parsed) reads the configuration from C(running_config) option and
51 transforms it into Ansible structured data as per the resource module's argspec
52 and the value is then returned in the I(parsed) key within the result.
53 type: str
54 config:
55 description: A list of interfaces to be configured with ACLs
56 type: list
57 elements: dict
58 suboptions:
59 name:
60 description: Name of the interface
61 type: str
62 required: true
63 access_groups:
64 description: List of address family indicators with ACLs to be configured
65 on the interface
66 type: list
67 elements: dict
68 suboptions:
69 afi:
70 description: Address Family Indicator of the ACLs to be configured
71 type: str
72 required: true
73 choices:
74 - ipv4
75 - ipv6
76 acls:
77 description: List of Access Control Lists for the interface
78 type: list
79 elements: dict
80 suboptions:
81 name:
82 description: Name of the ACL to be added/removed
83 type: str
84 required: true
85 direction:
86 description: Direction to be applied for the ACL
87 type: str
88 required: true
89 choices:
90 - in
91 - out
92 port:
93 description: Use ACL as port policy.
94 type: bool
95 state:
96 description: The state the configuration should be left in
97 type: str
98 choices:
99 - deleted
100 - gathered
101 - merged
102 - overridden
103 - rendered
104 - replaced
105 - parsed
106 default: merged
107
108 """
109 EXAMPLES = """
110 # Using merged
111
112 # Before state:
113 # ------------
114 #
115
116 - name: Merge ACL interfaces configuration
117 cisco.nxos.nxos_acl_interfaces:
118 config:
119 - name: Ethernet1/2
120 access_groups:
121 - afi: ipv6
122 acls:
123 - name: ACL1v6
124 direction: in
125
126 - name: Eth1/5
127 access_groups:
128 - afi: ipv4
129 acls:
130 - name: PortACL
131 direction: in
132 port: true
133
134 - name: ACL1v4
135 direction: out
136
137 - afi: ipv6
138 acls:
139 - name: ACL1v6
140 direction: in
141 state: merged
142
143 # After state:
144 # ------------
145 # interface Ethernet1/2
146 # ipv6 traffic-filter ACL1v6 in
147 # interface Ethernet1/5
148 # ip port access-group PortACL in
149 # ip access-group ACL1v4 out
150 # ipv6 traffic-filter ACL1v6 in
151
152 # Using replaced
153
154 # Before state:
155 # ------------
156 # interface Ethernet1/2
157 # ipv6 traffic-filter ACL1v6 in
158 # interface Ethernet1/5
159 # ip port access-group PortACL in
160 # ip access-group ACL1v4 out
161 # ipv6 traffic-filter ACL1v6 in
162
163 - name: Replace interface configuration with given configuration
164 cisco.nxos.nxos_acl_interfaces:
165 config:
166 - name: Eth1/5
167 access_groups:
168 - afi: ipv4
169 acls:
170 - name: NewACLv4
171 direction: out
172
173 - name: Ethernet1/3
174 access_groups:
175 - afi: ipv6
176 acls:
177 - name: NewACLv6
178 direction: in
179 port: true
180 state: replaced
181
182 # After state:
183 # ------------
184 # interface Ethernet1/2
185 # ipv6 traffic-filter ACL1v6 in
186 # interface Ethernet1/3
187 # ipv6 port traffic-filter NewACLv6 in
188 # interface Ethernet1/5
189 # ip access-group NewACLv4 out
190
191 # Using overridden
192
193 # Before state:
194 # ------------
195 # interface Ethernet1/2
196 # ipv6 traffic-filter ACL1v6 in
197 # interface Ethernet1/5
198 # ip port access-group PortACL in
199 # ip access-group ACL1v4 out
200 # ipv6 traffic-filter ACL1v6 in
201
202 - name: Override interface configuration with given configuration
203 cisco.nxos.nxos_acl_interfaces:
204 config:
205 - name: Ethernet1/3
206 access_groups:
207 - afi: ipv4
208 acls:
209 - name: ACL1v4
210 direction: out
211
212 - name: PortACL
213 port: true
214 direction: in
215 - afi: ipv6
216 acls:
217 - name: NewACLv6
218 direction: in
219 port: true
220 state: overridden
221
222 # After state:
223 # ------------
224 # interface Ethernet1/3
225 # ip access-group ACL1v4 out
226 # ip port access-group PortACL in
227 # ipv6 port traffic-filter NewACLv6 in
228
229 # Using deleted to remove ACL config from specified interfaces
230
231 # Before state:
232 # -------------
233 # interface Ethernet1/1
234 # ip access-group ACL2v4 in
235 # interface Ethernet1/2
236 # ipv6 traffic-filter ACL1v6 in
237 # interface Ethernet1/5
238 # ip port access-group PortACL in
239 # ip access-group ACL1v4 out
240 # ipv6 traffic-filter ACL1v6 in
241
242 - name: Delete ACL configuration on interfaces
243 cisco.nxos.nxos_acl_interfaces:
244 config:
245 - name: Ethernet1/5
246 - name: Ethernet1/2
247 state: deleted
248
249 # After state:
250 # -------------
251 # interface Ethernet1/1
252 # ip access-group ACL2v4 in
253 # interface Ethernet1/2
254 # interface Ethernet1/5
255
256 # Using deleted to remove ACL config from all interfaces
257
258 # Before state:
259 # -------------
260 # interface Ethernet1/1
261 # ip access-group ACL2v4 in
262 # interface Ethernet1/2
263 # ipv6 traffic-filter ACL1v6 in
264 # interface Ethernet1/5
265 # ip port access-group PortACL in
266 # ip access-group ACL1v4 out
267 # ipv6 traffic-filter ACL1v6 in
268
269 - name: Delete ACL configuration from all interfaces
270 cisco.nxos.nxos_acl_interfaces:
271 state: deleted
272
273 # After state:
274 # -------------
275 # interface Ethernet1/1
276 # interface Ethernet1/2
277 # interface Ethernet1/5
278
279 # Using parsed
280
281 - name: Parse given configuration into structured format
282 cisco.nxos.nxos_acl_interfaces:
283 running_config: |
284 interface Ethernet1/2
285 ipv6 traffic-filter ACL1v6 in
286 interface Ethernet1/5
287 ipv6 traffic-filter ACL1v6 in
288 ip access-group ACL1v4 out
289 ip port access-group PortACL in
290 state: parsed
291
292 # returns
293 # parsed:
294 # - name: Ethernet1/2
295 # access_groups:
296 # - afi: ipv6
297 # acls:
298 # - name: ACL1v6
299 # direction: in
300 # - name: Ethernet1/5
301 # access_groups:
302 # - afi: ipv4
303 # acls:
304 # - name: PortACL
305 # direction: in
306 # port: True
307 # - name: ACL1v4
308 # direction: out
309 # - afi: ipv6
310 # acls:
311 # - name: ACL1v6
312 # direction: in
313
314
315 # Using gathered:
316
317 # Before state:
318 # ------------
319 # interface Ethernet1/2
320 # ipv6 traffic-filter ACL1v6 in
321 # interface Ethernet1/5
322 # ipv6 traffic-filter ACL1v6 in
323 # ip access-group ACL1v4 out
324 # ip port access-group PortACL in
325
326 - name: Gather existing configuration from device
327 cisco.nxos.nxos_acl_interfaces:
328 config:
329 state: gathered
330
331 # returns
332 # gathered:
333 # - name: Ethernet1/2
334 # access_groups:
335 # - afi: ipv6
336 # acls:
337 # - name: ACL1v6
338 # direction: in
339 # - name: Ethernet1/5
340 # access_groups:
341 # - afi: ipv4
342 # acls:
343 # - name: PortACL
344 # direction: in
345 # port: True
346 # - name: ACL1v4
347 # direction: out
348 # - afi: ipv6
349 # acls:
350 # - name: ACL1v6
351 # direction: in
352
353
354 # Using rendered
355
356 - name: Render required configuration to be pushed to the device
357 cisco.nxos.nxos_acl_interfaces:
358 config:
359 - name: Ethernet1/2
360 access_groups:
361 - afi: ipv6
362 acls:
363 - name: ACL1v6
364 direction: in
365 - name: Ethernet1/5
366 access_groups:
367 - afi: ipv4
368 acls:
369 - name: PortACL
370 direction: in
371 port: true
372 - name: ACL1v4
373 direction: out
374 - afi: ipv6
375 acls:
376 - name: ACL1v6
377 direction: in
378 state: rendered
379
380
381 # returns
382 # rendered:
383 # interface Ethernet1/2
384 # ipv6 traffic-filter ACL1v6 in
385 # interface Ethernet1/5
386 # ipv6 traffic-filter ACL1v6 in
387 # ip access-group ACL1v4 out
388 # ip port access-group PortACL in
389 """
390 RETURN = """
391 before:
392 description: The configuration prior to the model invocation.
393 returned: always
394 type: dict
395 sample: >
396 The configuration returned will always be in the same format
397 of the parameters above.
398 after:
399 description: The resulting configuration model invocation.
400 returned: when changed
401 type: dict
402 sample: >
403 The configuration returned will always be in the same format
404 of the parameters above.
405 commands:
406 description: The set of commands pushed to the remote device.
407 returned: always
408 type: list
409 sample: ['interface Ethernet1/2', 'ipv6 traffic-filter ACL1v6 out', 'ip port access-group PortACL in']
410 """
411
412
413 from ansible.module_utils.basic import AnsibleModule
414
415 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.acl_interfaces.acl_interfaces import (
416 Acl_interfacesArgs,
417 )
418 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.acl_interfaces.acl_interfaces import (
419 Acl_interfaces,
420 )
421
422
423 def main():
424 """
425 Main entry point for module execution
426
427 :returns: the result form module invocation
428 """
429 module = AnsibleModule(
430 argument_spec=Acl_interfacesArgs.argument_spec,
431 supports_check_mode=True,
432 )
433
434 result = Acl_interfaces(module).execute_module()
435 module.exit_json(**result)
436
437
438 if __name__ == "__main__":
439 main()