Debian Codegraph @

ansible_collections/cisco/iosxr/plugins/modules/iosxr_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 """
26 The module file for iosxr_acls
27 """
28
29 from __future__ import absolute_import, division, print_function
30
31
32 __metaclass__ = type
33
34
35 DOCUMENTATION = """
36 module: iosxr_acls
37 short_description: Resource module to configure ACLs.
38 description:
39 - This module manages Access Control Lists (ACLs) on devices running IOS-XR.
40 version_added: 1.0.0
41 author: Nilashish Chakraborty (@NilashishC)
42 options:
43 config:
44 description: A list of dictionaries specifying ACL configurations.
45 type: list
46 elements: dict
47 suboptions:
48 afi:
49 description:
50 - The Address Family Indicator (AFI) for the Access Control Lists (ACL).
51 type: str
52 required: true
53 choices:
54 - ipv4
55 - ipv6
56 acls:
57 description:
58 - A list of Access Control Lists (ACLs).
59 type: list
60 elements: dict
61 suboptions:
62 name:
63 description:
64 - The name of the Access Control List (ACL).
65 type: str
66 aces:
67 description:
68 - List of Access Control Entries (ACEs) for this Access Control List (ACL).
69 type: list
70 elements: dict
71 suboptions:
72 sequence:
73 description:
74 - Sequence number for the Access Control Entry (ACE).
75 type: int
76 grant:
77 description:
78 - Forward or drop packets matching the Access Control Entry (ACE).
79 type: str
80 choices:
81 - permit
82 - deny
83 remark:
84 description:
85 - Comments or a description for the access list.
86 type: str
87 line:
88 description:
89 - An ACE excluding the sequence number.
90 - This key is mutually exclusive with all the other attributes except
91 'sequence'.
92 - When used with other attributes, the value of this key will get
93 precedence and the other keys will be ignored.
94 - This should only be used when an attribute doesn't exist in the
95 argspec but is valid for the device.
96 - For fact gathering, any ACE that is not fully parsed, will show
97 up as a value of this attribute, excluding the sequence number,
98 which will be populated as value of the sequence key.
99 type: str
100 aliases:
101 - ace
102 source:
103 description:
104 - Specifies the packet source.
105 type: dict
106 suboptions:
107 host:
108 description:
109 - The host IP address to match.
110 type: str
111 net_group:
112 description:
113 - Name of net-group.
114 type: str
115 port_group:
116 description:
117 - Name of port-group.
118 type: str
119 address:
120 description:
121 - The source IP address to match.
122 type: str
123 wildcard_bits:
124 description:
125 - The Wildcard bits to apply to source address.
126 type: str
127 any:
128 description:
129 - Match any source address.
130 type: bool
131 prefix:
132 description:
133 - Source network prefix.
134 type: str
135 port_protocol:
136 description:
137 - Specify the source port or protocol.
138 type: dict
139 suboptions:
140 eq:
141 description:
142 - Match only packets on a given port number.
143 type: str
144 gt:
145 description:
146 - Match only packets with a greater port number.
147 type: str
148 lt:
149 description:
150 - Match only packets with a lower port number.
151 type: str
152 neq:
153 description:
154 - Match only packets not on a given port number.
155 type: str
156 range:
157 description:
158 - Match only packets in the range of port numbers
159 type: dict
160 suboptions:
161 start:
162 description:
163 - Specify the start of the port range
164 type: str
165 end:
166 description:
167 - Specify the end of the port range
168 type: str
169 destination:
170 description:
171 - Specifies the packet destination.
172 type: dict
173 suboptions:
174 host:
175 description:
176 - The host IP address to match.
177 type: str
178 net_group:
179 description:
180 - Name of net-group.
181 type: str
182 port_group:
183 description:
184 - Name of port-group.
185 type: str
186 address:
187 description:
188 - The destination IP address to match.
189 type: str
190 wildcard_bits:
191 description:
192 - The Wildcard bits to apply to destination address.
193 type: str
194 any:
195 description:
196 - Match any destination address.
197 type: bool
198 prefix:
199 description:
200 - Destination network prefix.
201 type: str
202 port_protocol:
203 description:
204 - Specify the source port or protocol.
205 type: dict
206 suboptions:
207 eq:
208 description:
209 - Match only packets on a given port number.
210 type: str
211 gt:
212 description:
213 - Match only packets with a greater port number.
214 type: str
215 lt:
216 description:
217 - Match only packets with a lower port number.
218 type: str
219 neq:
220 description:
221 - Match only packets not on a given port number.
222 type: str
223 range:
224 description:
225 - Match only packets in the range of port numbers
226 type: dict
227 suboptions:
228 start:
229 description:
230 - Specify the start of the port range
231 type: str
232 end:
233 description:
234 - Specify the end of the port range
235 type: str
236 protocol:
237 description:
238 - Specify the protocol to match.
239 - Refer to vendor documentation for valid values.
240 type: str
241 protocol_options:
242 description:
243 - Additional suboptions for the protocol.
244 type: dict
245 suboptions:
246 icmpv6:
247 description: Internet Control Message Protocol settings for IPv6.
248 type: dict
249 suboptions:
250 address_unreachable:
251 description: Address Unreachable
252 type: bool
253 administratively_prohibited:
254 description: Administratively Prohibited
255 type: bool
256 beyond_scope_of_source_address:
257 description: Administratively Prohibited
258 type: bool
259 destination_unreachable:
260 description: Destination Unreachable
261 type: bool
262 echo:
263 description: Echo
264 type: bool
265 echo_reply:
266 description: Echo Reply
267 type: bool
268 erroneous_header_field:
269 description: Erroneous Header Field
270 type: bool
271 group_membership_query:
272 description: Group Membership Query
273 type: bool
274 group_membership_report:
275 description: Group Membership Report
276 type: bool
277 group_membership_termination:
278 description: Group Membership Termination
279 type: bool
280 host_unreachable:
281 description: Host Unreachable
282 type: bool
283 nd_na:
284 description: Neighbor Discovery - Neighbor Advertisement
285 type: bool
286 nd_ns:
287 description: Neighbor Discovery - Neighbor Solicitation
288 type: bool
289 neighbor_redirect:
290 description: Neighbor Redirect
291 type: bool
292 no_route_to_destination:
293 description: No Route To Destination
294 type: bool
295 node_information_request_is_refused:
296 description: Node Information Request Is Refused
297 type: bool
298 node_information_successful_reply:
299 description: Node Information Successful Reply
300 type: bool
301 packet_too_big:
302 description: Packet Too Big
303 type: bool
304 parameter_problem:
305 description: Parameter Problem
306 type: bool
307 port_unreachable:
308 description: Port Unreachable
309 type: bool
310 query_subject_is_IPv4address:
311 description: Query Subject Is IPv4 address
312 type: bool
313 query_subject_is_IPv6address:
314 description: Query Subject Is IPv6 address
315 type: bool
316 query_subject_is_domainname:
317 description: Query Subject Is Domain name
318 type: bool
319 reassembly_timeout:
320 description: Reassembly Timeout
321 type: bool
322 redirect:
323 description: Redirect
324 type: bool
325 router_advertisement:
326 description: Router Advertisement
327 type: bool
328 router_renumbering:
329 description: Router Renumbering
330 type: bool
331 router_solicitation:
332 description: Router Solicitation
333 type: bool
334 rr_command:
335 description: RR Command
336 type: bool
337 rr_result:
338 description: RR Result
339 type: bool
340 rr_seqnum_reset:
341 description: RR Seqnum Reset
342 type: bool
343 time_exceeded:
344 description: Time Exceeded
345 type: bool
346 ttl_exceeded:
347 description: TTL Exceeded
348 type: bool
349 unknown_query_type:
350 description: Unknown Query Type
351 type: bool
352 unreachable:
353 description: Unreachable
354 type: bool
355 unrecognized_next_header:
356 description: Unrecognized Next Header
357 type: bool
358 unrecognized_option:
359 description: Unrecognized Option
360 type: bool
361 whoareyou_reply:
362 description: Whoareyou Reply
363 type: bool
364 whoareyou_request:
365 description: Whoareyou Request
366 type: bool
367 icmp:
368 description: Internet Control Message Protocol settings.
369 type: dict
370 suboptions:
371 administratively_prohibited:
372 description: Administratively prohibited
373 type: bool
374 alternate_address:
375 description: Alternate address
376 type: bool
377 conversion_error:
378 description: Datagram conversion
379 type: bool
380 dod_host_prohibited:
381 description: Host prohibited
382 type: bool
383 dod_net_prohibited:
384 description: Net prohibited
385 type: bool
386 echo:
387 description: Echo (ping)
388 type: bool
389 echo_reply:
390 description: Echo reply
391 type: bool
392 general_parameter_problem:
393 description: Parameter problem
394 type: bool
395 host_isolated:
396 description: Host isolated
397 type: bool
398 host_precedence_unreachable:
399 description: Host unreachable for precedence
400 type: bool
401 host_redirect:
402 description: Host redirect
403 type: bool
404 host_tos_redirect:
405 description: Host redirect for TOS
406 type: bool
407 host_tos_unreachable:
408 description: Host unreachable for TOS
409 type: bool
410 host_unknown:
411 description: Host unknown
412 type: bool
413 host_unreachable:
414 description: Host unreachable
415 type: bool
416 information_reply:
417 description: Information replies
418 type: bool
419 information_request:
420 description: Information requests
421 type: bool
422 mask_reply:
423 description: Mask replies
424 type: bool
425 mask_request:
426 description: Mask requests
427 type: bool
428 mobile_redirect:
429 description: Mobile host redirect
430 type: bool
431 net_redirect:
432 description: Network redirect
433 type: bool
434 net_tos_redirect:
435 description: Net redirect for TOS
436 type: bool
437 net_tos_unreachable:
438 description: Network unreachable for TOS
439 type: bool
440 net_unreachable:
441 description: Net unreachable
442 type: bool
443 network_unknown:
444 description: Network unknown
445 type: bool
446 no_room_for_option:
447 description: Parameter required but no room
448 type: bool
449 option_missing:
450 description: Parameter required but not present
451 type: bool
452 packet_too_big:
453 description: Fragmentation needed and DF set
454 type: bool
455 parameter_problem:
456 description: All parameter problems
457 type: bool
458 port_unreachable:
459 description: Port unreachable
460 type: bool
461 precedence_unreachable:
462 description: Precedence cutoff
463 type: bool
464 protocol_unreachable:
465 description: Protocol unreachable
466 type: bool
467 reassembly_timeout:
468 description: Reassembly timeout
469 type: bool
470 redirect:
471 description: All redirects
472 type: bool
473 router_advertisement:
474 description: Router discovery advertisements
475 type: bool
476 router_solicitation:
477 description: Router discovery solicitations
478 type: bool
479 source_quench:
480 description: Source quenches
481 type: bool
482 source_route_failed:
483 description: Source route failed
484 type: bool
485 time_exceeded:
486 description: All time exceededs
487 type: bool
488 timestamp_reply:
489 description: Timestamp replies
490 type: bool
491 timestamp_request:
492 description: Timestamp requests
493 type: bool
494 traceroute:
495 description: Traceroute
496 type: bool
497 ttl_exceeded:
498 description: TTL exceeded
499 type: bool
500 unreachable:
501 description: All unreachables
502 type: bool
503 tcp:
504 description: Match TCP packet flags
505 type: dict
506 suboptions:
507 ack:
508 description: Match on the ACK bit
509 type: bool
510 established:
511 description: Match established connections
512 type: bool
513 fin:
514 description: Match on the FIN bit
515 type: bool
516 psh:
517 description: Match on the PSH bit
518 type: bool
519 rst:
520 description: Match on the RST bit
521 type: bool
522 syn:
523 description: Match on the SYN bit
524 type: bool
525 urg:
526 description: Match on the URG bit
527 type: bool
528 igmp:
529 description: Internet Group Management Protocol (IGMP) settings.
530 type: dict
531 suboptions:
532 dvmrp:
533 description: Match Distance Vector Multicast Routing Protocol
534 type: bool
535 host_query:
536 description: Match Host Query
537 type: bool
538 host_report:
539 description: Match Host Report
540 type: bool
541 pim:
542 description: Match Protocol Independent Multicast
543 type: bool
544 trace:
545 description: Multicast trace
546 type: bool
547 mtrace:
548 description: Match mtrace
549 type: bool
550 mtrace_response:
551 description: Match mtrace response
552 type: bool
553 dscp:
554 description:
555 - Match packets with given DSCP value.
556 type: dict
557 suboptions:
558 eq:
559 description: Match only packets on a given dscp value
560 type: str
561 gt:
562 description: Match only packets with a greater dscp value
563 type: str
564 lt:
565 description: Match only packets with a lower dscp value
566 type: str
567 neq:
568 description: Match only packets not on a given dscp value
569 type: str
570 range:
571 description: Match only packets in the range of dscp values
572 type: dict
573 suboptions:
574 start:
575 description: Start of the dscp range
576 type: str
577 end:
578 description: End of the dscp range
579 type: str
580 fragments:
581 description:
582 - Check non-intial fragments.
583 type: bool
584 packet_length:
585 description:
586 - Match packets given packet length.
587 type: dict
588 suboptions:
589 eq:
590 description: Match only packets on a given packet length
591 type: int
592 gt:
593 description: Match only packets with a greater packet length
594 type: int
595 lt:
596 description: Match only packets with a lower packet length
597 type: int
598 neq:
599 description: Match only packets not on a given packet length
600 type: int
601 range:
602 description: Match only packets in the range of packet lengths
603 type: dict
604 suboptions:
605 start:
606 description: Start of the packet length range
607 type: int
608 end:
609 description: End of the packet length range
610 type: int
611 precedence:
612 description: Match packets with given precedence value
613 type: str
614 ttl:
615 description: Match against specified TTL value.
616 type: dict
617 suboptions:
618 eq:
619 description: Match only packets with exact TTL value.
620 type: int
621 gt:
622 description: Match only packets with a greater TTL value.
623 type: int
624 lt:
625 description: Match only packets with a lower TTL value.
626 type: int
627 neq:
628 description: Match only packets that won't have the given TTL
629 value.
630 type: int
631 range:
632 description: Match only packets in the range of given TTL values.
633 type: dict
634 suboptions:
635 start:
636 description: Start of the TTL range.
637 type: int
638 end:
639 description: End of the TTL range.
640 type: int
641 log:
642 description:
643 - Enable/disable log matches against this entry.
644 type: bool
645 log_input:
646 description:
647 - Enable/disable log matches against this entry, including input interface.
648 type: bool
649 icmp_off:
650 description:
651 - Enable/disable the ICMP message for this entry.
652 type: bool
653 capture:
654 description:
655 - Capture matched packet.
656 type: bool
657 destopts:
658 description:
659 - Match if destination opts header is present.
660 type: bool
661 authen:
662 description:
663 - Match if authentication header is present.
664 type: bool
665 routing:
666 description:
667 - Match if routing header is present.
668 type: bool
669 hop_by_hop:
670 description:
671 - Match if hop-by-hop opts header is present.
672 type: bool
673 running_config:
674 description:
675 - The module, by default, will connect to the remote device and retrieve the current
676 running-config to use as a base for comparing against the contents of source.
677 There are times when it is not desirable to have the task get the current running-config
678 for every task in a playbook. The I(running_config) argument allows the implementer
679 to pass in the configuration to use as the base config for comparison. This
680 value of this option should be the output received from device by executing
681 command B(show running-config router static).
682 type: str
683 state:
684 description:
685 - The state the configuration should be left in.
686 type: str
687 choices:
688 - merged
689 - replaced
690 - overridden
691 - deleted
692 - gathered
693 - rendered
694 - parsed
695 default: merged
696
697 """
698 EXAMPLES = """
699 # Using merged to add new ACLs
700
701 # Before state:
702 # -------------
703
704 # RP/0/RP0/CPU0:ios#show access-lists afi-al
705 # Fri Sep 22 03:57:04.758 UTC
706 # ipv4 access-list acl_1
707 # 10 permit udp 192.168.1.0 0.0.0.255 any
708
709 - name: Merge the provided configuration with the existing running configuration
710 cisco.iosxr.iosxr_acls:
711 config:
712 - afi: ipv6
713 acls:
714 - name: acl6_1
715 aces:
716 - sequence: 10
717 grant: deny
718 protocol: tcp
719 source:
720 prefix: '2001:db8:1234::/48'
721 port_protocol:
722 range:
723 start: ftp
724 end: telnet
725 destination:
726 any: true
727 protocol_options:
728 tcp:
729 syn: true
730 ttl:
731 range:
732 start: 180
733 end: 250
734 routing: true
735 authen: true
736 log: true
737 - sequence: 20
738 grant: permit
739 protocol: icmpv6
740 source:
741 any: true
742 destination:
743 any: true
744 protocol_options:
745 icmpv6:
746 router_advertisement: true
747 precedence: network
748 destopts: true
749 - afi: ipv4
750 acls:
751 - name: acl_1
752 aces:
753 - sequence: 16
754 remark: TEST_ACL_1_REMARK
755 - sequence: 21
756 grant: permit
757 protocol: tcp
758 source:
759 host: 192.0.2.10
760 port_protocol:
761 range:
762 start: pop3
763 end: 121
764 destination:
765 address: 198.51.100.0
766 wildcard_bits: 0.0.0.15
767 protocol_options:
768 tcp:
769 rst: true
770 - sequence: 23
771 grant: deny
772 protocol: icmp
773 source:
774 any: true
775 destination:
776 prefix: 198.51.100.0/28
777 protocol_options:
778 icmp:
779 reassembly_timeout: true
780 dscp:
781 lt: af12
782 - name: acl_2
783 aces:
784 - sequence: 10
785 remark: TEST_ACL_2_REMARK
786 state: merged
787
788 # Task Output
789 # -----------
790 #
791 # before:
792 # - acls:
793 # - aces:
794 # - destination:
795 # any: true
796 # grant: permit
797 # protocol: udp
798 # sequence: 10
799 # source:
800 # address: 192.168.1.0
801 # wildcard_bits: 0.0.0.255
802 # name: acl_1
803 # afi: ipv4
804 #
805 # commands:
806 # - ipv6 access-list acl6_1
807 # - 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 authen routing log
808 # - 20 permit icmpv6 any any router-advertisement precedence network destopts
809 # - ipv4 access-list acl_1
810 # - 16 remark TEST_ACL_1_REMARK
811 # - 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
812 # - 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
813 # - ipv4 access-list acl_2
814 # - 10 remark TEST_ACL_2_REMARK
815 #
816 # after:
817 # - acls:
818 # - aces:
819 # - destination:
820 # any: true
821 # grant: permit
822 # protocol: udp
823 # sequence: 10
824 # source:
825 # address: 192.168.1.0
826 # wildcard_bits: 0.0.0.255
827 # - remark: TEST_ACL_1_REMARK
828 # sequence: 16
829 # - destination:
830 # address: 198.51.100.0
831 # wildcard_bits: 0.0.0.15
832 # grant: permit
833 # protocol: tcp
834 # protocol_options:
835 # tcp:
836 # rst: true
837 # sequence: 21
838 # source:
839 # host: 192.0.2.10
840 # port_protocol:
841 # range:
842 # end: '121'
843 # start: pop3
844 # - destination:
845 # address: 198.51.100.0
846 # wildcard_bits: 0.0.0.15
847 # dscp:
848 # lt: af12
849 # grant: deny
850 # protocol: icmp
851 # protocol_options:
852 # icmp:
853 # reassembly_timeout: true
854 # sequence: 23
855 # source:
856 # any: true
857 # name: acl_1
858 # - aces:
859 # - remark: TEST_ACL_2_REMARK
860 # sequence: 10
861 # name: acl_2
862 # afi: ipv4
863 # - acls:
864 # - aces:
865 # - authen: true
866 # destination:
867 # any: true
868 # grant: deny
869 # log: true
870 # protocol: tcp
871 # protocol_options:
872 # tcp:
873 # syn: true
874 # routing: true
875 # sequence: 10
876 # source:
877 # port_protocol:
878 # range:
879 # end: telnet
880 # start: ftp
881 # prefix: 2001:db8:1234::/48
882 # ttl:
883 # range:
884 # end: 250
885 # start: 180
886 # - destination:
887 # any: true
888 # destopts: true
889 # grant: permit
890 # precedence: network
891 # protocol: icmpv6
892 # protocol_options:
893 # icmpv6:
894 # router_advertisement: true
895 # sequence: 20
896 # source:
897 # any: true
898 # name: acl6_1
899 # afi: ipv6
900
901 # After state:
902 # -------------
903
904 # RP/0/RP0/CPU0:ios#show access-lists afi-all
905 # Fri Sep 22 04:35:19.977 UTC
906 # ipv4 access-list acl_1
907 # 10 permit udp 192.168.1.0 0.0.0.255 any
908 # 16 remark TEST_ACL_1_REMARK
909 # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
910 # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
911 # ipv4 access-list acl_2
912 # 10 remark TEST_ACL_2_REMARK
913 # ipv6 access-list acl6_1
914 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
915 # 20 permit icmpv6 any any router-advertisement precedence network destopts
916
917 # Using merged to update existing ACLs
918
919 # Before state:
920 # -------------
921
922 # RP/0/RP0/CPU0:ios#show access-lists afi-all
923 # Fri Sep 22 04:37:33.542 UTC
924 # ipv4 access-list acl_1
925 # 10 permit udp 192.168.1.0 0.0.0.255 any
926 # 16 remark TEST_ACL_1_REMARK
927 # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
928 # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
929 # ipv4 access-list acl_2
930 # 10 remark TEST_ACL_2_REMARK
931 # ipv6 access-list acl6_1
932 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
933 # 20 permit icmpv6 any any router-advertisement precedence network destopts
934
935 - name: Update existing ACEs
936 cisco.iosxr.iosxr_acls:
937 config:
938 - afi: ipv4
939 acls:
940 - name: acl_1
941 aces:
942 - sequence: 21
943 source:
944 prefix: 198.51.100.32/28
945 port_protocol:
946 range:
947 start: pop3
948 end: 121
949 protocol_options:
950 tcp:
951 syn: true
952 - sequence: 23
953 protocol_options:
954 icmp:
955 router_advertisement: true
956 dscp:
957 eq: af23
958
959 # Task Output
960 # -----------
961 #
962 # before:
963 # - acls:
964 # - aces:
965 # - destination:
966 # any: true
967 # grant: permit
968 # protocol: udp
969 # sequence: 10
970 # source:
971 # address: 192.168.1.0
972 # wildcard_bits: 0.0.0.255
973 # - remark: TEST_ACL_1_REMARK
974 # sequence: 16
975 # - destination:
976 # address: 198.51.100.0
977 # wildcard_bits: 0.0.0.15
978 # grant: permit
979 # protocol: tcp
980 # protocol_options:
981 # tcp:
982 # rst: true
983 # sequence: 21
984 # source:
985 # host: 192.0.2.10
986 # port_protocol:
987 # range:
988 # end: '121'
989 # start: pop3
990 # - destination:
991 # address: 198.51.100.0
992 # wildcard_bits: 0.0.0.15
993 # dscp:
994 # lt: af12
995 # grant: deny
996 # protocol: icmp
997 # protocol_options:
998 # icmp:
999 # reassembly_timeout: true
1000 # sequence: 23
1001 # source:
1002 # any: true
1003 # name: acl_1
1004 # - aces:
1005 # - remark: TEST_ACL_2_REMARK
1006 # sequence: 10
1007 # name: acl_2
1008 # afi: ipv4
1009 # - acls:
1010 # - aces:
1011 # - authen: true
1012 # destination:
1013 # any: true
1014 # grant: deny
1015 # log: true
1016 # protocol: tcp
1017 # protocol_options:
1018 # tcp:
1019 # syn: true
1020 # routing: true
1021 # sequence: 10
1022 # source:
1023 # port_protocol:
1024 # range:
1025 # end: telnet
1026 # start: ftp
1027 # prefix: 2001:db8:1234::/48
1028 # ttl:
1029 # range:
1030 # end: 250
1031 # start: 180
1032 # - destination:
1033 # any: true
1034 # destopts: true
1035 # grant: permit
1036 # precedence: network
1037 # protocol: icmpv6
1038 # protocol_options:
1039 # icmpv6:
1040 # router_advertisement: true
1041 # sequence: 20
1042 # source:
1043 # any: true
1044 # name: acl6_1
1045 # afi: ipv6
1046 #
1047 # commands:
1048 # - ipv4 access-list acl_1
1049 # - 21 permit tcp 198.51.100.32 0.0.0.15 range pop3 121 198.51.100.0 0.0.0.15 syn
1050 # - 23 deny icmp any 198.51.100.0 0.0.0.15 router-advertisement dscp eq af23
1051 # after:
1052 # - acls:
1053 # - aces:
1054 # - destination:
1055 # any: true
1056 # grant: permit
1057 # protocol: udp
1058 # sequence: 10
1059 # source:
1060 # address: 192.168.1.0
1061 # wildcard_bits: 0.0.0.255
1062 # - remark: TEST_ACL_1_REMARK
1063 # sequence: 16
1064 # - destination:
1065 # address: 198.51.100.0
1066 # wildcard_bits: 0.0.0.15
1067 # grant: permit
1068 # protocol: tcp
1069 # protocol_options:
1070 # tcp:
1071 # syn: true
1072 # sequence: 21
1073 # source:
1074 # address: 198.51.100.32
1075 # port_protocol:
1076 # range:
1077 # end: '121'
1078 # start: pop3
1079 # wildcard_bits: 0.0.0.15
1080 # - destination:
1081 # address: 198.51.100.0
1082 # wildcard_bits: 0.0.0.15
1083 # dscp:
1084 # eq: af23
1085 # grant: deny
1086 # protocol: icmp
1087 # protocol_options:
1088 # icmp:
1089 # router_advertisement: true
1090 # sequence: 23
1091 # source:
1092 # any: true
1093 # name: acl_1
1094 # - aces:
1095 # - remark: TEST_ACL_2_REMARK
1096 # sequence: 10
1097 # name: acl_2
1098 # afi: ipv4
1099 # - acls:
1100 # - aces:
1101 # - authen: true
1102 # destination:
1103 # any: true
1104 # grant: deny
1105 # log: true
1106 # protocol: tcp
1107 # protocol_options:
1108 # tcp:
1109 # syn: true
1110 # routing: true
1111 # sequence: 10
1112 # source:
1113 # port_protocol:
1114 # range:
1115 # end: telnet
1116 # start: ftp
1117 # prefix: 2001:db8:1234::/48
1118 # ttl:
1119 # range:
1120 # end: 250
1121 # start: 180
1122 # - destination:
1123 # any: true
1124 # destopts: true
1125 # grant: permit
1126 # precedence: network
1127 # protocol: icmpv6
1128 # protocol_options:
1129 # icmpv6:
1130 # router_advertisement: true
1131 # sequence: 20
1132 # source:
1133 # any: true
1134 # name: acl6_1
1135 # afi: ipv6
1136
1137 # After state:
1138 # -------------
1139
1140 # RP/0/RP0/CPU0:ios#show access-lists afi-all
1141 # Wed Sep 27 09:58:38.345 UTC
1142 # ipv4 access-list acl_1
1143 # 10 permit udp 192.168.1.0 0.0.0.255 any
1144 # 16 remark TEST_ACL_1_REMARK
1145 # 21 permit tcp 198.51.100.32 0.0.0.15 range pop3 121 198.51.100.0 0.0.0.15 syn
1146 # 23 deny icmp any 198.51.100.0 0.0.0.15 router-advertisement dscp eq af23
1147 # ipv4 access-list acl_2
1148 # 10 remark TEST_ACL_2_REMARK
1149 # ipv6 access-list acl6_1
1150 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
1151 # 20 permit icmpv6 any any router-advertisement precedence network destopts
1152
1153 # Using replaced to replace a whole ACL
1154
1155 # Before state:
1156 # -------------
1157
1158 # RP/0/RP0/CPU0:ios#show access-lists afi-all
1159 # Fri Sep 22 05:38:36.205 UTC
1160 # ipv4 access-list acl_1
1161 # 10 permit udp 192.168.1.0 0.0.0.255 any
1162 # 16 remark TEST_ACL_1_REMARK
1163 # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
1164 # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
1165 # ipv4 access-list acl_2
1166 # 10 remark TEST_ACL_2_REMARK
1167 # ipv6 access-list acl6_1
1168 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
1169 # 20 permit icmpv6 any any router-advertisement precedence network destopts
1170
1171 - name: Replace device configurations of listed ACL with provided configurations
1172 cisco.iosxr.iosxr_acls:
1173 state: replaced
1174 config:
1175 - afi: ipv4
1176 acls:
1177 - name: acl_2
1178 aces:
1179 - sequence: 11
1180 grant: permit
1181 protocol: igmp
1182 source:
1183 host: 198.51.100.130
1184 destination:
1185 any: true
1186 ttl:
1187 eq: 100
1188 - sequence: 12
1189 grant: deny
1190 source:
1191 any: true
1192 destination:
1193 any: true
1194 protocol: icmp
1195
1196 # Task Output
1197 # -----------
1198 # before:
1199 # - acls:
1200 # - aces:
1201 # - destination:
1202 # any: true
1203 # grant: permit
1204 # protocol: udp
1205 # sequence: 10
1206 # source:
1207 # address: 192.168.1.0
1208 # wildcard_bits: 0.0.0.255
1209 # - remark: TEST_ACL_1_REMARK
1210 # sequence: 16
1211 # - destination:
1212 # address: 198.51.100.0
1213 # wildcard_bits: 0.0.0.15
1214 # grant: permit
1215 # protocol: tcp
1216 # protocol_options:
1217 # tcp:
1218 # rst: true
1219 # sequence: 21
1220 # source:
1221 # host: 192.0.2.10
1222 # port_protocol:
1223 # range:
1224 # end: '121'
1225 # start: pop3
1226 # - destination:
1227 # address: 198.51.100.0
1228 # wildcard_bits: 0.0.0.15
1229 # dscp:
1230 # lt: af12
1231 # grant: deny
1232 # protocol: icmp
1233 # protocol_options:
1234 # icmp:
1235 # reassembly_timeout: true
1236 # sequence: 23
1237 # source:
1238 # any: true
1239 # name: acl_1
1240 # - aces:
1241 # - remark: TEST_ACL_2_REMARK
1242 # sequence: 10
1243 # name: acl_2
1244 # afi: ipv4
1245 # - acls:
1246 # - aces:
1247 # - authen: true
1248 # destination:
1249 # any: true
1250 # grant: deny
1251 # log: true
1252 # protocol: tcp
1253 # protocol_options:
1254 # tcp:
1255 # syn: true
1256 # routing: true
1257 # sequence: 10
1258 # source:
1259 # port_protocol:
1260 # range:
1261 # end: telnet
1262 # start: ftp
1263 # prefix: 2001:db8:1234::/48
1264 # ttl:
1265 # range:
1266 # end: 250
1267 # start: 180
1268 # - destination:
1269 # any: true
1270 # destopts: true
1271 # grant: permit
1272 # precedence: network
1273 # protocol: icmpv6
1274 # protocol_options:
1275 # icmpv6:
1276 # router_advertisement: true
1277 # sequence: 20
1278 # source:
1279 # any: true
1280 # name: acl6_1
1281 # afi: ipv6
1282 #
1283 # commands:
1284 # - ipv4 access-list acl_2
1285 # - no 10
1286 # - 11 permit igmp host 198.51.100.130 any ttl eq 100
1287 # - 12 deny icmp any any
1288 #
1289 # after:
1290 # - acls:
1291 # - aces:
1292 # - destination:
1293 # any: true
1294 # grant: permit
1295 # protocol: udp
1296 # sequence: 10
1297 # source:
1298 # address: 192.168.1.0
1299 # wildcard_bits: 0.0.0.255
1300 # - remark: TEST_ACL_1_REMARK
1301 # sequence: 16
1302 # - destination:
1303 # address: 198.51.100.0
1304 # wildcard_bits: 0.0.0.15
1305 # grant: permit
1306 # protocol: tcp
1307 # protocol_options:
1308 # tcp:
1309 # rst: true
1310 # sequence: 21
1311 # source:
1312 # host: 192.0.2.10
1313 # port_protocol:
1314 # range:
1315 # end: '121'
1316 # start: pop3
1317 # - destination:
1318 # address: 198.51.100.0
1319 # wildcard_bits: 0.0.0.15
1320 # dscp:
1321 # lt: af12
1322 # grant: deny
1323 # protocol: icmp
1324 # protocol_options:
1325 # icmp:
1326 # reassembly_timeout: true
1327 # sequence: 23
1328 # source:
1329 # any: true
1330 # name: acl_1
1331 # - aces:
1332 # - destination:
1333 # any: true
1334 # grant: permit
1335 # protocol: igmp
1336 # sequence: 11
1337 # source:
1338 # host: 198.51.100.130
1339 # ttl:
1340 # eq: 100
1341 # - destination:
1342 # any: true
1343 # grant: deny
1344 # protocol: icmp
1345 # sequence: 12
1346 # source:
1347 # any: true
1348 # name: acl_2
1349 # afi: ipv4
1350 # - acls:
1351 # - aces:
1352 # - authen: true
1353 # destination:
1354 # any: true
1355 # grant: deny
1356 # log: true
1357 # protocol: tcp
1358 # protocol_options:
1359 # tcp:
1360 # syn: true
1361 # routing: true
1362 # sequence: 10
1363 # source:
1364 # port_protocol:
1365 # range:
1366 # end: telnet
1367 # start: ftp
1368 # prefix: 2001:db8:1234::/48
1369 # ttl:
1370 # range:
1371 # end: 250
1372 # start: 180
1373 # - destination:
1374 # any: true
1375 # destopts: true
1376 # grant: permit
1377 # precedence: network
1378 # protocol: icmpv6
1379 # protocol_options:
1380 # icmpv6:
1381 # router_advertisement: true
1382 # sequence: 20
1383 # source:
1384 # any: true
1385 # name: acl6_1
1386 # afi: ipv6
1387
1388 # After state:
1389 # -------------
1390 # RP/0/RP0/CPU0:ios#show access-lists afi-all
1391 # Fri Sep 22 05:56:21.103 UTC
1392 # ipv4 access-list acl_1
1393 # 10 permit udp 192.168.1.0 0.0.0.255 any
1394 # 16 remark TEST_ACL_1_REMARK
1395 # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
1396 # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
1397 # ipv4 access-list acl_2
1398 # 11 permit igmp host 198.51.100.130 any ttl eq 100
1399 # 12 deny icmp any any
1400 # ipv6 access-list acl6_1
1401 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
1402 # 20 permit icmpv6 any any router-advertisement precedence network destopts
1403
1404 # Using overridden to override all ACLs in the device
1405
1406 # Before state:
1407 # -------------
1408
1409 # RP/0/RP0/CPU0:ios#sh access-lists afi-all
1410 # Thu Feb 20 05:22:57.021 UTC
1411 # ipv4 access-list acl_1
1412 # 10 permit udp 192.168.1.0 0.0.0.255 any
1413 # 16 remark TEST_ACL_1_REMARK
1414 # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
1415 # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
1416 # ipv4 access-list acl_2
1417 # 10 remark TEST_ACL_2_REMARK
1418 # ipv6 access-list acl6_1
1419 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
1420 # 20 permit icmpv6 any any router-advertisement precedence network destopts
1421
1422 - name: Overridde all ACLs configuration with provided configuration
1423 cisco.iosxr.iosxr_acls:
1424 config:
1425 - afi: ipv4
1426 acls:
1427 - name: acl_1
1428 aces:
1429 - sequence: 10
1430 grant: permit
1431 source:
1432 any: true
1433 destination:
1434 any: true
1435 protocol: tcp
1436 - name: acl_2
1437 aces:
1438 - sequence: 20
1439 grant: permit
1440 source:
1441 any: true
1442 destination:
1443 any: true
1444 protocol: igmp
1445 state: overridden
1446
1447 # Task Output
1448 # -----------
1449 #
1450 # before:
1451 # - acls:
1452 # - aces:
1453 # - remark: TEST_ACL_1_REMARK
1454 # sequence: 16
1455 # - destination:
1456 # address: 198.51.100.0
1457 # wildcard_bits: 0.0.0.15
1458 # grant: permit
1459 # protocol: tcp
1460 # protocol_options:
1461 # tcp:
1462 # rst: true
1463 # sequence: 21
1464 # source:
1465 # host: 192.0.2.10
1466 # port_protocol:
1467 # range:
1468 # end: '121'
1469 # start: pop3
1470 # - destination:
1471 # address: 198.51.100.0
1472 # wildcard_bits: 0.0.0.15
1473 # dscp:
1474 # lt: af12
1475 # grant: deny
1476 # protocol: icmp
1477 # protocol_options:
1478 # icmp:
1479 # reassembly_timeout: true
1480 # sequence: 23
1481 # source:
1482 # any: true
1483 # name: acl_1
1484 # - aces:
1485 # - remark: TEST_ACL_2_REMARK
1486 # sequence: 10
1487 # name: acl_2
1488 # afi: ipv4
1489 # - acls:
1490 # - aces:
1491 # - authen: true
1492 # destination:
1493 # any: true
1494 # grant: deny
1495 # log: true
1496 # protocol: tcp
1497 # protocol_options:
1498 # tcp:
1499 # syn: true
1500 # routing: true
1501 # sequence: 10
1502 # source:
1503 # port_protocol:
1504 # range:
1505 # end: telnet
1506 # start: ftp
1507 # prefix: 2001:db8:1234::/48
1508 # ttl:
1509 # range:
1510 # end: 250
1511 # start: 180
1512 # - destination:
1513 # any: true
1514 # destopts: true
1515 # grant: permit
1516 # precedence: network
1517 # protocol: icmpv6
1518 # protocol_options:
1519 # icmpv6:
1520 # router_advertisement: true
1521 # sequence: 20
1522 # source:
1523 # any: true
1524 # name: acl6_1
1525 # afi: ipv6
1526 #
1527 # commands:
1528 # - no ipv6 access-list acl6_1
1529 # - ipv4 access-list acl_1
1530 # - no 16
1531 # - no 21
1532 # - no 23
1533 # - 10 permit tcp any any
1534 # - ipv4 access-list acl_2
1535 # - no 10
1536 # - 20 permit igmp any any
1537 #
1538 # after:
1539 # - acls:
1540 # - aces:
1541 # - destination:
1542 # any: true
1543 # grant: permit
1544 # protocol: tcp
1545 # sequence: 10
1546 # source:
1547 # any: true
1548 # name: acl_1
1549 # - aces:
1550 # - destination:
1551 # any: true
1552 # grant: permit
1553 # protocol: igmp
1554 # sequence: 20
1555 # source:
1556 # any: true
1557 # name: acl_2
1558 # afi: ipv4
1559
1560 # After state:
1561 # -------------
1562
1563 # RP/0/RP0/CPU0:ios#sh access-lists afi-all
1564 # Thu Feb 20 06:31:22.178 UTC
1565 # ipv4 access-list acl_1
1566 # 10 permit tcp any any
1567 # ipv4 access-list acl_2
1568 # 20 permit igmp any any
1569
1570 # Using deleted to delete an entire ACL
1571
1572 # Before state:
1573 # -------------
1574
1575 # RP/0/RP0/CPU0:ios#show access-lists afi-all
1576 # Wed Sep 27 09:34:04.831 UTC
1577 # ipv4 access-list acl_1
1578 # 16 remark TEST_ACL_1_REMARK
1579 # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
1580 # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
1581 # ipv4 access-list acl_2
1582 # 10 remark TEST_ACL_2_REMARK
1583 # ipv6 access-list acl6_1
1584 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
1585 # 20 permit icmpv6 any any router-advertisement precedence network destopts
1586
1587 - name: Delete a single ACL
1588 cisco.iosxr.iosxr_acls:
1589 config:
1590 - afi: ipv6
1591 acls:
1592 - name: acl6_1
1593 state: deleted
1594
1595 # Task Output
1596 # -----------
1597 #
1598 # before:
1599 # - acls:
1600 # - aces:
1601 # - remark: TEST_ACL_1_REMARK
1602 # sequence: 16
1603 # - destination:
1604 # address: 198.51.100.0
1605 # wildcard_bits: 0.0.0.15
1606 # grant: permit
1607 # protocol: tcp
1608 # protocol_options:
1609 # tcp:
1610 # rst: true
1611 # sequence: 21
1612 # source:
1613 # host: 192.0.2.10
1614 # port_protocol:
1615 # range:
1616 # end: '121'
1617 # start: pop3
1618 # - destination:
1619 # address: 198.51.100.0
1620 # wildcard_bits: 0.0.0.15
1621 # dscp:
1622 # lt: af12
1623 # grant: deny
1624 # protocol: icmp
1625 # protocol_options:
1626 # icmp:
1627 # reassembly_timeout: true
1628 # sequence: 23
1629 # source:
1630 # any: true
1631 # name: acl_1
1632 # - aces:
1633 # - remark: TEST_ACL_2_REMARK
1634 # sequence: 10
1635 # name: acl_2
1636 # afi: ipv4
1637 # - acls:
1638 # - aces:
1639 # - authen: true
1640 # destination:
1641 # any: true
1642 # grant: deny
1643 # log: true
1644 # protocol: tcp
1645 # protocol_options:
1646 # tcp:
1647 # syn: true
1648 # routing: true
1649 # sequence: 10
1650 # source:
1651 # port_protocol:
1652 # range:
1653 # end: telnet
1654 # start: ftp
1655 # prefix: 2001:db8:1234::/48
1656 # ttl:
1657 # range:
1658 # end: 250
1659 # start: 180
1660 # - destination:
1661 # any: true
1662 # destopts: true
1663 # grant: permit
1664 # precedence: network
1665 # protocol: icmpv6
1666 # protocol_options:
1667 # icmpv6:
1668 # router_advertisement: true
1669 # sequence: 20
1670 # source:
1671 # any: true
1672 # name: acl6_1
1673 # afi: ipv6
1674 #
1675 # commands:
1676 # - no ipv6 access-list acl6_1
1677 #
1678 # after:
1679 # - acls:
1680 # - aces:
1681 # - remark: TEST_ACL_1_REMARK
1682 # sequence: 16
1683 # - destination:
1684 # address: 198.51.100.0
1685 # wildcard_bits: 0.0.0.15
1686 # grant: permit
1687 # protocol: tcp
1688 # protocol_options:
1689 # tcp:
1690 # rst: true
1691 # sequence: 21
1692 # source:
1693 # host: 192.0.2.10
1694 # port_protocol:
1695 # range:
1696 # end: '121'
1697 # start: pop3
1698 # - destination:
1699 # address: 198.51.100.0
1700 # wildcard_bits: 0.0.0.15
1701 # dscp:
1702 # lt: af12
1703 # grant: deny
1704 # protocol: icmp
1705 # protocol_options:
1706 # icmp:
1707 # reassembly_timeout: true
1708 # sequence: 23
1709 # source:
1710 # any: true
1711 # name: acl_1
1712 # - aces:
1713 # - remark: TEST_ACL_2_REMARK
1714 # sequence: 10
1715 # name: acl_2
1716 # afi: ipv4
1717
1718
1719 # After state:
1720 # -------------
1721
1722 # RP/0/RP0/CPU0:ios#sh access-lists afi-all
1723 # Thu Feb 20 05:22:57.021 UTC
1724 # ipv4 access-list acl_1
1725 # 16 remark TEST_ACL_1_REMARK
1726 # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
1727 # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
1728 # ipv4 access-list acl_2
1729 # 10 remark TEST_ACL_2_REMARK
1730
1731 # Using deleted to delete all ACLs under one AFI
1732
1733 # Before state:
1734 # -------------
1735
1736 # RP/0/RP0/CPU0:ios#show access-lists afi-all
1737 # Wed Sep 27 09:34:04.831 UTC
1738 # ipv4 access-list acl_1
1739 # 16 remark TEST_ACL_1_REMARK
1740 # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
1741 # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
1742 # ipv4 access-list acl_2
1743 # 10 remark TEST_ACL_2_REMARK
1744 # ipv6 access-list acl6_1
1745 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
1746 # 20 permit icmpv6 any any router-advertisement precedence network destopts
1747
1748 - name: Delete all ACLs under one AFI
1749 cisco.iosxr.iosxr_acls:
1750 config:
1751 - afi: ipv4
1752 state: deleted
1753
1754 # Task Output
1755 # -----------
1756 #
1757 # before:
1758 # - acls:
1759 # - aces:
1760 # - remark: TEST_ACL_1_REMARK
1761 # sequence: 16
1762 # - destination:
1763 # address: 198.51.100.0
1764 # wildcard_bits: 0.0.0.15
1765 # grant: permit
1766 # protocol: tcp
1767 # protocol_options:
1768 # tcp:
1769 # rst: true
1770 # sequence: 21
1771 # source:
1772 # host: 192.0.2.10
1773 # port_protocol:
1774 # range:
1775 # end: '121'
1776 # start: pop3
1777 # - destination:
1778 # address: 198.51.100.0
1779 # wildcard_bits: 0.0.0.15
1780 # dscp:
1781 # lt: af12
1782 # grant: deny
1783 # protocol: icmp
1784 # protocol_options:
1785 # icmp:
1786 # reassembly_timeout: true
1787 # sequence: 23
1788 # source:
1789 # any: true
1790 # name: acl_1
1791 # - aces:
1792 # - remark: TEST_ACL_2_REMARK
1793 # sequence: 10
1794 # name: acl_2
1795 # afi: ipv4
1796 # - acls:
1797 # - aces:
1798 # - authen: true
1799 # destination:
1800 # any: true
1801 # grant: deny
1802 # log: true
1803 # protocol: tcp
1804 # protocol_options:
1805 # tcp:
1806 # syn: true
1807 # routing: true
1808 # sequence: 10
1809 # source:
1810 # port_protocol:
1811 # range:
1812 # end: telnet
1813 # start: ftp
1814 # prefix: 2001:db8:1234::/48
1815 # ttl:
1816 # range:
1817 # end: 250
1818 # start: 180
1819 # - destination:
1820 # any: true
1821 # destopts: true
1822 # grant: permit
1823 # precedence: network
1824 # protocol: icmpv6
1825 # protocol_options:
1826 # icmpv6:
1827 # router_advertisement: true
1828 # sequence: 20
1829 # source:
1830 # any: true
1831 # name: acl6_1
1832 # afi: ipv6
1833 #
1834 # commands:
1835 # - no ipv4 access-list acl_1
1836 # - no ipv4 access-list acl_2
1837 #
1838 # after:
1839 # - acls:
1840 # - aces:
1841 # - authen: true
1842 # destination:
1843 # any: true
1844 # grant: deny
1845 # log: true
1846 # protocol: tcp
1847 # protocol_options:
1848 # tcp:
1849 # syn: true
1850 # routing: true
1851 # sequence: 10
1852 # source:
1853 # port_protocol:
1854 # range:
1855 # end: telnet
1856 # start: ftp
1857 # prefix: 2001:db8:1234::/48
1858 # ttl:
1859 # range:
1860 # end: 250
1861 # start: 180
1862 # - destination:
1863 # any: true
1864 # destopts: true
1865 # grant: permit
1866 # precedence: network
1867 # protocol: icmpv6
1868 # protocol_options:
1869 # icmpv6:
1870 # router_advertisement: true
1871 # sequence: 20
1872 # source:
1873 # any: true
1874 # name: acl6_1
1875 # afi: ipv6
1876
1877 # After state:
1878 # -------------
1879
1880 # RP/0/RP0/CPU0:ios#show access-lists afi-all
1881 # Thu Feb 20 05:22:57.021 UTC
1882 # ipv6 access-list acl6_1
1883 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
1884 # 20 permit icmpv6 any any router-advertisement precedence network destopts
1885
1886 # Using deleted to delete all ACLs from the device
1887
1888 # Before state:
1889 # -------------
1890
1891 # RP/0/RP0/CPU0:ios#show access-lists afi-all
1892 # Wed Sep 27 09:34:04.831 UTC
1893 # ipv4 access-list acl_1
1894 # 16 remark TEST_ACL_1_REMARK
1895 # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
1896 # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
1897 # ipv4 access-list acl_2
1898 # 10 remark TEST_ACL_2_REMARK
1899 # ipv6 access-list acl6_1
1900 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
1901 # 20 permit icmpv6 any any router-advertisement precedence network destopts
1902
1903 - name: Delete all ACLs from the device
1904 cisco.iosxr.iosxr_acls:
1905 state: deleted
1906
1907
1908 # Task Output
1909 # -----------
1910 #
1911 # before:
1912 # - acls:
1913 # - aces:
1914 # - remark: TEST_ACL_1_REMARK
1915 # sequence: 16
1916 # - destination:
1917 # address: 198.51.100.0
1918 # wildcard_bits: 0.0.0.15
1919 # grant: permit
1920 # protocol: tcp
1921 # protocol_options:
1922 # tcp:
1923 # rst: true
1924 # sequence: 21
1925 # source:
1926 # host: 192.0.2.10
1927 # port_protocol:
1928 # range:
1929 # end: '121'
1930 # start: pop3
1931 # - destination:
1932 # address: 198.51.100.0
1933 # wildcard_bits: 0.0.0.15
1934 # dscp:
1935 # lt: af12
1936 # grant: deny
1937 # protocol: icmp
1938 # protocol_options:
1939 # icmp:
1940 # reassembly_timeout: true
1941 # sequence: 23
1942 # source:
1943 # any: true
1944 # name: acl_1
1945 # - aces:
1946 # - remark: TEST_ACL_2_REMARK
1947 # sequence: 10
1948 # name: acl_2
1949 # afi: ipv4
1950 # - acls:
1951 # - aces:
1952 # - authen: true
1953 # destination:
1954 # any: true
1955 # grant: deny
1956 # log: true
1957 # protocol: tcp
1958 # protocol_options:
1959 # tcp:
1960 # syn: true
1961 # routing: true
1962 # sequence: 10
1963 # source:
1964 # port_protocol:
1965 # range:
1966 # end: telnet
1967 # start: ftp
1968 # prefix: 2001:db8:1234::/48
1969 # ttl:
1970 # range:
1971 # end: 250
1972 # start: 180
1973 # - destination:
1974 # any: true
1975 # destopts: true
1976 # grant: permit
1977 # precedence: network
1978 # protocol: icmpv6
1979 # protocol_options:
1980 # icmpv6:
1981 # router_advertisement: true
1982 # sequence: 20
1983 # source:
1984 # any: true
1985 # name: acl6_1
1986 # afi: ipv6
1987 #
1988 # commands:
1989 # - no ipv4 access-list acl_1
1990 # - no ipv4 access-list acl_2
1991 # - no ipv6 access-list acl6_1
1992 #
1993 # after: []
1994
1995 # After state:
1996 # -------------
1997
1998 # RP/0/RP0/CPU0:ios#show access-lists afi-all
1999 # Thu Feb 20 05:07:45.767 UTC
2000 # RP/0/RP0/CPU0:ios#
2001
2002 # Using gathered to gather ACL facts from the device
2003
2004 # RP/0/RP0/CPU0:ios#show access-lists afi-all
2005 # Wed Sep 27 09:34:04.831 UTC
2006 # ipv4 access-list acl_1
2007 # 16 remark TEST_ACL_1_REMARK
2008 # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
2009 # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
2010 # ipv4 access-list acl_2
2011 # 10 remark TEST_ACL_2_REMARK
2012 # ipv6 access-list acl6_1
2013 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
2014 # 20 permit icmpv6 any any router-advertisement precedence network destopts
2015
2016 - name: Gather ACL interfaces facts using gathered state
2017 cisco.iosxr.iosxr_acls:
2018 state: gathered
2019
2020 # Task Output (redacted)
2021 # -----------------------
2022 #
2023 # gathered:
2024 # - acls:
2025 # - aces:
2026 # - remark: TEST_ACL_1_REMARK
2027 # sequence: 16
2028 # - destination:
2029 # address: 198.51.100.0
2030 # wildcard_bits: 0.0.0.15
2031 # grant: permit
2032 # protocol: tcp
2033 # protocol_options:
2034 # tcp:
2035 # rst: true
2036 # sequence: 21
2037 # source:
2038 # host: 192.0.2.10
2039 # port_protocol:
2040 # range:
2041 # end: '121'
2042 # start: pop3
2043 # - destination:
2044 # address: 198.51.100.0
2045 # wildcard_bits: 0.0.0.15
2046 # dscp:
2047 # lt: af12
2048 # grant: deny
2049 # protocol: icmp
2050 # protocol_options:
2051 # icmp:
2052 # reassembly_timeout: true
2053 # sequence: 23
2054 # source:
2055 # any: true
2056 # name: acl_1
2057 # - aces:
2058 # - remark: TEST_ACL_2_REMARK
2059 # sequence: 10
2060 # name: acl_2
2061 # afi: ipv4
2062 # - acls:
2063 # - aces:
2064 # - authen: true
2065 # destination:
2066 # any: true
2067 # grant: deny
2068 # log: true
2069 # protocol: tcp
2070 # protocol_options:
2071 # tcp:
2072 # syn: true
2073 # routing: true
2074 # sequence: 10
2075 # source:
2076 # port_protocol:
2077 # range:
2078 # end: telnet
2079 # start: ftp
2080 # prefix: 2001:db8:1234::/48
2081 # ttl:
2082 # range:
2083 # end: 250
2084 # start: 180
2085 # - destination:
2086 # any: true
2087 # destopts: true
2088 # grant: permit
2089 # precedence: network
2090 # protocol: icmpv6
2091 # protocol_options:
2092 # icmpv6:
2093 # router_advertisement: true
2094 # sequence: 20
2095 # source:
2096 # any: true
2097 # name: acl6_1
2098 # afi: ipv6
2099
2100 # Using rendered
2101
2102 - name: Render platform specific commands (without connecting to the device)
2103 cisco.iosxr.iosxr_acls:
2104 config:
2105 - afi: ipv4
2106 acls:
2107 - name: acl_2
2108 aces:
2109 - sequence: 11
2110 grant: permit
2111 protocol: igmp
2112 source:
2113 host: 198.51.100.130
2114 destination:
2115 any: true
2116 ttl:
2117 eq: 100
2118 - sequence: 12
2119 grant: deny
2120 source:
2121 any: true
2122 destination:
2123 any: true
2124 protocol: icmp
2125 state: rendered
2126
2127 # Task Output (redacted)
2128 # -----------------------
2129
2130 # rendered:
2131 # - ipv4 access-list acl_2
2132 # - 11 permit igmp host 198.51.100.130 any ttl eq 100
2133 # - 12 deny icmp any any
2134
2135 # Using parsed
2136
2137 # parsed.cfg
2138 # ------------
2139 # ipv4 access-list acl_1
2140 # 16 remark TEST_ACL_1_REMARK
2141 # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
2142 # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
2143 # ipv4 access-list acl_2
2144 # 10 remark TEST_ACL_2_REMARK
2145 # ipv6 access-list acl6_1
2146 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log
2147 # 20 permit icmpv6 any any router-advertisement precedence network destopts
2148
2149 - name: Parse externally provided ACL config to agnostic model
2150 cisco.iosxr.iosxr_acls:
2151 running_config: "{{ lookup('file', 'parsed.cfg') }}"
2152 state: parsed
2153
2154 # Task Output (redacted)
2155 # -----------------------
2156 # parsed:
2157 # - acls:
2158 # - aces:
2159 # - remark: TEST_ACL_1_REMARK
2160 # sequence: 16
2161 # - destination:
2162 # address: 198.51.100.0
2163 # wildcard_bits: 0.0.0.15
2164 # grant: permit
2165 # protocol: tcp
2166 # protocol_options:
2167 # tcp:
2168 # rst: true
2169 # sequence: 21
2170 # source:
2171 # host: 192.0.2.10
2172 # port_protocol:
2173 # range:
2174 # end: '121'
2175 # start: pop3
2176 # - destination:
2177 # address: 198.51.100.0
2178 # wildcard_bits: 0.0.0.15
2179 # dscp:
2180 # lt: af12
2181 # grant: deny
2182 # protocol: icmp
2183 # protocol_options:
2184 # icmp:
2185 # reassembly_timeout: true
2186 # sequence: 23
2187 # source:
2188 # any: true
2189 # name: acl_1
2190 # - aces:
2191 # - remark: TEST_ACL_2_REMARK
2192 # sequence: 10
2193 # name: acl_2
2194 # afi: ipv4
2195 # - acls:
2196 # - aces:
2197 # - authen: true
2198 # destination:
2199 # any: true
2200 # grant: deny
2201 # log: true
2202 # protocol: tcp
2203 # protocol_options:
2204 # tcp:
2205 # syn: true
2206 # routing: true
2207 # sequence: 10
2208 # source:
2209 # port_protocol:
2210 # range:
2211 # end: telnet
2212 # start: ftp
2213 # prefix: 2001:db8:1234::/48
2214 # ttl:
2215 # range:
2216 # end: 250
2217 # start: 180
2218 # - destination:
2219 # any: true
2220 # destopts: true
2221 # grant: permit
2222 # precedence: network
2223 # protocol: icmpv6
2224 # protocol_options:
2225 # icmpv6:
2226 # router_advertisement: true
2227 # sequence: 20
2228 # source:
2229 # any: true
2230 # name: acl6_1
2231 # afi: ipv6
2232 """
2233
2234 RETURN = """
2235 before:
2236 description: The configuration prior to the model invocation.
2237 returned: always
2238 type: list
2239 sample: >
2240 The configuration returned will always be in the same format
2241 of the parameters above.
2242 after:
2243 description: The resulting configuration model invocation.
2244 returned: when changed
2245 type: list
2246 sample: >
2247 The configuration returned will always be in the same format
2248 of the parameters above.
2249 commands:
2250 description: The set of commands pushed to the remote device.
2251 returned: always
2252 type: list
2253 sample:
2254 - ipv6 access-list acl6_1
2255 - 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 authen routing log
2256 - 20 permit icmpv6 any any router-advertisement precedence network destopts
2257 - ipv4 access-list acl_1
2258 - 16 remark TEST_ACL_1_REMARK
2259 - 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst
2260 - 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12
2261 rendered:
2262 description: The provided configuration in the task rendered in device-native format (offline).
2263 returned: when I(state) is C(rendered)
2264 type: list
2265 sample:
2266 - ipv6 access-list acl6_1
2267 - 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 authen routing log
2268 - 20 permit icmpv6 any any router-advertisement precedence network destopts
2269 gathered:
2270 description: Facts about the network resource gathered from the remote device as structured data.
2271 returned: when I(state) is C(gathered)
2272 type: list
2273 sample: >
2274 This output will always be in the same format as the
2275 module argspec.
2276 parsed:
2277 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
2278 returned: when I(state) is C(parsed)
2279 type: list
2280 sample: >
2281 This output will always be in the same format as the
2282 module argspec.
2283 """
2284
2285
2286 from ansible.module_utils.basic import AnsibleModule
2287
2288 from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec.acls.acls import (
2289 AclsArgs,
2290 )
2291 from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.config.acls.acls import Acls
2292
2293
2294 def main():
2295 """
2296 Main entry point for module execution
2297
2298 :returns: the result form module invocation
2299 """
2300 required_if = [
2301 ("state", "merged", ("config",)),
2302 ("state", "replaced", ("config",)),
2303 ("state", "overridden", ("config",)),
2304 ("state", "rendered", ("config",)),
2305 ("state", "parsed", ("running_config",)),
2306 ]
2307
2308 module = AnsibleModule(
2309 argument_spec=AclsArgs.argument_spec,
2310 required_if=required_if,
2311 supports_check_mode=True,
2312 )
2313
2314 result = Acls(module).execute_module()
2315 module.exit_json(**result)
2316
2317
2318 if __name__ == "__main__":
2319 main()