Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_acls.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 The module file for nxos_acls
26 """
27
28 from __future__ import absolute_import, division, print_function
29
30
31 __metaclass__ = type
32
33
34 DOCUMENTATION = """
35 module: nxos_acls
36 short_description: ACLs resource module
37 description: Manage named IP ACLs on the Cisco NX-OS platform
38 version_added: 1.0.0
39 author: Adharsh Srivats Rangarajan (@adharshsrivatsr)
40 notes:
41 - Tested against NX-OS 7.3.(0)D1(1) on VIRL
42 - Unsupported for Cisco MDS
43 - As NX-OS allows configuring a rule again with different sequence numbers, the user
44 is expected to provide sequence numbers for the access control entries to preserve
45 idempotency. If no sequence number is given, the rule will be added as a new rule
46 by the device.
47 options:
48 running_config:
49 description:
50 - This option is used only with state I(parsed).
51 - The value of this option should be the output received from the NX-OS device
52 by executing the command B(show running-config | section 'ip(v6)* access-list).
53 - The state I(parsed) reads the configuration from C(running_config) option and
54 transforms it into Ansible structured data as per the resource module's argspec
55 and the value is then returned in the I(parsed) key within the result.
56 type: str
57 config:
58 description: A dictionary of ACL options.
59 type: list
60 elements: dict
61 suboptions:
62 afi:
63 description: The Address Family Indicator (AFI) for the ACL.
64 type: str
65 required: true
66 choices:
67 - ipv4
68 - ipv6
69 acls:
70 description: A list of the ACLs.
71 type: list
72 elements: dict
73 suboptions:
74 name:
75 description: Name of the ACL.
76 type: str
77 required: true
78 aces:
79 description: The entries within the ACL.
80 type: list
81 elements: dict
82 suboptions:
83 grant:
84 description: Action to be applied on the rule.
85 type: str
86 choices:
87 - permit
88 - deny
89 destination:
90 description: Specify the packet destination.
91 type: dict
92 suboptions:
93 address:
94 description: Destination network address.
95 type: str
96 any:
97 description: Any destination address.
98 type: bool
99 host:
100 description: Host IP address.
101 type: str
102 port_protocol:
103 description: Specify the destination port or protocol (only for
104 TCP and UDP).
105 type: dict
106 suboptions:
107 eq:
108 description: Match only packets on a given port number.
109 type: str
110 gt:
111 description: Match only packets with a greater port number.
112 type: str
113 lt:
114 description: Match only packets with a lower port number.
115 type: str
116 neq:
117 description: Match only packets not on a given port number.
118 type: str
119 range:
120 description: Match only packets in the range of port numbers.
121 type: dict
122 suboptions:
123 start:
124 description: Specify the start of the port range.
125 type: str
126 end:
127 description: Specify the end of the port range.
128 type: str
129 prefix:
130 description: Destination network prefix. Only for prefixes of
131 value less than 31 for ipv4 and 127 for ipv6. Prefixes of 32
132 (ipv4) and 128 (ipv6) should be given in the 'host' key.
133 type: str
134 wildcard_bits:
135 description: Destination wildcard bits.
136 type: str
137 dscp:
138 description: Match packets with given DSCP value.
139 type: str
140 fragments:
141 description: Check non-initial fragments.
142 type: bool
143 remark:
144 description: Access list entry comment.
145 type: str
146 sequence:
147 description: Sequence number.
148 type: int
149 source:
150 description: Specify the packet source.
151 type: dict
152 suboptions:
153 address:
154 description: Source network address.
155 type: str
156 any:
157 description: Any source address.
158 type: bool
159 host:
160 description: Host IP address.
161 type: str
162 port_protocol:
163 description: Specify the destination port or protocol (only for
164 TCP and UDP).
165 type: dict
166 suboptions:
167 eq:
168 description: Match only packets on a given port number.
169 type: str
170 gt:
171 description: Match only packets with a greater port number.
172 type: str
173 lt:
174 description: Match only packets with a lower port number.
175 type: str
176 neq:
177 description: Match only packets not on a given port number.
178 type: str
179 range:
180 description: Match only packets in the range of port numbers.
181 type: dict
182 suboptions:
183 start:
184 description: Specify the start of the port range.
185 type: str
186 end:
187 description: Specify the end of the port range.
188 type: str
189 prefix:
190 description: Source network prefix. Only for prefixes of mask
191 value less than 31 for ipv4 and 127 for ipv6. Prefixes of mask
192 32 (ipv4) and 128 (ipv6) should be given in the 'host' key.
193 type: str
194 wildcard_bits:
195 description: Source wildcard bits.
196 type: str
197 log:
198 description: Log matches against this entry.
199 type: bool
200 precedence:
201 description: Match packets with given precedence value.
202 type: str
203 protocol:
204 description: Specify the protocol.
205 type: str
206 protocol_options:
207 description: All possible suboptions for the protocol chosen.
208 type: dict
209 suboptions:
210 icmp:
211 description: ICMP protocol options.
212 type: dict
213 suboptions:
214 administratively_prohibited:
215 description: Administratively prohibited
216 type: bool
217 alternate_address:
218 description: Alternate address
219 type: bool
220 conversion_error:
221 description: Datagram conversion
222 type: bool
223 dod_host_prohibited:
224 description: Host prohibited
225 type: bool
226 dod_net_prohibited:
227 description: Net prohibited
228 type: bool
229 echo:
230 description: Echo (ping)
231 type: bool
232 echo_reply:
233 description: Echo reply
234 type: bool
235 echo_request:
236 description: Echo request (ping)
237 type: bool
238 general_parameter_problem:
239 description: Parameter problem
240 type: bool
241 host_isolated:
242 description: Host isolated
243 type: bool
244 host_precedence_unreachable:
245 description: Host unreachable for precedence
246 type: bool
247 host_redirect:
248 description: Host redirect
249 type: bool
250 host_tos_redirect:
251 description: Host redirect for TOS
252 type: bool
253 host_tos_unreachable:
254 description: Host unreachable for TOS
255 type: bool
256 host_unknown:
257 description: Host unknown
258 type: bool
259 host_unreachable:
260 description: Host unreachable
261 type: bool
262 information_reply:
263 description: Information replies
264 type: bool
265 information_request:
266 description: Information requests
267 type: bool
268 mask_reply:
269 description: Mask replies
270 type: bool
271 mask_request:
272 description: Mask requests
273 type: bool
274 message_code:
275 description: ICMP message code
276 type: int
277 message_type:
278 description: ICMP message type
279 type: int
280 mobile_redirect:
281 description: Mobile host redirect
282 type: bool
283 net_redirect:
284 description: Network redirect
285 type: bool
286 net_tos_redirect:
287 description: Net redirect for TOS
288 type: bool
289 net_tos_unreachable:
290 description: Network unreachable for TOS
291 type: bool
292 net_unreachable:
293 description: Net unreachable
294 type: bool
295 network_unknown:
296 description: Network unknown
297 type: bool
298 no_room_for_option:
299 description: Parameter required but no room
300 type: bool
301 option_missing:
302 description: Parameter required but not present
303 type: bool
304 packet_too_big:
305 description: Fragmentation needed and DF set
306 type: bool
307 parameter_problem:
308 description: All parameter problems
309 type: bool
310 port_unreachable:
311 description: Port unreachable
312 type: bool
313 precedence_unreachable:
314 description: Precedence cutoff
315 type: bool
316 protocol_unreachable:
317 description: Protocol unreachable
318 type: bool
319 reassembly_timeout:
320 description: Reassembly timeout
321 type: bool
322 redirect:
323 description: All redirects
324 type: bool
325 router_advertisement:
326 description: Router discovery advertisements
327 type: bool
328 router_solicitation:
329 description: Router discovery solicitations
330 type: bool
331 source_quench:
332 description: Source quenches
333 type: bool
334 source_route_failed:
335 description: Source route failed
336 type: bool
337 time_exceeded:
338 description: All time exceeded.
339 type: bool
340 timestamp_reply:
341 description: Timestamp replies
342 type: bool
343 timestamp_request:
344 description: Timestamp requests
345 type: bool
346 traceroute:
347 description: Traceroute
348 type: bool
349 ttl_exceeded:
350 description: TTL exceeded
351 type: bool
352 unreachable:
353 description: All unreachables
354 type: bool
355 icmpv6:
356 description: ICMPv6 protocol options.
357 type: dict
358 suboptions:
359 beyond_scope:
360 description: Destination beyond scope.
361 type: bool
362 destination_unreachable:
363 description: Destination address is unreachable.
364 type: bool
365 echo_reply:
366 description: Echo reply.
367 type: bool
368 echo_request:
369 description: Echo request (ping).
370 type: bool
371 fragments:
372 description: Check non-initial fragments.
373 type: bool
374 header:
375 description: Parameter header problem.
376 type: bool
377 hop_limit:
378 description: Hop limit exceeded in transit.
379 type: bool
380 mld_query:
381 description: Multicast Listener Discovery Query.
382 type: bool
383 mld_reduction:
384 description: Multicast Listener Discovery Reduction.
385 type: bool
386 mld_report:
387 description: Multicast Listener Discovery Report.
388 type: bool
389 mldv2:
390 description: Multicast Listener Discovery Protocol.
391 type: bool
392 nd_na:
393 description: Neighbor discovery neighbor advertisements.
394 type: bool
395 nd_ns:
396 description: Neighbor discovery neighbor solicitations.
397 type: bool
398 next_header:
399 description: Parameter next header problems.
400 type: bool
401 no_admin:
402 description: Administration prohibited destination.
403 type: bool
404 no_route:
405 description: No route to destination.
406 type: bool
407 packet_too_big:
408 description: Packet too big.
409 type: bool
410 parameter_option:
411 description: Parameter option problems.
412 type: bool
413 parameter_problem:
414 description: All parameter problems.
415 type: bool
416 port_unreachable:
417 description: Port unreachable.
418 type: bool
419 reassembly_timeout:
420 description: Reassembly timeout.
421 type: bool
422 renum_command:
423 description: Router renumbering command.
424 type: bool
425 renum_result:
426 description: Router renumbering result.
427 type: bool
428 renum_seq_number:
429 description: Router renumbering sequence number reset.
430 type: bool
431 router_advertisement:
432 description: Neighbor discovery router advertisements.
433 type: bool
434 router_renumbering:
435 description: All router renumbering.
436 type: bool
437 router_solicitation:
438 description: Neighbor discovery router solicitations.
439 type: bool
440 time_exceeded:
441 description: All time exceeded.
442 type: bool
443 unreachable:
444 description: All unreachable.
445 type: bool
446 telemetry_path:
447 description: IPT enabled.
448 type: bool
449 telemetry_queue:
450 description: Flow of interest for BDC/HDC.
451 type: bool
452 tcp:
453 description: TCP flags.
454 type: dict
455 suboptions:
456 ack:
457 description: Match on the ACK bit
458 type: bool
459 established:
460 description: Match established connections
461 type: bool
462 fin:
463 description: Match on the FIN bit
464 type: bool
465 psh:
466 description: Match on the PSH bit
467 type: bool
468 rst:
469 description: Match on the RST bit
470 type: bool
471 syn:
472 description: Match on the SYN bit
473 type: bool
474 urg:
475 description: Match on the URG bit
476 type: bool
477 igmp:
478 description: IGMP protocol options.
479 type: dict
480 suboptions:
481 dvmrp:
482 description: Distance Vector Multicast Routing Protocol
483 type: bool
484 host_query:
485 description: Host Query
486 type: bool
487 host_report:
488 description: Host Report
489 type: bool
490 state:
491 description:
492 - The state the configuration should be left in
493 type: str
494 choices:
495 - deleted
496 - gathered
497 - merged
498 - overridden
499 - rendered
500 - replaced
501 - parsed
502 default: merged
503
504 """
505 EXAMPLES = """
506 # Using merged
507
508 # Before state:
509 # -------------
510 # nxos-9k# show running-config | section '^ip(v6)* access-list'
511
512 - name: Merge provided ACLs configuration with device configuration
513 cisco.nxos.nxos_acls:
514 state: merged
515 config:
516 - afi: ipv4
517 acls:
518 - name: ACL1v4
519 aces:
520 - grant: deny
521 destination:
522 address: 192.0.2.64
523 wildcard_bits: 0.0.0.255
524 source:
525 any: true
526 port_protocol:
527 lt: 55
528 protocol: tcp
529 protocol_options:
530 tcp:
531 ack: true
532 fin: true
533 sequence: 50
534
535 - afi: ipv6
536 acls:
537 - name: ACL1v6
538 aces:
539 - grant: permit
540 sequence: 10
541 source:
542 any: true
543 destination:
544 prefix: 2001:db8:12::/32
545 protocol: sctp
546
547 # Task Output
548 # -----------
549 # before: []
550 #
551 # commands:
552 # - ip access-list ACL1v4
553 # - 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin
554 # - ipv6 access-list ACL1v6
555 # - 10 permit sctp any 2001:db8:12::/32
556 #
557 # after:
558 # - acls:
559 # - aces:
560 # - destination:
561 # prefix: 2001:db8:12::/32
562 # grant: permit
563 # protocol: sctp
564 # sequence: 10
565 # source:
566 # any: true
567 # name: ACL1v6
568 # afi: ipv6
569 # - acls:
570 # - aces:
571 # - destination:
572 # address: 192.0.2.64
573 # wildcard_bits: 0.0.0.255
574 # grant: deny
575 # protocol: tcp
576 # protocol_options:
577 # tcp:
578 # ack: true
579 # fin: true
580 # sequence: 50
581 # source:
582 # any: true
583 # port_protocol:
584 # lt: '55'
585 # name: ACL1v4
586 # afi: ipv4
587
588
589 # After state:
590 # ------------
591 #
592 # nxos-9k# show running-config | section '^ip(v6)* access-list'
593 # ip access-list ACL1v4
594 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin
595 # ipv6 access-list ACL1v6
596 # 10 permit sctp any any
597
598 # Using replaced
599
600 # Before state:
601 # ----------------
602 # nxos-9k# show running-config | section '^ip(v6)* access-list'
603 # ip access-list ACL1v4
604 # 10 permit ip any any
605 # 20 deny udp any any
606 # ip access-list ACL2v4
607 # 10 permit ahp 192.0.2.0 0.0.0.255 any
608 # ipv6 access-list ACL1v6
609 # 10 permit sctp any any
610 # 20 remark IPv6 ACL
611 # ipv6 access-list ACL2v6
612 # 10 deny ipv6 any 2001:db8:3000::/36
613 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128
614
615 - name: Replace existing ACL configuration with provided configuration
616 cisco.nxos.nxos_acls:
617 config:
618 - afi: ipv4
619 - afi: ipv6
620 acls:
621 - name: ACL1v6
622 aces:
623 - sequence: 20
624 grant: permit
625 source:
626 any: true
627 destination:
628 any: true
629 protocol: pim
630
631 - remark: Replaced ACE
632 - name: ACL2v6
633 state: replaced
634
635 # Task Output
636 # -----------
637 # before:
638 # - acls:
639 # - aces:
640 # - destination:
641 # any: true
642 # grant: permit
643 # protocol: sctp
644 # sequence: 10
645 # source:
646 # any: true
647 # - remark: IPv6 ACL
648 # sequence: 20
649 # name: ACL1v6
650 # - aces:
651 # - destination:
652 # prefix: 2001:db8:3000::/36
653 # grant: deny
654 # protocol: ipv6
655 # sequence: 10
656 # source:
657 # any: true
658 # - destination:
659 # host: 2001:db8:2000:ab::2
660 # grant: permit
661 # protocol: tcp
662 # sequence: 20
663 # source:
664 # host: 2001:db8:2000:2::2
665 # name: ACL2v6
666 # afi: ipv6
667 # - acls:
668 # - aces:
669 # - destination:
670 # any: true
671 # grant: permit
672 # protocol: ip
673 # sequence: 10
674 # source:
675 # any: true
676 # - destination:
677 # any: true
678 # grant: deny
679 # protocol: udp
680 # sequence: 20
681 # source:
682 # any: true
683 # name: ACL1v4
684 # - aces:
685 # - destination:
686 # any: true
687 # grant: permit
688 # protocol: ahp
689 # sequence: 10
690 # source:
691 # address: 192.0.2.0
692 # wildcard_bits: 0.0.0.255
693 # name: ACL2v4
694 # afi: ipv4
695 #
696 # commands:
697 # - no ip access-list ACL1v4
698 # - no ip access-list ACL2v4
699 # - ipv6 access-list ACL1v6
700 # - no 10 permit sctp any any
701 # - no 20 remark IPv6 ACL
702 # - remark Replaced ACE
703 # - 20 permit pim any any
704 # - ipv6 access-list ACL2v6
705 # - no 10 deny ipv6 any 2001:db8:3000::/36
706 # - no 20 permit tcp host 2001:db8:2000:2::2 host 2001:db8:2000:ab::2
707 #
708 # after:
709 # - acls:
710 # - aces:
711 # - remark: Replaced ACE
712 # sequence: 10
713 # - destination:
714 # any: true
715 # grant: permit
716 # protocol: pim
717 # sequence: 20
718 # source:
719 # any: true
720 # name: ACL1v6
721 # - name: ACL2v6
722 # afi: ipv6
723
724 # After state:
725 # ---------------
726 # nxos-9k# show running-config | section '^ip(v6)* access-list'
727 # ipv6 access-list ACL1v6
728 # 10 remark Replaced ACE
729 # 20 permit pim any any
730 # ipv6 access-list ACL2v6
731
732 # Using overridden
733
734 # Before state:
735 # ----------------
736 # nxos-9k# show running-config | section '^ip(v6)* access-list'
737 # ip access-list ACL1v4
738 # 10 permit ip any any
739 # 20 deny udp any any
740 # ip access-list ACL2v4
741 # 10 permit ahp 192.0.2.0 0.0.0.255 any
742 # ipv6 access-list ACL1v6
743 # 10 permit sctp any any
744 # 20 remark IPv6 ACL
745 # ipv6 access-list ACL2v6
746 # 10 deny ipv6 any 2001:db8:3000::/36
747 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128
748
749 - name: Override existing configuration with provided configuration
750 cisco.nxos.nxos_acls:
751 config:
752 - afi: ipv4
753 acls:
754 - name: NewACL
755 aces:
756 - grant: deny
757 source:
758 address: 192.0.2.0
759 wildcard_bits: 0.0.255.255
760 destination:
761 any: true
762 protocol: eigrp
763 - remark: Example for overridden state
764 state: overridden
765
766 # Task Output
767 # -----------
768 #
769 # before:
770 # - acls:
771 # - aces:
772 # - destination:
773 # any: true
774 # grant: permit
775 # protocol: sctp
776 # sequence: 10
777 # source:
778 # any: true
779 # - remark: IPv6 ACL
780 # sequence: 20
781 # name: ACL1v6
782 # - aces:
783 # - destination:
784 # prefix: 2001:db8:3000::/36
785 # grant: deny
786 # protocol: ipv6
787 # sequence: 10
788 # source:
789 # any: true
790 # - destination:
791 # host: 2001:db8:2000:ab::2
792 # grant: permit
793 # protocol: tcp
794 # sequence: 20
795 # source:
796 # host: 2001:db8:2000:2::2
797 # name: ACL2v6
798 # afi: ipv6
799 # - acls:
800 # - aces:
801 # - destination:
802 # any: true
803 # grant: permit
804 # protocol: ip
805 # sequence: 10
806 # source:
807 # any: true
808 # - destination:
809 # any: true
810 # grant: deny
811 # protocol: udp
812 # sequence: 20
813 # source:
814 # any: true
815 # name: ACL1v4
816 # - aces:
817 # - destination:
818 # any: true
819 # grant: permit
820 # protocol: ahp
821 # sequence: 10
822 # source:
823 # address: 192.0.2.0
824 # wildcard_bits: 0.0.0.255
825 # name: ACL2v4
826 # afi: ipv4
827 #
828 # commands:
829 # - no ipv6 access-list ACL1v6
830 # - no ipv6 access-list ACL2v6
831 # - no ip access-list ACL1v4
832 # - no ip access-list ACL2v4
833 # - ip access-list NewACL
834 # - deny eigrp 192.0.2.0 0.0.255.255 any
835 # - remark Example for overridden state
836 #
837 # after:
838 # - acls:
839 # - aces:
840 # - destination:
841 # any: true
842 # grant: deny
843 # protocol: eigrp
844 # sequence: 10
845 # source:
846 # address: 192.0.2.0
847 # wildcard_bits: 0.0.255.255
848 # - remark: Example for overridden state
849 # sequence: 20
850 # name: NewACL
851 # afi: ipv4
852
853 # After state:
854 # ------------
855 # nxos-9k# show running-config | section '^ip(v6)* access-list'
856 # ip access-list NewACL
857 # 10 deny eigrp 192.0.2.0 0.0.255.255 any
858 # 20 remark Example for overridden state
859
860 # Using deleted - delete all
861 #
862 # Before state:
863 # -------------
864 # nxos-9k# show running-config | section '^ip(v6)* access-list'
865 # ip access-list ACL1v4
866 # 10 permit ip any any
867 # 20 deny udp any any
868 # ip access-list ACL2v4
869 # 10 permit ahp 192.0.2.0 0.0.0.255 any
870 # ip access-list ACL1v6
871 # 10 permit sctp any any
872 # 20 remark IPv6 ACL
873 # ip access-list ACL2v6
874 # 10 deny ipv6 any 2001:db8:3000::/36
875 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128
876
877 - name: Delete all ACLs
878 cisco.nxos.nxos_acls:
879 state: deleted
880
881 # Task Output
882 # -----------
883 #
884 # before:
885 # - acls:
886 # - aces:
887 # - destination:
888 # any: true
889 # grant: permit
890 # protocol: sctp
891 # sequence: 10
892 # source:
893 # any: true
894 # - remark: IPv6 ACL
895 # sequence: 20
896 # name: ACL1v6
897 # - aces:
898 # - destination:
899 # prefix: 2001:db8:3000::/36
900 # grant: deny
901 # protocol: ipv6
902 # sequence: 10
903 # source:
904 # any: true
905 # - destination:
906 # host: 2001:db8:2000:ab::2
907 # grant: permit
908 # protocol: tcp
909 # sequence: 20
910 # source:
911 # host: 2001:db8:2000:2::2
912 # name: ACL2v6
913 # afi: ipv6
914 # - acls:
915 # - aces:
916 # - destination:
917 # any: true
918 # grant: permit
919 # protocol: ip
920 # sequence: 10
921 # source:
922 # any: true
923 # - destination:
924 # any: true
925 # grant: deny
926 # protocol: udp
927 # sequence: 20
928 # source:
929 # any: true
930 # name: ACL1v4
931 # - aces:
932 # - destination:
933 # any: true
934 # grant: permit
935 # protocol: ahp
936 # sequence: 10
937 # source:
938 # address: 192.0.2.0
939 # wildcard_bits: 0.0.0.255
940 # name: ACL2v4
941 # afi: ipv4
942 #
943 # commands:
944 # - no ip access-list ACL1v4
945 # - no ip access-list ACL2v4
946 # - no ipv6 access-list ACL1v6
947 # - no ipv6 access-list ACL2v6
948 #
949 # after: []
950
951
952 # After state:
953 # -----------
954 # nxos-9k# show running-config | section '^ip(v6)* access-list'
955 #
956
957 # Using deleted - delete AFI
958
959 # Before state:
960 # -------------
961 # nxos-9k# show running-config | section '^ip(v6)* access-list'
962 # ip access-list ACL1v4
963 # 10 permit ip any any
964 # 20 deny udp any any
965 # ip access-list ACL2v4
966 # 10 permit ahp 192.0.2.0 0.0.0.255 any
967 # ip access-list ACL1v6
968 # 10 permit sctp any any
969 # 20 remark IPv6 ACL
970 # ip access-list ACL2v6
971 # 10 deny ipv6 any 2001:db8:3000::/36
972 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128
973
974 - name: Delete all ACLs in given AFI
975 cisco.nxos.nxos_acls:
976 config:
977 - afi: ipv4
978 state: deleted
979
980 # Task Output
981 # -----------
982 #
983 # before:
984 # - acls:
985 # - aces:
986 # - destination:
987 # any: true
988 # grant: permit
989 # protocol: sctp
990 # sequence: 10
991 # source:
992 # any: true
993 # - remark: IPv6 ACL
994 # sequence: 20
995 # name: ACL1v6
996 # - aces:
997 # - destination:
998 # prefix: 2001:db8:3000::/36
999 # grant: deny
1000 # protocol: ipv6
1001 # sequence: 10
1002 # source:
1003 # any: true
1004 # - destination:
1005 # host: 2001:db8:2000:ab::2
1006 # grant: permit
1007 # protocol: tcp
1008 # sequence: 20
1009 # source:
1010 # host: 2001:db8:2000:2::2
1011 # name: ACL2v6
1012 # afi: ipv6
1013 # - acls:
1014 # - aces:
1015 # - destination:
1016 # any: true
1017 # grant: permit
1018 # protocol: ip
1019 # sequence: 10
1020 # source:
1021 # any: true
1022 # - destination:
1023 # any: true
1024 # grant: deny
1025 # protocol: udp
1026 # sequence: 20
1027 # source:
1028 # any: true
1029 # name: ACL1v4
1030 # - aces:
1031 # - destination:
1032 # any: true
1033 # grant: permit
1034 # protocol: ahp
1035 # sequence: 10
1036 # source:
1037 # address: 192.0.2.0
1038 # wildcard_bits: 0.0.0.255
1039 # name: ACL2v4
1040 # afi: ipv4
1041 #
1042 # commands:
1043 # - no ip access-list ACL1v4
1044 # - no ip access-list ACL2v4
1045 #
1046 # after:
1047 # - acls:
1048 # - aces:
1049 # - destination:
1050 # any: true
1051 # grant: permit
1052 # protocol: sctp
1053 # sequence: 10
1054 # source:
1055 # any: true
1056 # - remark: IPv6 ACL
1057 # sequence: 20
1058 # name: ACL1v6
1059 # - aces:
1060 # - destination:
1061 # prefix: 2001:db8:3000::/36
1062 # grant: deny
1063 # protocol: ipv6
1064 # sequence: 10
1065 # source:
1066 # any: true
1067 # - destination:
1068 # host: 2001:db8:2000:ab::2
1069 # grant: permit
1070 # protocol: tcp
1071 # sequence: 20
1072 # source:
1073 # host: 2001:db8:2000:2::2
1074 # name: ACL2v6
1075 # afi: ipv6
1076
1077 # After state:
1078 # ------------
1079 # nxos-9k# show running-config | section '^ip(v6)* access-list'
1080 # ip access-list ACL1v6
1081 # 10 permit sctp any any
1082 # 20 remark IPv6 ACL
1083 # ip access-list ACL2v6
1084 # 10 deny ipv6 any 2001:db8:3000::/36
1085 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128
1086
1087 # Using deleted - delete ACLs
1088
1089 # Before state:
1090 # -------------
1091 # nxos-9k# show running-config | section '^ip(v6)* access-list'
1092 # ip access-list ACL1v4
1093 # 10 permit ip any any
1094 # 20 deny udp any any
1095 # ip access-list ACL2v4
1096 # 10 permit ahp 192.0.2.0 0.0.0.255 any
1097 # ipv6 access-list ACL1v6
1098 # 10 permit sctp any any
1099 # 20 remark IPv6 ACL
1100 # ipv6 access-list ACL2v6
1101 # 10 deny ipv6 any 2001:db8:3000::/36
1102 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128
1103
1104 - name: Delete specific ACLs
1105 cisco.nxos.nxos_acls:
1106 state: deleted
1107 config:
1108 - afi: ipv4
1109 acls:
1110 - name: ACL1v4
1111 - name: ACL2v4
1112 - afi: ipv6
1113 acls:
1114 - name: ACL1v6
1115
1116 # Task Output
1117 # -----------
1118 #
1119 # before:
1120 # - acls:
1121 # - aces:
1122 # - destination:
1123 # any: true
1124 # grant: permit
1125 # protocol: sctp
1126 # sequence: 10
1127 # source:
1128 # any: true
1129 # - remark: IPv6 ACL
1130 # sequence: 20
1131 # name: ACL1v6
1132 # - aces:
1133 # - destination:
1134 # prefix: 2001:db8:3000::/36
1135 # grant: deny
1136 # protocol: ipv6
1137 # sequence: 10
1138 # source:
1139 # any: true
1140 # - destination:
1141 # host: 2001:db8:2000:ab::2
1142 # grant: permit
1143 # protocol: tcp
1144 # sequence: 20
1145 # source:
1146 # host: 2001:db8:2000:2::2
1147 # name: ACL2v6
1148 # afi: ipv6
1149 # - acls:
1150 # - aces:
1151 # - destination:
1152 # any: true
1153 # grant: permit
1154 # protocol: ip
1155 # sequence: 10
1156 # source:
1157 # any: true
1158 # - destination:
1159 # any: true
1160 # grant: deny
1161 # protocol: udp
1162 # sequence: 20
1163 # source:
1164 # any: true
1165 # name: ACL1v4
1166 # - aces:
1167 # - destination:
1168 # any: true
1169 # grant: permit
1170 # protocol: ahp
1171 # sequence: 10
1172 # source:
1173 # address: 192.0.2.0
1174 # wildcard_bits: 0.0.0.255
1175 # name: ACL2v4
1176 # afi: ipv4
1177 #
1178 # commands:
1179 # - no ip access-list ACL1v4
1180 # - no ip access-list ACL2v4
1181 # - no ipv6 access-list ACL1v6
1182 #
1183 # after:
1184 # - acls:
1185 # - aces:
1186 # - destination:
1187 # prefix: 2001:db8:3000::/36
1188 # grant: deny
1189 # protocol: ipv6
1190 # sequence: 10
1191 # source:
1192 # any: true
1193 # - destination:
1194 # host: 2001:db8:2000:ab::2
1195 # grant: permit
1196 # protocol: tcp
1197 # sequence: 20
1198 # source:
1199 # host: 2001:db8:2000:2::2
1200 # name: ACL2v6
1201 # afi: ipv6
1202
1203 # After state:
1204 # ------------
1205 # nxos-9k# show running-config | section '^ip(v6)* access-list'
1206 # ipv6 access-list ACL2v6
1207 # 10 deny ipv6 any 2001:db8:3000::/36
1208 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128
1209
1210 # Using parsed
1211
1212 - name: Parse given config to structured data
1213 cisco.nxos.nxos_acls:
1214 running_config: |
1215 ip access-list ACL1v4
1216 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin
1217 ipv6 access-list ACL1v6
1218 10 permit sctp any any
1219 state: parsed
1220
1221 # Task Output
1222 # ------------
1223 #
1224 # parsed:
1225 # - afi: ipv4
1226 # acls:
1227 # - name: ACL1v4
1228 # aces:
1229 # - grant: deny
1230 # destination:
1231 # address: 192.0.2.64
1232 # wildcard_bits: 0.0.0.255
1233 # source:
1234 # any: true
1235 # port_protocol:
1236 # lt: 55
1237 # protocol: tcp
1238 # protocol_options:
1239 # tcp:
1240 # ack: true
1241 # fin: true
1242 # sequence: 50
1243 #
1244 # - afi: ipv6
1245 # acls:
1246 # - name: ACL1v6
1247 # aces:
1248 # - grant: permit
1249 # sequence: 10
1250 # source:
1251 # any: true
1252 # destination:
1253 # prefix: 2001:db8:12::/32
1254 # protocol: sctp
1255
1256
1257 # Using gathered:
1258
1259 # Before state:
1260 # ------------
1261 # nxos-9k# show running-config | section '^ip(v6)* access-list'
1262 # ip access-list ACL1v4
1263 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin
1264 # ipv6 access-list ACL1v6
1265 # 10 permit sctp any any
1266
1267 - name: Gather existing configuration
1268 cisco.nxos.nxos_acls:
1269 state: gathered
1270
1271 # Task Output
1272 # -----------
1273 #
1274 # gathered:
1275 # - afi: ipv4
1276 # acls:
1277 # - name: ACL1v4
1278 # aces:
1279 # - grant: deny
1280 # destination:
1281 # address: 192.0.2.64
1282 # wildcard_bits: 0.0.0.255
1283 # source:
1284 # any: true
1285 # port_protocol:
1286 # lt: 55
1287 # protocol: tcp
1288 # protocol_options:
1289 # tcp:
1290 # ack: true
1291 # fin: true
1292 # sequence: 50
1293
1294 # - afi: ipv6
1295 # acls:
1296 # - name: ACL1v6
1297 # aces:
1298 # - grant: permit
1299 # sequence: 10
1300 # source:
1301 # any: true
1302 # destination:
1303 # prefix: 2001:db8:12::/32
1304 # protocol: sctp
1305
1306
1307 # Using rendered
1308
1309 - name: Render required configuration to be pushed to the device
1310 cisco.nxos.nxos_acls:
1311 config:
1312 - afi: ipv4
1313 acls:
1314 - name: ACL1v4
1315 aces:
1316 - grant: deny
1317 destination:
1318 address: 192.0.2.64
1319 wildcard_bits: 0.0.0.255
1320 source:
1321 any: true
1322 port_protocol:
1323 lt: 55
1324 protocol: tcp
1325 protocol_options:
1326 tcp:
1327 ack: true
1328 fin: true
1329 sequence: 50
1330 - afi: ipv6
1331 acls:
1332 - name: ACL1v6
1333 aces:
1334 - grant: permit
1335 sequence: 10
1336 source:
1337 any: true
1338 destination:
1339 prefix: '2001:db8:12::/32'
1340 protocol: sctp
1341 state: rendered
1342
1343
1344 # Task Output
1345 # -----------
1346 #
1347 # rendered:
1348 # ip access-list ACL1v4
1349 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin
1350 # ipv6 access-list ACL1v6
1351 # 10 permit sctp any any
1352 """
1353 RETURN = """
1354 before:
1355 description: The configuration prior to the model invocation.
1356 returned: always
1357 type: dict
1358 sample: >
1359 The configuration returned will always be in the same format
1360 of the parameters above.
1361 after:
1362 description: The resulting configuration model invocation.
1363 returned: when changed
1364 type: dict
1365 sample: >
1366 The configuration returned will always be in the same format
1367 of the parameters above.
1368 commands:
1369 description: The set of commands pushed to the remote device.
1370 returned: always
1371 type: list
1372 sample:
1373 - ip access-list ACL1v4
1374 - 10 permit ip any any precedence critical log
1375 - 20 deny tcp any lt smtp host 192.0.2.64 ack fin
1376 rendered:
1377 description: The provided configuration in the task rendered in device-native format (offline).
1378 returned: when I(state) is C(rendered)
1379 type: list
1380 sample:
1381 - ip access-list ACL1v4
1382 - 10 permit ip any any precedence critical log
1383 - 20 deny tcp any lt smtp host 192.0.2.64 ack fin
1384 gathered:
1385 description: Facts about the network resource gathered from the remote device as structured data.
1386 returned: when I(state) is C(gathered)
1387 type: list
1388 sample: >
1389 This output will always be in the same format as the
1390 module argspec.
1391 parsed:
1392 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
1393 returned: when I(state) is C(parsed)
1394 type: list
1395 sample: >
1396 This output will always be in the same format as the
1397 module argspec.
1398 """
1399
1400 from ansible.module_utils.basic import AnsibleModule
1401
1402 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.acls.acls import (
1403 AclsArgs,
1404 )
1405 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.acls.acls import Acls
1406
1407
1408 def main():
1409 """
1410 Main entry point for module execution
1411
1412 :returns: the result form module invocation
1413 """
1414 module = AnsibleModule(argument_spec=AclsArgs.argument_spec, supports_check_mode=True)
1415
1416 result = Acls(module).execute_module()
1417 module.exit_json(**result)
1418
1419
1420 if __name__ == "__main__":
1421 main()