Debian Codegraph @

ansible_collections/cisco/ios/plugins/modules/ios_acls.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2021 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 The module file for ios_acls
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 author:
18 - Sumit Jaiswal (@justjais)
19 - Sagar Paul (@KB-perByte)
20 - Nikhil Bhasin (@nickbhasin)
21 description: This module configures and manages the named or numbered ACLs on IOS platforms.
22 module: ios_acls
23 notes:
24 - Tested against Cisco IOSXE Version 17.3 on CML.
25 - Module behavior is not idempotent when sequence for aces are not mentioned
26 - This module works with connection C(network_cli).
27 See U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html)
28 - Default ACLs don't get updated, replaced or overridden. Added Defaults - implicit_deny_v6,
29 implicit_permit_v6, preauth_v6, IP-Adm-V4-Int-ACL-global, implicit_deny, implicit_permit, preauth_v4, sl_def_acl
30 options:
31 config:
32 description: A list of ACL configuration options.
33 elements: dict
34 suboptions:
35 acls:
36 description:
37 - A list of Access Control Lists (ACL) attributes.
38 elements: dict
39 suboptions:
40 aces:
41 description: The entries within the ACL.
42 elements: dict
43 suboptions:
44 destination:
45 description: Specify the packet destination.
46 suboptions:
47 address:
48 description: Host address to match, or any single host address.
49 type: str
50 any:
51 description: Match any source address.
52 type: bool
53 host:
54 description: A single destination host
55 type: str
56 object_group:
57 description: Destination network object group
58 type: str
59 port_protocol:
60 description:
61 - Specify the destination port along with protocol.
62 - Note, Valid with TCP/UDP protocol_options
63 suboptions:
64 eq:
65 description: Match only packets on a given port number.
66 type: str
67 gt:
68 description: Match only packets with a greater port number.
69 type: str
70 lt:
71 description: Match only packets with a lower port number.
72 type: str
73 neq:
74 description: Match only packets not on a given port number.
75 type: str
76 range:
77 description: Port group.
78 suboptions:
79 end:
80 description: Specify the end of the port range.
81 type: str
82 start:
83 description: Specify the start of the port range.
84 type: str
85 type: dict
86 type: dict
87 wildcard_bits:
88 description: Destination wildcard bits, valid with IPV4 address.
89 type: str
90 type: dict
91 dscp:
92 description: Match packets with given dscp value.
93 type: str
94 evaluate:
95 description: Evaluate an access list
96 type: str
97 enable_fragments:
98 description: Enable non-initial fragments.
99 type: bool
100 grant:
101 choices:
102 - permit
103 - deny
104 description: Specify the action.
105 type: str
106 log:
107 description: Log matches against this entry.
108 suboptions:
109 set:
110 description: Enable Log matches against this entry
111 type: bool
112 user_cookie:
113 description: User defined cookie (max of 64 char)
114 type: str
115 type: dict
116 log_input:
117 description: Log matches against this entry, including input interface.
118 suboptions:
119 set:
120 description: Enable Log matches against this entry, including input interface.
121 type: bool
122 user_cookie:
123 description: User defined cookie (max of 64 char)
124 type: str
125 type: dict
126 option:
127 description:
128 - Match packets with given IP Options value.
129 - Valid only for named acls.
130 suboptions:
131 add_ext:
132 description: Match packets with Address Extension Option (147).
133 type: bool
134 any_options:
135 description: Match packets with ANY Option.
136 type: bool
137 com_security:
138 description: Match packets with Commercial Security Option (134).
139 type: bool
140 dps:
141 description: Match packets with Dynamic Packet State Option (151).
142 type: bool
143 encode:
144 description: Match packets with Encode Option (15).
145 type: bool
146 eool:
147 description: Match packets with End of Options (0).
148 type: bool
149 ext_ip:
150 description: Match packets with Extended IP Option (145).
151 type: bool
152 ext_security:
153 description: Match packets with Extended Security Option (133).
154 type: bool
155 finn:
156 description: Match packets with Experimental Flow Control Option (205).
157 type: bool
158 imitd:
159 description: Match packets with IMI Traffic Desriptor Option (144).
160 type: bool
161 lsr:
162 description: Match packets with Loose Source Route Option (131).
163 type: bool
164 mtup:
165 description: Match packets with MTU Probe Option (11).
166 type: bool
167 mtur:
168 description: Match packets with MTU Reply Option (12).
169 type: bool
170 no_op:
171 description: Match packets with No Operation Option (1).
172 type: bool
173 nsapa:
174 description: Match packets with NSAP Addresses Option (150).
175 type: bool
176 record_route:
177 description: Match packets with Record Route Option (7).
178 type: bool
179 router_alert:
180 description: Match packets with Router Alert Option (148).
181 type: bool
182 sdb:
183 description: Match packets with Selective Directed Broadcast Option (149).
184 type: bool
185 security:
186 description: Match packets with Basic Security Option (130).
187 type: bool
188 ssr:
189 description: Match packets with Strict Source Routing Option (137).
190 type: bool
191 stream_id:
192 description: Match packets with Stream ID Option (136).
193 type: bool
194 timestamp:
195 description: Match packets with Time Stamp Option (68).
196 type: bool
197 traceroute:
198 description: Match packets with Trace Route Option (82).
199 type: bool
200 ump:
201 description: Match packets with Upstream Multicast Packet Option (152).
202 type: bool
203 visa:
204 description: Match packets with Experimental Access Control Option (142).
205 type: bool
206 zsu:
207 description: Match packets with Experimental Measurement Option (10).
208 type: bool
209 type: dict
210 precedence:
211 description: Match packets with given precedence value.
212 type: str
213 protocol:
214 description:
215 - Specify the protocol to match.
216 - Refer to vendor documentation for valid values.
217 type: str
218 protocol_options:
219 description: protocol type.
220 suboptions:
221 ahp:
222 description: Authentication Header Protocol.
223 type: bool
224 eigrp:
225 description: Cisco's EIGRP routing protocol.
226 type: bool
227 esp:
228 description: Encapsulation Security Payload.
229 type: bool
230 gre:
231 description: Cisco's GRE tunneling.
232 type: bool
233 hbh:
234 description: Hop by Hop options header. Valid for IPV6
235 type: bool
236 icmp:
237 description: Internet Control Message Protocol.
238 suboptions:
239 administratively_prohibited:
240 description: Administratively prohibited
241 type: bool
242 alternate_address:
243 description: Alternate address
244 type: bool
245 conversion_error:
246 description: Datagram conversion
247 type: bool
248 dod_host_prohibited:
249 description: Host prohibited
250 type: bool
251 dod_net_prohibited:
252 description: Net prohibited
253 type: bool
254 echo:
255 description: Echo (ping)
256 type: bool
257 echo_reply:
258 description: Echo reply
259 type: bool
260 general_parameter_problem:
261 description: Parameter problem
262 type: bool
263 host_isolated:
264 description: Host isolated
265 type: bool
266 host_precedence_unreachable:
267 description: Host unreachable for precedence
268 type: bool
269 host_redirect:
270 description: Host redirect
271 type: bool
272 host_tos_redirect:
273 description: Host redirect for TOS
274 type: bool
275 host_tos_unreachable:
276 description: Host unreachable for TOS
277 type: bool
278 host_unknown:
279 description: Host unknown
280 type: bool
281 host_unreachable:
282 description: Host unreachable
283 type: bool
284 information_reply:
285 description: Information replies
286 type: bool
287 information_request:
288 description: Information requests
289 type: bool
290 mask_reply:
291 description: Mask replies
292 type: bool
293 mask_request:
294 description: mask_request
295 type: bool
296 mobile_redirect:
297 description: Mobile host redirect
298 type: bool
299 net_redirect:
300 description: Network redirect
301 type: bool
302 net_tos_redirect:
303 description: Net redirect for TOS
304 type: bool
305 net_tos_unreachable:
306 description: Network unreachable for TOS
307 type: bool
308 net_unreachable:
309 description: Net unreachable
310 type: bool
311 network_unknown:
312 description: Network unknown
313 type: bool
314 no_room_for_option:
315 description: Parameter required but no room
316 type: bool
317 option_missing:
318 description: Parameter required but not present
319 type: bool
320 packet_too_big:
321 description: Fragmentation needed and DF set
322 type: bool
323 parameter_problem:
324 description: All parameter problems
325 type: bool
326 port_unreachable:
327 description: Port unreachable
328 type: bool
329 precedence_unreachable:
330 description: Precedence cutoff
331 type: bool
332 protocol_unreachable:
333 description: Protocol unreachable
334 type: bool
335 reassembly_timeout:
336 description: Reassembly timeout
337 type: bool
338 redirect:
339 description: All redirects
340 type: bool
341 router_advertisement:
342 description: Router discovery advertisements
343 type: bool
344 router_solicitation:
345 description: Router discovery solicitations
346 type: bool
347 source_quench:
348 description: Source quenches
349 type: bool
350 source_route_failed:
351 description: Source route failed
352 type: bool
353 time_exceeded:
354 description: All time exceededs
355 type: bool
356 timestamp_reply:
357 description: Timestamp replies
358 type: bool
359 timestamp_request:
360 description: Timestamp requests
361 type: bool
362 traceroute:
363 description: Traceroute
364 type: bool
365 ttl_exceeded:
366 description: TTL exceeded
367 type: bool
368 unreachable:
369 description: All unreachables
370 type: bool
371 type: dict
372 igmp:
373 description: Internet Gateway Message Protocol.
374 suboptions:
375 dvmrp:
376 description: Distance Vector Multicast Routing Protocol(2)
377 type: bool
378 host_query:
379 description: IGMP Membership Query(0)
380 type: bool
381 host_report:
382 description: IGMP Host report
383 type: bool
384 mtrace_resp:
385 description: Multicast Traceroute Response(7)
386 type: bool
387 mtrace_route:
388 description: Multicast Traceroute(8)
389 type: bool
390 pim:
391 description: Protocol Independent Multicast(3)
392 type: bool
393 trace:
394 description: Multicast trace(4)
395 type: bool
396 v1host_report:
397 description: IGMPv1 Membership Report(1)
398 type: bool
399 v2host_report:
400 description: IGMPv2 Membership Report(5)
401 type: bool
402 v2leave_group:
403 description: IGMPv2 Leave Group(6)
404 type: bool
405 v3host_report:
406 description: IGMPv3 Membership Report(9)
407 type: bool
408 type: dict
409 ip:
410 description: Any Internet Protocol.
411 type: bool
412 ipinip:
413 description: IP in IP tunneling.
414 type: bool
415 ipv6:
416 description: Any IPv6.
417 type: bool
418 nos:
419 description: KA9Q NOS compatible IP over IP tunneling.
420 type: bool
421 ospf:
422 description: OSPF routing protocol.
423 type: bool
424 pcp:
425 description: Payload Compression Protocol.
426 type: bool
427 pim:
428 description: Protocol Independent Multicast.
429 type: bool
430 protocol_number:
431 description: An IP protocol number
432 type: int
433 sctp:
434 description: Stream Control Transmission Protocol.
435 type: bool
436 tcp:
437 description: Match TCP packet flags
438 suboptions:
439 ack:
440 description: Match on the ACK bit
441 type: bool
442 established:
443 description: Match established connections
444 type: bool
445 fin:
446 description: Match on the FIN bit
447 type: bool
448 psh:
449 description: Match on the PSH bit
450 type: bool
451 rst:
452 description: Match on the RST bit
453 type: bool
454 syn:
455 description: Match on the SYN bit
456 type: bool
457 urg:
458 description: Match on the URG bit
459 type: bool
460 type: dict
461 udp:
462 description: User Datagram Protocol.
463 type: bool
464 type: dict
465 remarks:
466 description:
467 - The remarks/description of the ACL.
468 - The remarks attribute used within an ace with or without a
469 sequence number will produce remarks that are pushed
470 before the ace entry.
471 - Remarks entry used as the only key in as the list option
472 will produce non ace specific remarks, these remarks would be
473 pushed at the end of all the aces for an acl.
474 - Remarks is treated a block, for every single remarks updated for
475 an ace all the remarks are negated and added back to maintain the
476 order of remarks mentioned.
477 - As the appliance deletes all the remarks once the ace is updated,
478 the set of remarks would be re-applied that is an expected behavior.
479 elements: str
480 type: list
481 sequence:
482 description:
483 - Sequence Number for the Access Control Entry(ACE).
484 - Refer to vendor documentation for valid values.
485 type: int
486 source:
487 description: Specify the packet source.
488 suboptions:
489 address:
490 description: Source network address.
491 type: str
492 any:
493 description: Match any source address.
494 type: bool
495 host:
496 description: A single source host
497 type: str
498 object_group:
499 description: Source network object group
500 type: str
501 port_protocol:
502 description:
503 - Specify the source port along with protocol.
504 - Note, Valid with TCP/UDP protocol_options
505 suboptions:
506 eq:
507 description: Match only packets on a given port number.
508 type: str
509 gt:
510 description: Match only packets with a greater port number.
511 type: str
512 lt:
513 description: Match only packets with a lower port number.
514 type: str
515 neq:
516 description: Match only packets not on a given port number.
517 type: str
518 range:
519 description: Port group.
520 suboptions:
521 end:
522 description: Specify the end of the port range.
523 type: str
524 start:
525 description: Specify the start of the port range.
526 type: str
527 type: dict
528 type: dict
529 wildcard_bits:
530 description: Source wildcard bits, valid with IPV4 address.
531 type: str
532 type: dict
533 time_range:
534 description: Specify a time-range.
535 type: str
536 tos:
537 description:
538 - Match packets with given TOS value.
539 - Note, DSCP and TOS are mutually exclusive
540 suboptions:
541 max_reliability:
542 description: Match packets with max reliable TOS (2).
543 type: bool
544 max_throughput:
545 description: Match packets with max throughput TOS (4).
546 type: bool
547 min_delay:
548 description: Match packets with min delay TOS (8).
549 type: bool
550 min_monetary_cost:
551 description: Match packets with min monetary cost TOS (1).
552 type: bool
553 normal:
554 description: Match packets with normal TOS (0).
555 type: bool
556 service_value:
557 description: Type of service value
558 type: int
559 type: dict
560 ttl:
561 description: Match packets with given TTL value.
562 suboptions:
563 eq:
564 description: Match only packets on a given TTL number.
565 type: int
566 gt:
567 description: Match only packets with a greater TTL number.
568 type: int
569 lt:
570 description: Match only packets with a lower TTL number.
571 type: int
572 neq:
573 description: Match only packets not on a given TTL number.
574 type: int
575 range:
576 description: Match only packets in the range of TTLs.
577 suboptions:
578 end:
579 description: Specify the end of the port range.
580 type: int
581 start:
582 description: Specify the start of the port range.
583 type: int
584 type: dict
585 type: dict
586 type: list
587 acl_type:
588 choices:
589 - extended
590 - standard
591 description:
592 - ACL type
593 - Note, it's mandatory and required for Named ACL, but for Numbered ACL it's not mandatory.
594 type: str
595 name:
596 description: The name or the number of the ACL.
597 required: true
598 type: str
599 type: list
600 afi:
601 choices:
602 - ipv4
603 - ipv6
604 description:
605 - The Address Family Indicator (AFI) for the Access Control Lists (ACL).
606 required: true
607 type: str
608 type: list
609 running_config:
610 description:
611 - This option is used only with state I(parsed).
612 - The value of this option should be the output received from
613 the IOS device by executing the command B(sh access-list).
614 - The state I(parsed) reads the configuration from C(running_config) option and
615 transforms it into Ansible structured data as per the resource module's argspec
616 and the value is then returned in the I(parsed) key within the result.
617 type: str
618 state:
619 choices:
620 - merged
621 - replaced
622 - overridden
623 - deleted
624 - gathered
625 - rendered
626 - parsed
627 default: merged
628 description:
629 - The state the configuration should be left in
630 - The state I(merged) is the default state which merges the want and
631 have config, but for ACL module as the IOS platform doesn't allow
632 update of ACE over an pre-existing ACE sequence in ACL, same way ACLs
633 resource module will error out for respective scenario and only addition
634 of new ACE over new sequence will be allowed with merge state.
635 - The states I(rendered), I(gathered) and I(parsed) does not perform any
636 change on the device.
637 - The state I(rendered) will transform the configuration in C(config)
638 option to platform specific CLI commands which will be returned in
639 the I(rendered) key within the result. For state I(rendered) active
640 connection to remote host is not required.
641 - The state I(gathered) will fetch the running configuration from device
642 and transform it into structured data in the format as per the resource
643 module argspec and the value is returned in the I(gathered) key within the result.
644 - The state I(parsed) reads the configuration from C(running_config) option
645 and transforms it into JSON format as per the resource module parameters
646 and the value is returned in the I(parsed) key within the result. The
647 value of C(running_config) option should be the same format as the output
648 of commands I(sh running-config | section access-list) for all acls related information
649 and I(sh access-lists | include access list) to obtain configuration specific of
650 an empty acls, the following commands are executed on
651 device. Config data from both the commands should be kept together one after
652 another for the parsers to pick the commands correctly.
653 For state I(parsed) active connection to remote host is not required.
654 - The state I(overridden), modify/add the ACLs defined, deleted all other ACLs.
655 - The state I(replaced), modify/add only the ACEs of the ACLs defined only.
656 It does not perform any other change on the device.
657 - The state I(deleted), deletes only the specified ACLs, or all if not specified.
658 type: str
659 short_description: Resource module to configure ACLs.
660 version_added: 1.0.0
661 """
662
663 EXAMPLES = """
664 # Using merged
665
666 # Before state:
667 # -------------
668 #
669 # vios#sh running-config | section access-list
670 # ip access-list extended 110
671 # 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
672
673 - name: Merge provided configuration with device configuration
674 cisco.ios.ios_acls:
675 config:
676 - afi: ipv4
677 acls:
678 - name: std_acl
679 acl_type: standard
680 aces:
681 - grant: deny
682 source:
683 address: 192.168.1.200
684 - grant: deny
685 source:
686 address: 192.168.2.0
687 wildcard_bits: 0.0.0.255
688 - name: 110
689 aces:
690 - sequence: 10
691 protocol_options:
692 icmp:
693 traceroute: true
694 source:
695 address: 192.168.3.0
696 wildcard_bits: 255.255.255.0
697 destination:
698 any: true
699 grant: permit
700 - grant: deny
701 protocol_options:
702 tcp:
703 ack: true
704 source:
705 host: 198.51.100.0
706 destination:
707 host: 198.51.110.0
708 port_protocol:
709 eq: telnet
710 - name: extended_acl_1
711 acl_type: extended
712 aces:
713 - grant: deny
714 protocol_options:
715 tcp:
716 fin: true
717 source:
718 address: 192.0.2.0
719 wildcard_bits: 0.0.0.255
720 destination:
721 address: 192.0.3.0
722 wildcard_bits: 0.0.0.255
723 port_protocol:
724 eq: www
725 option:
726 traceroute: true
727 ttl:
728 eq: 10
729 - name: 123
730 aces:
731 - remarks:
732 - "remarks for extended ACL 1"
733 - "check ACL"
734 - grant: deny
735 protocol_options:
736 tcp:
737 ack: true
738 source:
739 address: 198.51.100.0
740 wildcard_bits: 0.0.0.255
741 destination:
742 address: 198.51.101.0
743 wildcard_bits: 0.0.0.255
744 port_protocol:
745 eq: telnet
746 tos:
747 service_value: 12
748 - grant: deny
749 protocol_options:
750 tcp:
751 ack: true
752 source:
753 address: 192.0.3.0
754 wildcard_bits: 0.0.0.255
755 destination:
756 address: 192.0.4.0
757 wildcard_bits: 0.0.0.255
758 port_protocol:
759 eq: www
760 dscp: ef
761 ttl:
762 lt: 20
763 - afi: ipv6
764 acls:
765 - name: R1_TRAFFIC
766 aces:
767 - grant: deny
768 protocol_options:
769 tcp:
770 ack: true
771 source:
772 any: true
773 port_protocol:
774 eq: www
775 destination:
776 any: true
777 port_protocol:
778 eq: telnet
779 dscp: af11
780 state: merged
781
782 # Task Output
783 # -----------
784 #
785 # before:
786 # - acls:
787 # - aces:
788 # - destination:
789 # address: 192.0.3.0
790 # wildcard_bits: 0.0.0.255
791 # dscp: ef
792 # grant: deny
793 # protocol: icmp
794 # protocol_options:
795 # icmp:
796 # echo: true
797 # sequence: 10
798 # source:
799 # address: 192.0.2.0
800 # wildcard_bits: 0.0.0.255
801 # ttl:
802 # eq: 10
803 # acl_type: extended
804 # name: '100'
805 # afi: ipv4
806 # commands:
807 # - ip access-list extended 110
808 # - deny tcp host 198.51.100.0 host 198.51.110.0 eq telnet ack
809 # - 30 permit icmp 192.168.3.0 255.255.255.0 any traceroute
810 # - ip access-list extended extended_acl_1
811 # - deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
812 # - ip access-list standard std_acl
813 # - deny 192.168.1.20
814 # - deny 192.168.2.0 0.0.0.255
815 # - ip access-list extended 123
816 # - deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
817 # - deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
818 # - remark remarks for extended ACL 1
819 # - remark check ACL
820 # - ipv6 access-list R1_TRAFFIC
821 # - deny tcp any eq www any eq telnet ack dscp af11
822 # after:
823 # - acls:
824 # - aces:
825 # - destination:
826 # address: 192.0.3.0
827 # wildcard_bits: 0.0.0.255
828 # dscp: ef
829 # grant: deny
830 # protocol: icmp
831 # protocol_options:
832 # icmp:
833 # echo: true
834 # sequence: 10
835 # source:
836 # address: 192.0.2.0
837 # wildcard_bits: 0.0.0.255
838 # ttl:
839 # eq: 10
840 # - destination:
841 # host: 198.51.110.0
842 # port_protocol:
843 # eq: telnet
844 # grant: deny
845 # protocol: tcp
846 # protocol_options:
847 # tcp:
848 # ack: true
849 # sequence: 20
850 # source:
851 # host: 198.51.100.0
852 # - destination:
853 # any: true
854 # grant: permit
855 # protocol: icmp
856 # protocol_options:
857 # icmp:
858 # traceroute: true
859 # sequence: 30
860 # source:
861 # address: 0.0.0.0
862 # wildcard_bits: 255.255.255.0
863 # acl_type: extended
864 # name: '110'
865 # - aces:
866 # - destination:
867 # address: 198.51.101.0
868 # port_protocol:
869 # eq: telnet
870 # wildcard_bits: 0.0.0.255
871 # grant: deny
872 # protocol: tcp
873 # protocol_options:
874 # tcp:
875 # ack: true
876 # sequence: 10
877 # source:
878 # address: 198.51.100.0
879 # wildcard_bits: 0.0.0.255
880 # tos:
881 # service_value: 12
882 # - destination:
883 # address: 192.0.4.0
884 # port_protocol:
885 # eq: www
886 # wildcard_bits: 0.0.0.255
887 # dscp: ef
888 # grant: deny
889 # protocol: tcp
890 # protocol_options:
891 # tcp:
892 # ack: true
893 # sequence: 20
894 # source:
895 # address: 192.0.3.0
896 # wildcard_bits: 0.0.0.255
897 # ttl:
898 # lt: 20
899 # - remarks:
900 # - remarks for extended ACL 1
901 # - check ACL
902 # acl_type: extended
903 # name: '123'
904 # - aces:
905 # - destination:
906 # address: 192.0.3.0
907 # port_protocol:
908 # eq: www
909 # wildcard_bits: 0.0.0.255
910 # grant: deny
911 # option:
912 # traceroute: true
913 # protocol: tcp
914 # protocol_options:
915 # tcp:
916 # fin: true
917 # sequence: 10
918 # source:
919 # address: 192.0.2.0
920 # wildcard_bits: 0.0.0.255
921 # ttl:
922 # eq: 10
923 # acl_type: extended
924 # name: extended_acl_1
925 # - aces:
926 # - grant: deny
927 # sequence: 10
928 # source:
929 # host: 192.168.1.20
930 # - grant: deny
931 # sequence: 20
932 # source:
933 # address: 192.168.2.0
934 # wildcard_bits: 0.0.0.255
935 # acl_type: standard
936 # name: std_acl
937 # afi: ipv4
938 # - acls:
939 # - aces:
940 # - destination:
941 # any: true
942 # port_protocol:
943 # eq: telnet
944 # dscp: af11
945 # grant: deny
946 # protocol: tcp
947 # protocol_options:
948 # tcp:
949 # ack: true
950 # sequence: 10
951 # source:
952 # any: true
953 # port_protocol:
954 # eq: www
955 # name: R1_TRAFFIC
956 # afi: ipv6
957
958 # After state:
959 # ------------
960 #
961 # vios#sh running-config | section access-list
962 # ip access-list standard std_acl
963 # 10 deny 192.168.1.200
964 # 20 deny 192.168.2.0 0.0.0.255
965 # ip access-list extended 100
966 # 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
967 # ip access-list extended 110
968 # 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 traceroute dscp ef ttl eq 10
969 # 20 deny tcp host 198.51.100.0 host 198.51.110.0 eq telnet ack
970 # ip access-list extended 123
971 # 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
972 # 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
973 # ip access-list extended test
974 # 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
975 # ipv6 access-list R1_TRAFFIC
976 # sequence 10 deny tcp any eq www any eq telnet ack dscp af11
977
978 # vios#show running-config | include ip(v6)* access-list|remark
979 # ip access-list standard std_acl
980 # ip access-list extended extended_acl_1
981 # ip access-list extended 110
982 # ip access-list extended 123
983 # remark remarks for extended ACL 1
984 # remark check ACL
985 # ipv6 access-list R1_TRAFFIC
986
987 # Using merged (update existing ACE - will fail)
988
989 # Before state:
990 # -------------
991 #
992 # vios#sh running-config | section access-list
993 # ip access-list extended 100
994 # 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
995
996 - name: Merge provided configuration with device configuration
997 cisco.ios.ios_acls:
998 config:
999 - afi: ipv4
1000 acls:
1001 - name: 100
1002 aces:
1003 - sequence: 10
1004 protocol_options:
1005 icmp:
1006 traceroute: true
1007 state: merged
1008
1009 # After state:
1010 # ------------
1011 #
1012 # Play Execution fails, with error:
1013 # Cannot update existing sequence 10 of ACLs 100 with state merged.
1014 # Please use state replaced or overridden.
1015
1016 # Using replaced
1017
1018 # Before state:
1019 # -------------
1020 #
1021 # vios#sh running-config | section access-list
1022 # ip access-list standard std_acl
1023 # 10 deny 192.168.1.200
1024 # 20 deny 192.168.2.0 0.0.0.255
1025 # ip access-list extended 110
1026 # 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 traceroute dscp ef ttl eq 10
1027 # 20 deny tcp host 198.51.100.0 host 198.51.110.0 eq telnet ack
1028 # ip access-list extended 123
1029 # 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
1030 # 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
1031 # ip access-list extended R1_TRAFFIC
1032 # 10 deny tcp any eq www any eq telnet ack dscp af11
1033 # ip access-list extended test
1034 # 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
1035
1036 - name: Replaces device configuration of listed acls with provided configuration
1037 cisco.ios.ios_acls:
1038 config:
1039 - afi: ipv4
1040 acls:
1041 - name: 110
1042 aces:
1043 - grant: deny
1044 protocol_options:
1045 tcp:
1046 syn: true
1047 source:
1048 address: 192.0.2.0
1049 wildcard_bits: 0.0.0.255
1050 destination:
1051 address: 192.0.3.0
1052 wildcard_bits: 0.0.0.255
1053 port_protocol:
1054 eq: www
1055 dscp: ef
1056 ttl:
1057 eq: 10
1058 - name: 150
1059 aces:
1060 - grant: deny
1061 sequence: 20
1062 protocol_options:
1063 tcp:
1064 syn: true
1065 source:
1066 address: 198.51.100.0
1067 wildcard_bits: 0.0.0.255
1068 port_protocol:
1069 eq: telnet
1070 destination:
1071 address: 198.51.110.0
1072 wildcard_bits: 0.0.0.255
1073 port_protocol:
1074 eq: telnet
1075 dscp: ef
1076 ttl:
1077 eq: 10
1078 state: replaced
1079
1080 # Task Output
1081 # -----------
1082 #
1083 # before:
1084 # - acls:
1085 # - aces:
1086 # - destination:
1087 # address: 192.0.3.0
1088 # wildcard_bits: 0.0.0.255
1089 # dscp: ef
1090 # grant: deny
1091 # protocol: icmp
1092 # protocol_options:
1093 # icmp:
1094 # traceroute: true
1095 # sequence: 10
1096 # source:
1097 # address: 192.0.2.0
1098 # wildcard_bits: 0.0.0.255
1099 # ttl:
1100 # eq: 10
1101 # - destination:
1102 # host: 198.51.110.0
1103 # port_protocol:
1104 # eq: telnet
1105 # grant: deny
1106 # protocol: tcp
1107 # protocol_options:
1108 # tcp:
1109 # ack: true
1110 # sequence: 20
1111 # source:
1112 # host: 198.51.100.0
1113 # acl_type: extended
1114 # name: '110'
1115 # - aces:
1116 # - destination:
1117 # address: 198.51.101.0
1118 # port_protocol:
1119 # eq: telnet
1120 # wildcard_bits: 0.0.0.255
1121 # grant: deny
1122 # protocol: tcp
1123 # protocol_options:
1124 # tcp:
1125 # ack: true
1126 # sequence: 10
1127 # source:
1128 # address: 198.51.100.0
1129 # wildcard_bits: 0.0.0.255
1130 # tos:
1131 # service_value: 12
1132 # - destination:
1133 # address: 192.0.4.0
1134 # port_protocol:
1135 # eq: www
1136 # wildcard_bits: 0.0.0.255
1137 # dscp: ef
1138 # grant: deny
1139 # protocol: tcp
1140 # protocol_options:
1141 # tcp:
1142 # ack: true
1143 # sequence: 20
1144 # source:
1145 # address: 192.0.3.0
1146 # wildcard_bits: 0.0.0.255
1147 # ttl:
1148 # lt: 20
1149 # acl_type: extended
1150 # name: '123'
1151 # - aces:
1152 # - destination:
1153 # any: true
1154 # port_protocol:
1155 # eq: telnet
1156 # dscp: af11
1157 # grant: deny
1158 # protocol: tcp
1159 # protocol_options:
1160 # tcp:
1161 # ack: true
1162 # sequence: 10
1163 # source:
1164 # any: true
1165 # port_protocol:
1166 # eq: www
1167 # acl_type: extended
1168 # name: R1_TRAFFIC
1169 # - aces:
1170 # - grant: deny
1171 # sequence: 10
1172 # source:
1173 # host: 192.168.1.200
1174 # - grant: deny
1175 # sequence: 20
1176 # source:
1177 # address: 192.168.2.0
1178 # wildcard_bits: 0.0.0.255
1179 # acl_type: standard
1180 # name: std_acl
1181 # - aces:
1182 # - destination:
1183 # address: 192.0.3.0
1184 # port_protocol:
1185 # eq: www
1186 # wildcard_bits: 0.0.0.255
1187 # grant: deny
1188 # option:
1189 # traceroute: true
1190 # protocol: tcp
1191 # protocol_options:
1192 # tcp:
1193 # fin: true
1194 # sequence: 10
1195 # source:
1196 # address: 192.0.2.0
1197 # wildcard_bits: 0.0.0.255
1198 # ttl:
1199 # eq: 10
1200 # acl_type: extended
1201 # name: test
1202 # afi: ipv4
1203 # commands:
1204 # - ip access-list extended 110
1205 # - no 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 traceroute dscp ef ttl eq 10
1206 # - no 20 deny tcp host 198.51.100.0 host 198.51.110.0 eq telnet ack
1207 # - deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www syn dscp ef ttl eq 10
1208 # - ip access-list extended 150
1209 # - 20 deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq telnet syn dscp ef ttl eq 10
1210 # after:
1211 # - acls:
1212 # - aces:
1213 # - destination:
1214 # address: 192.0.3.0
1215 # port_protocol:
1216 # eq: www
1217 # wildcard_bits: 0.0.0.255
1218 # dscp: ef
1219 # grant: deny
1220 # protocol: tcp
1221 # protocol_options:
1222 # tcp:
1223 # syn: true
1224 # sequence: 10
1225 # source:
1226 # address: 192.0.2.0
1227 # wildcard_bits: 0.0.0.255
1228 # ttl:
1229 # eq: 10
1230 # acl_type: extended
1231 # name: '110'
1232 # - aces:
1233 # - destination:
1234 # address: 198.51.101.0
1235 # port_protocol:
1236 # eq: telnet
1237 # wildcard_bits: 0.0.0.255
1238 # grant: deny
1239 # protocol: tcp
1240 # protocol_options:
1241 # tcp:
1242 # ack: true
1243 # sequence: 10
1244 # source:
1245 # address: 198.51.100.0
1246 # wildcard_bits: 0.0.0.255
1247 # tos:
1248 # service_value: 12
1249 # - destination:
1250 # address: 192.0.4.0
1251 # port_protocol:
1252 # eq: www
1253 # wildcard_bits: 0.0.0.255
1254 # dscp: ef
1255 # grant: deny
1256 # protocol: tcp
1257 # protocol_options:
1258 # tcp:
1259 # ack: true
1260 # sequence: 20
1261 # source:
1262 # address: 192.0.3.0
1263 # wildcard_bits: 0.0.0.255
1264 # ttl:
1265 # lt: 20
1266 # acl_type: extended
1267 # name: '123'
1268 # - aces:
1269 # - destination:
1270 # address: 198.51.110.0
1271 # port_protocol:
1272 # eq: telnet
1273 # wildcard_bits: 0.0.0.255
1274 # dscp: ef
1275 # grant: deny
1276 # protocol: tcp
1277 # protocol_options:
1278 # tcp:
1279 # syn: true
1280 # sequence: 20
1281 # source:
1282 # address: 198.51.100.0
1283 # port_protocol:
1284 # eq: telnet
1285 # wildcard_bits: 0.0.0.255
1286 # ttl:
1287 # eq: 10
1288 # acl_type: extended
1289 # name: '150'
1290 # - aces:
1291 # - destination:
1292 # any: true
1293 # port_protocol:
1294 # eq: telnet
1295 # dscp: af11
1296 # grant: deny
1297 # protocol: tcp
1298 # protocol_options:
1299 # tcp:
1300 # ack: true
1301 # sequence: 10
1302 # source:
1303 # any: true
1304 # port_protocol:
1305 # eq: www
1306 # acl_type: extended
1307 # name: R1_TRAFFIC
1308 # - aces:
1309 # - grant: deny
1310 # sequence: 10
1311 # source:
1312 # host: 192.168.1.200
1313 # - grant: deny
1314 # sequence: 20
1315 # source:
1316 # address: 192.168.2.0
1317 # wildcard_bits: 0.0.0.255
1318 # acl_type: standard
1319 # name: std_acl
1320 # - aces:
1321 # - destination:
1322 # address: 192.0.3.0
1323 # port_protocol:
1324 # eq: www
1325 # wildcard_bits: 0.0.0.255
1326 # grant: deny
1327 # option:
1328 # traceroute: true
1329 # protocol: tcp
1330 # protocol_options:
1331 # tcp:
1332 # fin: true
1333 # sequence: 10
1334 # source:
1335 # address: 192.0.2.0
1336 # wildcard_bits: 0.0.0.255
1337 # ttl:
1338 # eq: 10
1339 # acl_type: extended
1340 # name: test
1341 # afi: ipv4
1342
1343 # After state:
1344 # -------------
1345 #
1346 # vios#sh access-lists
1347 # ip access-list standard std_acl
1348 # 10 deny 192.168.1.200
1349 # 20 deny 192.168.2.0 0.0.0.255
1350 # ip access-list extended 110
1351 # 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www syn dscp ef ttl eq 10
1352 # ip access-list extended 123
1353 # 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
1354 # 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
1355 # ip access-list extended 150
1356 # 20 deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq telnet syn dscp ef ttl eq 10
1357 # ip access-list extended test
1358 # 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
1359 # ipv6 access-list R1_TRAFFIC
1360 # sequence 10 deny tcp any eq www any eq telnet ack dscp af11
1361
1362 # Using replaced - example remarks specific
1363
1364 # Before state:
1365 # -------------
1366 #
1367 # vios#show running-config | section access-list
1368 # ip access-list extended TEST
1369 # 10 remark FIRST REMARK BEFORE LINE 10
1370 # 10 remark ============
1371 # 10 remark ALLOW HOST FROM TEST 10
1372 # 10 permit ip host 1.1.1.1 any
1373 # 20 remark FIRST REMARK BEFORE LINE 20
1374 # 20 remark ============
1375 # 20 remark ALLOW HOST remarks AFTER LINE 20
1376 # 20 permit ip host 2.2.2.2 any
1377 # 30 remark FIRST REMARK BEFORE LINE 30
1378 # 30 remark ============
1379 # 30 remark ALLOW HOST remarks AFTER LINE 30
1380 # 30 permit ip host 3.3.3.3 any
1381
1382 - name: Replace remarks of ace with sequence 10
1383 # check_mode: true
1384 cisco.ios.ios_acls:
1385 state: replaced
1386 config:
1387 - acls:
1388 - aces:
1389 - destination:
1390 any: true
1391 grant: permit
1392 protocol: ip
1393 remarks:
1394 - The new first remarks before 10
1395 - ============new
1396 - The new second remarks before 10
1397 sequence: 10
1398 source:
1399 host: 1.1.1.1
1400 - destination:
1401 any: true
1402 grant: permit
1403 protocol: ip
1404 remarks:
1405 - FIRST REMARK BEFORE LINE 20
1406 - ============
1407 - ALLOW HOST remarks AFTER LINE 20
1408 sequence: 20
1409 source:
1410 host: 2.2.2.2
1411 - destination:
1412 any: true
1413 grant: permit
1414 protocol: ip
1415 remarks:
1416 - FIRST REMARK BEFORE LINE 30
1417 - ============
1418 - ALLOW HOST remarks AFTER LINE 30
1419 sequence: 30
1420 source:
1421 host: 3.3.3.3
1422 acl_type: extended
1423 name: TEST
1424 afi: ipv4
1425
1426 # Task Output
1427 # -----------
1428 #
1429 # before:
1430 # - acls:
1431 # - aces:
1432 # - destination:
1433 # any: true
1434 # grant: permit
1435 # protocol: ip
1436 # remarks:
1437 # - FIRST REMARK BEFORE LINE 10
1438 # - ===========1=
1439 # - ALLOW HOST FROM TEST 10
1440 # sequence: 10
1441 # source:
1442 # host: 1.1.1.1
1443 # - destination:
1444 # any: true
1445 # grant: permit
1446 # protocol: ip
1447 # remarks:
1448 # - FIRST REMARK BEFORE LINE 20
1449 # - ============
1450 # - ALLOW HOST remarks AFTER LINE 20
1451 # sequence: 20
1452 # source:
1453 # host: 2.2.2.2
1454 # - destination:
1455 # any: true
1456 # grant: permit
1457 # protocol: ip
1458 # remarks:
1459 # - FIRST REMARK BEFORE LINE 30
1460 # - ============
1461 # - ALLOW HOST remarks AFTER LINE 30
1462 # sequence: 30
1463 # source:
1464 # host: 3.3.3.3
1465 # acl_type: extended
1466 # name: TEST
1467 # afi: ipv4
1468 # commands:
1469 # - ip access-list extended TEST
1470 # - no 10 remark
1471 # - 10 remark The new first remarks before 10
1472 # - 10 remark ============new
1473 # - 10 remark The new second remarks before 10
1474 # after:
1475 # - acls:
1476 # - aces:
1477 # - destination:
1478 # any: true
1479 # grant: permit
1480 # protocol: ip
1481 # remarks:
1482 # - The new first remarks before 10
1483 # - ============new
1484 # - The new second remarks before 10
1485 # sequence: 10
1486 # source:
1487 # host: 1.1.1.1
1488 # - destination:
1489 # any: true
1490 # grant: permit
1491 # protocol: ip
1492 # remarks:
1493 # - FIRST REMARK BEFORE LINE 20
1494 # - ============
1495 # - ALLOW HOST remarks AFTER LINE 20
1496 # sequence: 20
1497 # source:
1498 # host: 2.2.2.2
1499 # - destination:
1500 # any: true
1501 # grant: permit
1502 # protocol: ip
1503 # remarks:
1504 # - FIRST REMARK BEFORE LINE 30
1505 # - ============
1506 # - ALLOW HOST remarks AFTER LINE 30
1507 # sequence: 30
1508 # source:
1509 # host: 3.3.3.3
1510 # acl_type: extended
1511 # name: TEST
1512 # afi: ipv4
1513
1514 # After state:
1515 # -------------
1516 #
1517 # foo#show running-config | section access-list
1518 # ip access-list extended TEST
1519 # 10 remark The new first remarks before 10
1520 # 10 remark ============new
1521 # 10 remark The new second remarks before 10
1522 # 10 permit ip host 1.1.1.1 any
1523 # 20 remark FIRST REMARK BEFORE LINE 20
1524 # 20 remark ============
1525 # 20 remark ALLOW HOST remarks AFTER LINE 20
1526 # 20 permit ip host 2.2.2.2 any
1527 # 30 remark FIRST REMARK BEFORE LINE 30
1528 # 30 remark ============
1529 # 30 remark ALLOW HOST remarks AFTER LINE 30
1530 # 30 permit ip host 3.3.3.3 any
1531
1532 # Using replaced - example remarks specific on targeted sequence
1533
1534 # Before state:
1535 # -------------
1536 #
1537 # vios#show running-config | section access-list
1538 # ip access-list extended TEST
1539 # 10 permit ip host 1.1.1.1 any
1540 # 20 remark FIRST REMARK BEFORE LINE 20
1541 # 20 remark ============
1542 # 20 remark ALLOW HOST remarks AFTER LINE 20
1543 # 20 permit ip host 2.2.2.2 any
1544 # 30 remark FIRST REMARK BEFORE LINE 30
1545 # 30 remark ============
1546 # 30 remark ALLOW HOST remarks AFTER LINE 30
1547 # 30 permit ip host 3.3.3.3 any
1548
1549 - name: Replace remarks of ace with sequence 10
1550 # check_mode: true
1551 cisco.ios.ios_acls:
1552 state: replaced
1553 config:
1554 - acls:
1555 - aces:
1556 - destination:
1557 any: true
1558 grant: permit
1559 protocol: ip
1560 remarks:
1561 - The new first remarks before 10
1562 - ============new
1563 - The new second remarks before 10
1564 sequence: 10
1565 source:
1566 host: 1.1.1.1
1567 - destination:
1568 any: true
1569 grant: permit
1570 protocol: ip
1571 remarks:
1572 - FIRST REMARK BEFORE LINE 20
1573 - ============
1574 - ALLOW HOST remarks AFTER LINE 20
1575 sequence: 20
1576 source:
1577 host: 2.2.2.2
1578 - destination:
1579 any: true
1580 grant: permit
1581 protocol: ip
1582 remarks:
1583 - FIRST REMARK BEFORE LINE 30
1584 - ============
1585 - ALLOW HOST remarks AFTER LINE 30
1586 sequence: 30
1587 source:
1588 host: 3.3.3.3
1589 acl_type: extended
1590 name: TEST
1591 afi: ipv4
1592
1593 # Task Output
1594 # -----------
1595 #
1596 # before:
1597 # - acls:
1598 # - aces:
1599 # - destination:
1600 # any: true
1601 # grant: permit
1602 # protocol: ip
1603 # sequence: 10
1604 # source:
1605 # host: 1.1.1.1
1606 # - destination:
1607 # any: true
1608 # grant: permit
1609 # protocol: ip
1610 # remarks:
1611 # - FIRST REMARK BEFORE LINE 20
1612 # - ============
1613 # - ALLOW HOST remarks AFTER LINE 20
1614 # sequence: 20
1615 # source:
1616 # host: 2.2.2.2
1617 # - destination:
1618 # any: true
1619 # grant: permit
1620 # protocol: ip
1621 # remarks:
1622 # - FIRST REMARK BEFORE LINE 30
1623 # - ============
1624 # - ALLOW HOST remarks AFTER LINE 30
1625 # sequence: 30
1626 # source:
1627 # host: 3.3.3.3
1628 # acl_type: extended
1629 # name: TEST
1630 # afi: ipv4
1631 # commands:
1632 # - ip access-list extended TEST
1633 # - 10 remark The new first remarks before 10
1634 # - 10 remark ============new
1635 # - 10 remark The new second remarks before 10
1636 # after:
1637 # - acls:
1638 # - aces:
1639 # - destination:
1640 # any: true
1641 # grant: permit
1642 # protocol: ip
1643 # remarks:
1644 # - The new first remarks before 10
1645 # - ============new
1646 # - The new second remarks before 10
1647 # sequence: 10
1648 # source:
1649 # host: 1.1.1.1
1650 # - destination:
1651 # any: true
1652 # grant: permit
1653 # protocol: ip
1654 # remarks:
1655 # - FIRST REMARK BEFORE LINE 20
1656 # - ============
1657 # - ALLOW HOST remarks AFTER LINE 20
1658 # sequence: 20
1659 # source:
1660 # host: 2.2.2.2
1661 # - destination:
1662 # any: true
1663 # grant: permit
1664 # protocol: ip
1665 # remarks:
1666 # - FIRST REMARK BEFORE LINE 30
1667 # - ============
1668 # - ALLOW HOST remarks AFTER LINE 30
1669 # sequence: 30
1670 # source:
1671 # host: 3.3.3.3
1672 # acl_type: extended
1673 # name: TEST
1674 # afi: ipv4
1675
1676 # After state:
1677 # -------------
1678 #
1679 # foo#show running-config | section access-list
1680 # ip access-list extended TEST
1681 # 10 remark The new first remarks before 10
1682 # 10 remark ============new
1683 # 10 remark The new second remarks before 10
1684 # 10 permit ip host 1.1.1.1 any
1685 # 20 remark FIRST REMARK BEFORE LINE 20
1686 # 20 remark ============
1687 # 20 remark ALLOW HOST remarks AFTER LINE 20
1688 # 20 permit ip host 2.2.2.2 any
1689 # 30 remark FIRST REMARK BEFORE LINE 30
1690 # 30 remark ============
1691 # 30 remark ALLOW HOST remarks AFTER LINE 30
1692 # 30 permit ip host 3.3.3.3 any
1693
1694 # Using overridden
1695
1696 # Before state:
1697 # -------------
1698 #
1699 # vios#sh access-lists
1700 # ip access-list standard std_acl
1701 # 10 deny 192.168.1.200
1702 # 20 deny 192.168.2.0 0.0.0.255
1703 # ip access-list extended 110
1704 # 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 traceroute dscp ef ttl eq 10
1705 # 20 deny tcp host 198.51.100.0 host 198.51.110.0 eq telnet ack
1706 # ip access-list extended 123
1707 # 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
1708 # 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
1709 # ip access-list extended R1_TRAFFIC
1710 # 10 deny tcp any eq www any eq telnet ack dscp af11
1711 # ip access-list extended test
1712 # 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
1713
1714 - name: Override device configuration of all acls with provided configuration
1715 cisco.ios.ios_acls:
1716 config:
1717 - afi: ipv4
1718 acls:
1719 - name: 110
1720 aces:
1721 - grant: deny
1722 sequence: 20
1723 protocol_options:
1724 tcp:
1725 ack: true
1726 source:
1727 address: 198.51.100.0
1728 wildcard_bits: 0.0.0.255
1729 port_protocol:
1730 eq: telnet
1731 destination:
1732 address: 198.51.110.0
1733 wildcard_bits: 0.0.0.255
1734 port_protocol:
1735 eq: www
1736 dscp: ef
1737 ttl:
1738 eq: 10
1739 - name: 150
1740 aces:
1741 - grant: deny
1742 sequence: 10
1743 protocol_options:
1744 tcp:
1745 syn: true
1746 source:
1747 address: 198.51.100.0
1748 wildcard_bits: 0.0.0.255
1749 port_protocol:
1750 eq: telnet
1751 destination:
1752 address: 198.51.110.0
1753 wildcard_bits: 0.0.0.255
1754 port_protocol:
1755 eq: telnet
1756 dscp: ef
1757 ttl:
1758 eq: 10
1759 - name: implicit_deny
1760 aces:
1761 - grant: deny
1762 sequence: 10
1763 protocol_options:
1764 tcp:
1765 syn: true
1766 source:
1767 address: 198.51.100.0
1768 wildcard_bits: 0.0.0.255
1769 port_protocol:
1770 eq: telnet
1771 destination:
1772 address: 198.51.110.0
1773 wildcard_bits: 0.0.0.255
1774 port_protocol:
1775 eq: telnet
1776 dscp: ef
1777 ttl:
1778 eq: 10
1779 state: overridden
1780
1781 # Task Output
1782 # -----------
1783 #
1784 # before:
1785 # - acls:
1786 # - aces:
1787 # - destination:
1788 # address: 192.0.3.0
1789 # wildcard_bits: 0.0.0.255
1790 # dscp: ef
1791 # grant: deny
1792 # protocol: icmp
1793 # protocol_options:
1794 # icmp:
1795 # traceroute: true
1796 # sequence: 10
1797 # source:
1798 # address: 192.0.2.0
1799 # wildcard_bits: 0.0.0.255
1800 # ttl:
1801 # eq: 10
1802 # - destination:
1803 # host: 198.51.110.0
1804 # port_protocol:
1805 # eq: telnet
1806 # grant: deny
1807 # protocol: tcp
1808 # protocol_options:
1809 # tcp:
1810 # ack: true
1811 # sequence: 20
1812 # source:
1813 # host: 198.51.100.0
1814 # acl_type: extended
1815 # name: '110'
1816 # - aces:
1817 # - destination:
1818 # address: 198.51.101.0
1819 # port_protocol:
1820 # eq: telnet
1821 # wildcard_bits: 0.0.0.255
1822 # grant: deny
1823 # protocol: tcp
1824 # protocol_options:
1825 # tcp:
1826 # ack: true
1827 # sequence: 10
1828 # source:
1829 # address: 198.51.100.0
1830 # wildcard_bits: 0.0.0.255
1831 # tos:
1832 # service_value: 12
1833 # - destination:
1834 # address: 192.0.4.0
1835 # port_protocol:
1836 # eq: www
1837 # wildcard_bits: 0.0.0.255
1838 # dscp: ef
1839 # grant: deny
1840 # protocol: tcp
1841 # protocol_options:
1842 # tcp:
1843 # ack: true
1844 # sequence: 20
1845 # source:
1846 # address: 192.0.3.0
1847 # wildcard_bits: 0.0.0.255
1848 # ttl:
1849 # lt: 20
1850 # acl_type: extended
1851 # name: '123'
1852 # - aces:
1853 # - destination:
1854 # any: true
1855 # port_protocol:
1856 # eq: telnet
1857 # dscp: af11
1858 # grant: deny
1859 # protocol: tcp
1860 # protocol_options:
1861 # tcp:
1862 # ack: true
1863 # sequence: 10
1864 # source:
1865 # any: true
1866 # port_protocol:
1867 # eq: www
1868 # acl_type: extended
1869 # name: R1_TRAFFIC
1870 # - aces:
1871 # - grant: deny
1872 # sequence: 10
1873 # source:
1874 # host: 192.168.1.200
1875 # - grant: deny
1876 # sequence: 20
1877 # source:
1878 # address: 192.168.2.0
1879 # wildcard_bits: 0.0.0.255
1880 # acl_type: standard
1881 # name: std_acl
1882 # - aces:
1883 # - destination:
1884 # address: 192.0.3.0
1885 # port_protocol:
1886 # eq: www
1887 # wildcard_bits: 0.0.0.255
1888 # grant: deny
1889 # option:
1890 # traceroute: true
1891 # protocol: tcp
1892 # protocol_options:
1893 # tcp:
1894 # fin: true
1895 # sequence: 10
1896 # source:
1897 # address: 192.0.2.0
1898 # wildcard_bits: 0.0.0.255
1899 # ttl:
1900 # eq: 10
1901 # acl_type: extended
1902 # name: test
1903 # afi: ipv4
1904 # commands:
1905 # - ip access-list extended 110
1906 # - no 20 deny tcp host 198.51.100.0 host 198.51.110.0 eq telnet ack
1907 # - no 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 traceroute dscp ef ttl eq 10
1908 # - 20 deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq www ack dscp ef ttl eq 10
1909 # - ip access-list extended 150
1910 # - 10 deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq telnet syn dscp ef ttl eq 10
1911 # - no ip access-list extended 123
1912 # - no ip access-list extended R1_TRAFFIC
1913 # - no ip access-list standard std_acl
1914 # - no ip access-list extended test
1915 # after:
1916 # - acls:
1917 # - aces:
1918 # - destination:
1919 # address: 198.51.110.0
1920 # port_protocol:
1921 # eq: www
1922 # wildcard_bits: 0.0.0.255
1923 # dscp: ef
1924 # grant: deny
1925 # protocol: tcp
1926 # protocol_options:
1927 # tcp:
1928 # ack: true
1929 # sequence: 20
1930 # source:
1931 # address: 198.51.100.0
1932 # port_protocol:
1933 # eq: telnet
1934 # wildcard_bits: 0.0.0.255
1935 # ttl:
1936 # eq: 10
1937 # acl_type: extended
1938 # name: '110'
1939 # - aces:
1940 # - destination:
1941 # address: 198.51.110.0
1942 # port_protocol:
1943 # eq: telnet
1944 # wildcard_bits: 0.0.0.255
1945 # dscp: ef
1946 # grant: deny
1947 # protocol: tcp
1948 # protocol_options:
1949 # tcp:
1950 # syn: true
1951 # sequence: 10
1952 # source:
1953 # address: 198.51.100.0
1954 # port_protocol:
1955 # eq: telnet
1956 # wildcard_bits: 0.0.0.255
1957 # ttl:
1958 # eq: 10
1959 # acl_type: extended
1960 # name: '150'
1961 # afi: ipv4
1962
1963 # After state:
1964 # -------------
1965 #
1966 # vios#sh running-config | section access-list
1967 # ip access-list extended 110
1968 # 20 deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq www ack dscp ef ttl eq 10
1969 # ip access-list extended 150
1970 # 10 deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq telnet syn dscp ef ttl eq 10
1971
1972 # Using overridden - example remarks specific on multiple sequence
1973
1974 # Before state:
1975 # -------------
1976 #
1977 # vios#show running-config | section access-list
1978 # ip access-list extended TEST
1979 # 10 remark FIRST REMARK BEFORE SEQUENCE 10
1980 # 10 remark ============
1981 # 10 remark REMARKS FOR SEQUENCE 10 NO FOLLOWING ACE
1982 # 20 remark FIRST REMARK BEFORE SEQUENCE 20
1983 # 20 remark ============
1984 # 20 remark ALLOW HOST FROM SEQUENCE 20
1985 # 20 permit ip host 1.1.1.1 any
1986 # 30 remark FIRST REMARK BEFORE SEQUENCE 30
1987 # 30 remark ============
1988 # 30 remark ALLOW HOST FROM SEQUENCE 30
1989 # 30 permit ip host 2.2.2.2 any
1990 # 40 remark FIRST REMARK BEFORE SEQUENCE 40
1991 # 40 remark ============
1992 # 40 remark ALLOW NEW HOST FROM SEQUENCE 40
1993 # 40 permit ip host 3.3.3.3 any
1994 # remark Remark not specific to sequence
1995 # remark ============
1996 # remark End Remarks
1997 # ip access-list extended test_acl
1998 # 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
1999 # ip access-list extended 110
2000 # 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
2001 # ip access-list extended 123
2002 # 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
2003 # 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
2004 # ipv6 access-list R1_TRAFFIC
2005 # sequence 10 deny tcp any eq www any eq telnet ack dscp af11
2006
2007 - name: Override remarks and ace configurations
2008 cisco.ios.ios_acls:
2009 config:
2010 - afi: ipv4
2011 acls:
2012 - name: TEST
2013 acl_type: extended
2014 aces:
2015 - sequence: 10
2016 remarks:
2017 - "FIRST REMARK BEFORE SEQUENCE 10"
2018 - "============"
2019 - "REMARKS FOR SEQUENCE 10 NO FOLLOWING ACE"
2020 grant: permit
2021 protocol: ip
2022 source:
2023 host: 1.1.1.1
2024 destination:
2025 any: true
2026 - sequence: 20
2027 remarks:
2028 - "FIRST REMARK BEFORE SEQUENCE 20"
2029 - "============"
2030 - "ALLOW HOST FROM SEQUENCE 20"
2031 grant: permit
2032 protocol: ip
2033 source:
2034 host: 192.168.0.1
2035 destination:
2036 any: true
2037 - sequence: 30
2038 remarks:
2039 - "FIRST REMARK BEFORE SEQUENCE 30"
2040 - "============"
2041 - "ALLOW HOST FROM SEQUENCE 30 updated"
2042 grant: permit
2043 protocol: ip
2044 source:
2045 host: 2.2.2.2
2046 destination:
2047 any: true
2048 - sequence: 40
2049 remarks:
2050 - "FIRST REMARK BEFORE SEQUENCE 40"
2051 - "============"
2052 - "ALLOW NEW HOST FROM SEQUENCE 40"
2053 grant: permit
2054 protocol: ip
2055 source:
2056 host: 3.3.3.3
2057 destination:
2058 any: true
2059 - remarks:
2060 - "Remark not specific to sequence"
2061 - "============"
2062 - "End Remarks 1"
2063 state: overridden
2064
2065 # Task Output
2066 # -----------
2067 #
2068 # before:
2069 # - acls:
2070 # - aces:
2071 # - destination:
2072 # address: 192.0.3.0
2073 # wildcard_bits: 0.0.0.255
2074 # dscp: ef
2075 # grant: deny
2076 # protocol: icmp
2077 # protocol_options:
2078 # icmp:
2079 # echo: true
2080 # sequence: 10
2081 # source:
2082 # address: 192.0.2.0
2083 # wildcard_bits: 0.0.0.255
2084 # ttl:
2085 # eq: 10
2086 # acl_type: extended
2087 # name: '110'
2088 # - aces:
2089 # - destination:
2090 # address: 198.51.101.0
2091 # port_protocol:
2092 # eq: telnet
2093 # wildcard_bits: 0.0.0.255
2094 # grant: deny
2095 # protocol: tcp
2096 # protocol_options:
2097 # tcp:
2098 # ack: true
2099 # sequence: 10
2100 # source:
2101 # address: 198.51.100.0
2102 # wildcard_bits: 0.0.0.255
2103 # tos:
2104 # service_value: 12
2105 # - destination:
2106 # address: 192.0.4.0
2107 # port_protocol:
2108 # eq: www
2109 # wildcard_bits: 0.0.0.255
2110 # dscp: ef
2111 # grant: deny
2112 # protocol: tcp
2113 # protocol_options:
2114 # tcp:
2115 # ack: true
2116 # sequence: 20
2117 # source:
2118 # address: 192.0.3.0
2119 # wildcard_bits: 0.0.0.255
2120 # ttl:
2121 # lt: 20
2122 # acl_type: extended
2123 # name: '123'
2124 # - aces:
2125 # - destination:
2126 # any: true
2127 # grant: permit
2128 # protocol: ip
2129 # remarks:
2130 # - FIRST REMARK BEFORE SEQUENCE 20
2131 # - ============
2132 # - ALLOW HOST FROM SEQUENCE 20
2133 # sequence: 20
2134 # source:
2135 # host: 1.1.1.1
2136 # - destination:
2137 # any: true
2138 # grant: permit
2139 # protocol: ip
2140 # remarks:
2141 # - FIRST REMARK BEFORE SEQUENCE 30
2142 # - ============
2143 # - ALLOW HOST FROM SEQUENCE 30
2144 # sequence: 30
2145 # source:
2146 # host: 2.2.2.2
2147 # - destination:
2148 # any: true
2149 # grant: permit
2150 # protocol: ip
2151 # remarks:
2152 # - FIRST REMARK BEFORE SEQUENCE 40
2153 # - ============
2154 # - ALLOW NEW HOST FROM SEQUENCE 40
2155 # sequence: 40
2156 # source:
2157 # host: 3.3.3.3
2158 # - remarks:
2159 # - FIRST REMARK BEFORE SEQUENCE 10
2160 # - ============
2161 # - REMARKS FOR SEQUENCE 10 NO FOLLOWING ACE
2162 # sequence: 10
2163 # - remarks:
2164 # - Remark not specific to sequence
2165 # - ============
2166 # - End Remarks
2167 # acl_type: extended
2168 # name: TEST
2169 # - aces:
2170 # - destination:
2171 # address: 192.0.3.0
2172 # port_protocol:
2173 # eq: www
2174 # wildcard_bits: 0.0.0.255
2175 # grant: deny
2176 # option:
2177 # traceroute: true
2178 # protocol: tcp
2179 # protocol_options:
2180 # tcp:
2181 # fin: true
2182 # sequence: 10
2183 # source:
2184 # address: 192.0.2.0
2185 # wildcard_bits: 0.0.0.255
2186 # ttl:
2187 # eq: 10
2188 # acl_type: extended
2189 # name: test_acl
2190 # afi: ipv4
2191 # - acls:
2192 # - aces:
2193 # - destination:
2194 # any: true
2195 # port_protocol:
2196 # eq: telnet
2197 # dscp: af11
2198 # grant: deny
2199 # protocol: tcp
2200 # protocol_options:
2201 # tcp:
2202 # ack: true
2203 # sequence: 10
2204 # source:
2205 # any: true
2206 # port_protocol:
2207 # eq: www
2208 # name: R1_TRAFFIC
2209 # afi: ipv6
2210 # commands:
2211 # - no ipv6 access-list R1_TRAFFIC
2212 # - ip access-list extended TEST
2213 # - no 10 # removes all remarks and ace entry for sequence 10
2214 # - no 20 permit ip host 1.1.1.1 any # removing the ace automatically removes the remarks
2215 # - no 30 remark # just remove remarks for sequence 30
2216 # - no remark # remove all remarks at end of acl, that has no sequence
2217 # - 10 remark FIRST REMARK BEFORE SEQUENCE 10
2218 # - 10 remark ============
2219 # - 10 remark REMARKS FOR SEQUENCE 10 NO FOLLOWING ACE
2220 # - 10 permit ip host 1.1.1.1 any
2221 # - 20 remark FIRST REMARK BEFORE SEQUENCE 20
2222 # - 20 remark ============
2223 # - 20 remark ALLOW HOST FROM SEQUENCE 20
2224 # - 20 permit ip host 192.168.0.1 any
2225 # - 30 remark FIRST REMARK BEFORE SEQUENCE 30
2226 # - 30 remark ============
2227 # - 30 remark ALLOW HOST FROM SEQUENCE 30 updated
2228 # - remark Remark not specific to sequence
2229 # - remark ============
2230 # - remark End Remarks 1
2231 # - no ip access-list extended 110
2232 # - no ip access-list extended 123
2233 # - no ip access-list extended test_acl
2234 # after:
2235 # - acls:
2236 # - aces:
2237 # - destination:
2238 # any: true
2239 # grant: permit
2240 # protocol: ip
2241 # remarks:
2242 # - FIRST REMARK BEFORE SEQUENCE 10
2243 # - ============
2244 # - REMARKS FOR SEQUENCE 10 NO FOLLOWING ACE
2245 # sequence: 10
2246 # source:
2247 # host: 1.1.1.1
2248 # - destination:
2249 # any: true
2250 # grant: permit
2251 # protocol: ip
2252 # remarks:
2253 # - FIRST REMARK BEFORE SEQUENCE 20
2254 # - ============
2255 # - ALLOW HOST FROM SEQUENCE 20
2256 # sequence: 20
2257 # source:
2258 # host: 192.168.0.1
2259 # - destination:
2260 # any: true
2261 # grant: permit
2262 # protocol: ip
2263 # remarks:
2264 # - FIRST REMARK BEFORE SEQUENCE 30
2265 # - ============
2266 # - ALLOW HOST FROM SEQUENCE 30 updated
2267 # sequence: 30
2268 # source:
2269 # host: 2.2.2.2
2270 # - destination:
2271 # any: true
2272 # grant: permit
2273 # protocol: ip
2274 # remarks:
2275 # - FIRST REMARK BEFORE SEQUENCE 40
2276 # - ============
2277 # - ALLOW NEW HOST FROM SEQUENCE 40
2278 # sequence: 40
2279 # source:
2280 # host: 3.3.3.3
2281 # - remarks:
2282 # - Remark not specific to sequence
2283 # - ============
2284 # - End Remarks 1
2285 # acl_type: extended
2286 # name: TEST
2287 # afi: ipv4
2288
2289 # After state:
2290 # -------------
2291 #
2292 # foo#show running-config | section access-list
2293 # ip access-list extended TEST
2294 # 10 remark FIRST REMARK BEFORE SEQUENCE 10
2295 # 10 remark ============
2296 # 10 remark REMARKS FOR SEQUENCE 10 NO FOLLOWING ACE
2297 # 10 permit ip host 1.1.1.1 any
2298 # 20 remark FIRST REMARK BEFORE SEQUENCE 20
2299 # 20 remark ============
2300 # 20 remark ALLOW HOST FROM SEQUENCE 20
2301 # 20 permit ip host 192.168.0.1 any
2302 # 30 remark FIRST REMARK BEFORE SEQUENCE 30
2303 # 30 remark ============
2304 # 30 remark ALLOW HOST FROM SEQUENCE 30 updated
2305 # 30 permit ip host 2.2.2.2 any
2306 # 40 remark FIRST REMARK BEFORE SEQUENCE 40
2307 # 40 remark ============
2308 # 40 remark ALLOW NEW HOST FROM SEQUENCE 40
2309 # 40 permit ip host 3.3.3.3 any
2310 # remark Remark not specific to sequence
2311 # remark ============
2312 # remark End Remarks 1
2313
2314 # Using deleted - delete ACL(s)
2315
2316 # Before state:
2317 # -------------
2318 #
2319 # vios#sh access-lists
2320 # ip access-list standard std_acl
2321 # 10 deny 192.168.1.200
2322 # 20 deny 192.168.2.0 0.0.0.255
2323 # ip access-list extended 110
2324 # 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 traceroute dscp ef ttl eq 10
2325 # 20 deny tcp host 198.51.100.0 host 198.51.110.0 eq telnet ack
2326 # ip access-list extended 123
2327 # 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
2328 # 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
2329 # ip access-list extended extended_acl_1
2330 # 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
2331
2332 - name: "Delete ACLs (Note: This won't delete the all configured ACLs)"
2333 cisco.ios.ios_acls:
2334 config:
2335 - afi: ipv4
2336 acls:
2337 - name: extended_acl_1
2338 acl_type: extended
2339 - name: 110
2340 state: deleted
2341
2342 # Task Output
2343 # -----------
2344 #
2345 # before:
2346 # - acls:
2347 # - aces:
2348 # - destination:
2349 # address: 192.0.3.0
2350 # wildcard_bits: 0.0.0.255
2351 # dscp: ef
2352 # grant: deny
2353 # protocol: icmp
2354 # protocol_options:
2355 # icmp:
2356 # traceroute: true
2357 # sequence: 10
2358 # source:
2359 # address: 192.0.2.0
2360 # wildcard_bits: 0.0.0.255
2361 # ttl:
2362 # eq: 10
2363 # - destination:
2364 # host: 198.51.110.0
2365 # port_protocol:
2366 # eq: telnet
2367 # grant: deny
2368 # protocol: tcp
2369 # protocol_options:
2370 # tcp:
2371 # ack: true
2372 # sequence: 20
2373 # source:
2374 # host: 198.51.100.0
2375 # acl_type: extended
2376 # name: '110'
2377 # - aces:
2378 # - destination:
2379 # address: 198.51.101.0
2380 # port_protocol:
2381 # eq: telnet
2382 # wildcard_bits: 0.0.0.255
2383 # grant: deny
2384 # protocol: tcp
2385 # protocol_options:
2386 # tcp:
2387 # ack: true
2388 # sequence: 10
2389 # source:
2390 # address: 198.51.100.0
2391 # wildcard_bits: 0.0.0.255
2392 # tos:
2393 # service_value: 12
2394 # - destination:
2395 # address: 192.0.4.0
2396 # port_protocol:
2397 # eq: www
2398 # wildcard_bits: 0.0.0.255
2399 # dscp: ef
2400 # grant: deny
2401 # protocol: tcp
2402 # protocol_options:
2403 # tcp:
2404 # ack: true
2405 # sequence: 20
2406 # source:
2407 # address: 192.0.3.0
2408 # wildcard_bits: 0.0.0.255
2409 # ttl:
2410 # lt: 20
2411 # acl_type: extended
2412 # name: '123'
2413 # - aces:
2414 # - grant: deny
2415 # sequence: 10
2416 # source:
2417 # host: 192.168.1.200
2418 # - grant: deny
2419 # sequence: 20
2420 # source:
2421 # address: 192.168.2.0
2422 # wildcard_bits: 0.0.0.255
2423 # acl_type: standard
2424 # name: std_acl
2425 # - aces:
2426 # - destination:
2427 # address: 192.0.3.0
2428 # port_protocol:
2429 # eq: www
2430 # wildcard_bits: 0.0.0.255
2431 # grant: deny
2432 # option:
2433 # traceroute: true
2434 # protocol: tcp
2435 # protocol_options:
2436 # tcp:
2437 # fin: true
2438 # sequence: 10
2439 # source:
2440 # address: 192.0.2.0
2441 # wildcard_bits: 0.0.0.255
2442 # ttl:
2443 # eq: 10
2444 # acl_type: extended
2445 # name: extended_acl_1
2446 # afi: ipv4
2447 # commands:
2448 # - no ip access-list extended 110
2449 # - no ip access-list extended extended_acl_1
2450 # after:
2451 # - acls:
2452 # - aces:
2453 # - destination:
2454 # address: 198.51.101.0
2455 # port_protocol:
2456 # eq: telnet
2457 # wildcard_bits: 0.0.0.255
2458 # grant: deny
2459 # protocol: tcp
2460 # protocol_options:
2461 # tcp:
2462 # ack: true
2463 # sequence: 10
2464 # source:
2465 # address: 198.51.100.0
2466 # wildcard_bits: 0.0.0.255
2467 # tos:
2468 # service_value: 12
2469 # - destination:
2470 # address: 192.0.4.0
2471 # port_protocol:
2472 # eq: www
2473 # wildcard_bits: 0.0.0.255
2474 # dscp: ef
2475 # grant: deny
2476 # protocol: tcp
2477 # protocol_options:
2478 # tcp:
2479 # ack: true
2480 # sequence: 20
2481 # source:
2482 # address: 192.0.3.0
2483 # wildcard_bits: 0.0.0.255
2484 # ttl:
2485 # lt: 20
2486 # acl_type: extended
2487 # name: '123'
2488 # - aces:
2489 # - grant: deny
2490 # sequence: 10
2491 # source:
2492 # host: 192.168.1.200
2493 # - grant: deny
2494 # sequence: 20
2495 # source:
2496 # address: 192.168.2.0
2497 # wildcard_bits: 0.0.0.255
2498 # acl_type: standard
2499 # name: std_acl
2500 # afi: ipv4
2501
2502 # After state:
2503 # -------------
2504 #
2505 # vios#sh running-config | section access-list
2506 # ip access-list standard std_acl
2507 # 10 deny 192.168.1.200
2508 # 20 deny 192.168.2.0 0.0.0.255
2509 # ip access-list extended 123
2510 # 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
2511 # 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
2512
2513 # Using deleted - delete ACLs based on AFI
2514
2515 # Before state:
2516 # -------------
2517 #
2518 # vios#sh running-config | section access-list
2519 # ip access-list standard std_acl
2520 # 10 deny 192.168.1.200
2521 # 20 deny 192.168.2.0 0.0.0.255
2522 # ip access-list extended 110
2523 # 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 traceroute dscp ef ttl eq 10
2524 # 20 deny tcp host 198.51.100.0 host 198.51.110.0 eq telnet ack
2525 # ip access-list extended 123
2526 # 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
2527 # 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
2528 # ip access-list extended test
2529 # 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
2530 # ipv6 access-list R1_TRAFFIC
2531 # sequence 10 deny tcp any eq www any eq telnet ack dscp af11
2532
2533 - name: "Delete ACLs based on AFI (Note: This won't delete the all configured ACLs)"
2534 cisco.ios.ios_acls:
2535 config:
2536 - afi: ipv4
2537 state: deleted
2538
2539 # Task Output
2540 # -----------
2541 #
2542 # before:
2543 # - acls:
2544 # - aces:
2545 # - destination:
2546 # address: 192.0.3.0
2547 # wildcard_bits: 0.0.0.255
2548 # dscp: ef
2549 # grant: deny
2550 # protocol: icmp
2551 # protocol_options:
2552 # icmp:
2553 # traceroute: true
2554 # sequence: 10
2555 # source:
2556 # address: 192.0.2.0
2557 # wildcard_bits: 0.0.0.255
2558 # ttl:
2559 # eq: 10
2560 # - destination:
2561 # host: 198.51.110.0
2562 # port_protocol:
2563 # eq: telnet
2564 # grant: deny
2565 # protocol: tcp
2566 # protocol_options:
2567 # tcp:
2568 # ack: true
2569 # sequence: 20
2570 # source:
2571 # host: 198.51.100.0
2572 # acl_type: extended
2573 # name: '110'
2574 # - aces:
2575 # - destination:
2576 # address: 198.51.101.0
2577 # port_protocol:
2578 # eq: telnet
2579 # wildcard_bits: 0.0.0.255
2580 # grant: deny
2581 # protocol: tcp
2582 # protocol_options:
2583 # tcp:
2584 # ack: true
2585 # sequence: 10
2586 # source:
2587 # address: 198.51.100.0
2588 # wildcard_bits: 0.0.0.255
2589 # tos:
2590 # service_value: 12
2591 # - destination:
2592 # address: 192.0.4.0
2593 # port_protocol:
2594 # eq: www
2595 # wildcard_bits: 0.0.0.255
2596 # dscp: ef
2597 # grant: deny
2598 # protocol: tcp
2599 # protocol_options:
2600 # tcp:
2601 # ack: true
2602 # sequence: 20
2603 # source:
2604 # address: 192.0.3.0
2605 # wildcard_bits: 0.0.0.255
2606 # ttl:
2607 # lt: 20
2608 # acl_type: extended
2609 # name: '123'
2610 # - aces:
2611 # - grant: deny
2612 # sequence: 10
2613 # source:
2614 # host: 192.168.1.200
2615 # - grant: deny
2616 # sequence: 20
2617 # source:
2618 # address: 192.168.2.0
2619 # wildcard_bits: 0.0.0.255
2620 # acl_type: standard
2621 # name: std_acl
2622 # - aces:
2623 # - destination:
2624 # address: 192.0.3.0
2625 # port_protocol:
2626 # eq: www
2627 # wildcard_bits: 0.0.0.255
2628 # grant: deny
2629 # option:
2630 # traceroute: true
2631 # protocol: tcp
2632 # protocol_options:
2633 # tcp:
2634 # fin: true
2635 # sequence: 10
2636 # source:
2637 # address: 192.0.2.0
2638 # wildcard_bits: 0.0.0.255
2639 # ttl:
2640 # eq: 10
2641 # acl_type: extended
2642 # name: test
2643 # afi: ipv4
2644 # - acls:
2645 # - aces:
2646 # - destination:
2647 # any: true
2648 # port_protocol:
2649 # eq: telnet
2650 # dscp: af11
2651 # grant: deny
2652 # protocol: tcp
2653 # protocol_options:
2654 # tcp:
2655 # ack: true
2656 # sequence: 10
2657 # source:
2658 # any: true
2659 # port_protocol:
2660 # eq: www
2661 # name: R1_TRAFFIC
2662 # afi: ipv6
2663 # commands:
2664 # - no ip access-list extended 110
2665 # - no ip access-list extended 123
2666 # - no ip access-list standard std_acl
2667 # - no ip access-list extended test
2668 # after:
2669 # - acls:
2670 # - aces:
2671 # - destination:
2672 # any: true
2673 # port_protocol:
2674 # eq: telnet
2675 # dscp: af11
2676 # grant: deny
2677 # protocol: tcp
2678 # protocol_options:
2679 # tcp:
2680 # ack: true
2681 # sequence: 10
2682 # source:
2683 # any: true
2684 # port_protocol:
2685 # eq: www
2686 # name: R1_TRAFFIC
2687 # afi: ipv6
2688
2689 # After state:
2690 # -------------
2691 #
2692 # vios#sh running-config | section access-list
2693 # ipv6 access-list R1_TRAFFIC
2694 # sequence 10 deny tcp any eq www any eq telnet ack dscp af11
2695
2696
2697 # Using deleted - delete all ACLs
2698
2699 # Before state:
2700 # -------------
2701 #
2702 # vios#sh access-lists
2703 # ip access-list standard std_acl
2704 # 10 deny 192.168.1.200
2705 # 20 deny 192.168.2.0 0.0.0.255
2706 # ip access-list extended 110
2707 # 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 traceroute dscp ef ttl eq 10
2708 # 20 deny tcp host 198.51.100.0 host 198.51.110.0 eq telnet ack
2709 # ip access-list extended 123
2710 # 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
2711 # 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
2712 # ip access-list extended test
2713 # 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
2714 # ipv6 access-list R1_TRAFFIC
2715 # sequence 10 deny tcp any eq www any eq telnet ack dscp af11
2716
2717 - name: Delete ALL of configured ACLs
2718 cisco.ios.ios_acls:
2719 state: deleted
2720
2721 # Task Output
2722 # -----------
2723 #
2724 # before:
2725 # - acls:
2726 # - aces:
2727 # - destination:
2728 # address: 192.0.3.0
2729 # wildcard_bits: 0.0.0.255
2730 # dscp: ef
2731 # grant: deny
2732 # protocol: icmp
2733 # protocol_options:
2734 # icmp:
2735 # traceroute: true
2736 # sequence: 10
2737 # source:
2738 # address: 192.0.2.0
2739 # wildcard_bits: 0.0.0.255
2740 # ttl:
2741 # eq: 10
2742 # - destination:
2743 # host: 198.51.110.0
2744 # port_protocol:
2745 # eq: telnet
2746 # grant: deny
2747 # protocol: tcp
2748 # protocol_options:
2749 # tcp:
2750 # ack: true
2751 # sequence: 20
2752 # source:
2753 # host: 198.51.100.0
2754 # acl_type: extended
2755 # name: '110'
2756 # - aces:
2757 # - destination:
2758 # address: 198.51.101.0
2759 # port_protocol:
2760 # eq: telnet
2761 # wildcard_bits: 0.0.0.255
2762 # grant: deny
2763 # protocol: tcp
2764 # protocol_options:
2765 # tcp:
2766 # ack: true
2767 # sequence: 10
2768 # source:
2769 # address: 198.51.100.0
2770 # wildcard_bits: 0.0.0.255
2771 # tos:
2772 # service_value: 12
2773 # - destination:
2774 # address: 192.0.4.0
2775 # port_protocol:
2776 # eq: www
2777 # wildcard_bits: 0.0.0.255
2778 # dscp: ef
2779 # grant: deny
2780 # protocol: tcp
2781 # protocol_options:
2782 # tcp:
2783 # ack: true
2784 # sequence: 20
2785 # source:
2786 # address: 192.0.3.0
2787 # wildcard_bits: 0.0.0.255
2788 # ttl:
2789 # lt: 20
2790 # acl_type: extended
2791 # name: '123'
2792 # - aces:
2793 # - grant: deny
2794 # sequence: 10
2795 # source:
2796 # host: 192.168.1.200
2797 # - grant: deny
2798 # sequence: 20
2799 # source:
2800 # address: 192.168.2.0
2801 # wildcard_bits: 0.0.0.255
2802 # acl_type: standard
2803 # name: std_acl
2804 # - aces:
2805 # - destination:
2806 # address: 192.0.3.0
2807 # port_protocol:
2808 # eq: www
2809 # wildcard_bits: 0.0.0.255
2810 # grant: deny
2811 # option:
2812 # traceroute: true
2813 # protocol: tcp
2814 # protocol_options:
2815 # tcp:
2816 # fin: true
2817 # sequence: 10
2818 # source:
2819 # address: 192.0.2.0
2820 # wildcard_bits: 0.0.0.255
2821 # ttl:
2822 # eq: 10
2823 # acl_type: extended
2824 # name: test
2825 # afi: ipv4
2826 # - acls:
2827 # - aces:
2828 # - destination:
2829 # any: true
2830 # port_protocol:
2831 # eq: telnet
2832 # dscp: af11
2833 # grant: deny
2834 # protocol: tcp
2835 # protocol_options:
2836 # tcp:
2837 # ack: true
2838 # sequence: 10
2839 # source:
2840 # any: true
2841 # port_protocol:
2842 # eq: www
2843 # name: R1_TRAFFIC
2844 # afi: ipv6
2845 # commands:
2846 # - no ip access-list extended test
2847 # - no ip access-list extended 110
2848 # - no ip access-list extended 123
2849 # - no ip access-list extended test
2850 # - no ipv6 access-list R1_TRAFFIC
2851 # after: []
2852
2853 # After state:
2854 # -------------
2855 #
2856 # vios#sh running-config | section access-list
2857
2858
2859 # Using gathered
2860
2861 # Before state:
2862 # -------------
2863 #
2864 # vios#sh access-lists
2865 # ip access-list standard std_acl
2866 # 10 deny 192.168.1.200
2867 # 20 deny 192.168.2.0 0.0.0.255
2868 # ip access-list extended 110
2869 # 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 traceroute dscp ef ttl eq 10
2870 # 20 deny tcp host 198.51.100.0 host 198.51.110.0 eq telnet ack
2871 # ip access-list extended 123
2872 # 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
2873 # 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
2874 # ip access-list extended test
2875 # 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
2876 # ipv6 access-list R1_TRAFFIC
2877 # sequence 10 deny tcp any eq www any eq telnet ack dscp af11
2878
2879 - name: Gather ACLs configuration from target device
2880 cisco.ios.ios_acls:
2881 state: gathered
2882
2883 # Module Execution Result:
2884 # ------------------------
2885 #
2886 # before:
2887 # - acls:
2888 # - aces:
2889 # - destination:
2890 # address: 192.0.3.0
2891 # wildcard_bits: 0.0.0.255
2892 # dscp: ef
2893 # grant: deny
2894 # protocol: icmp
2895 # protocol_options:
2896 # icmp:
2897 # traceroute: true
2898 # sequence: 10
2899 # source:
2900 # address: 192.0.2.0
2901 # wildcard_bits: 0.0.0.255
2902 # ttl:
2903 # eq: 10
2904 # - destination:
2905 # host: 198.51.110.0
2906 # port_protocol:
2907 # eq: telnet
2908 # grant: deny
2909 # protocol: tcp
2910 # protocol_options:
2911 # tcp:
2912 # ack: true
2913 # sequence: 20
2914 # source:
2915 # host: 198.51.100.0
2916 # acl_type: extended
2917 # name: '110'
2918 # - aces:
2919 # - destination:
2920 # address: 198.51.101.0
2921 # port_protocol:
2922 # eq: telnet
2923 # wildcard_bits: 0.0.0.255
2924 # grant: deny
2925 # protocol: tcp
2926 # protocol_options:
2927 # tcp:
2928 # ack: true
2929 # sequence: 10
2930 # source:
2931 # address: 198.51.100.0
2932 # wildcard_bits: 0.0.0.255
2933 # tos:
2934 # service_value: 12
2935 # - destination:
2936 # address: 192.0.4.0
2937 # port_protocol:
2938 # eq: www
2939 # wildcard_bits: 0.0.0.255
2940 # dscp: ef
2941 # grant: deny
2942 # protocol: tcp
2943 # protocol_options:
2944 # tcp:
2945 # ack: true
2946 # sequence: 20
2947 # source:
2948 # address: 192.0.3.0
2949 # wildcard_bits: 0.0.0.255
2950 # ttl:
2951 # lt: 20
2952 # acl_type: extended
2953 # name: '123'
2954 # - aces:
2955 # - grant: deny
2956 # sequence: 10
2957 # source:
2958 # host: 192.168.1.200
2959 # - grant: deny
2960 # sequence: 20
2961 # source:
2962 # address: 192.168.2.0
2963 # wildcard_bits: 0.0.0.255
2964 # acl_type: standard
2965 # name: std_acl
2966 # - aces:
2967 # - destination:
2968 # address: 192.0.3.0
2969 # port_protocol:
2970 # eq: www
2971 # wildcard_bits: 0.0.0.255
2972 # grant: deny
2973 # option:
2974 # traceroute: true
2975 # protocol: tcp
2976 # protocol_options:
2977 # tcp:
2978 # fin: true
2979 # sequence: 10
2980 # source:
2981 # address: 192.0.2.0
2982 # wildcard_bits: 0.0.0.255
2983 # ttl:
2984 # eq: 10
2985 # acl_type: extended
2986 # name: test
2987 # afi: ipv4
2988 # - acls:
2989 # - aces:
2990 # - destination:
2991 # any: true
2992 # port_protocol:
2993 # eq: telnet
2994 # dscp: af11
2995 # grant: deny
2996 # protocol: tcp
2997 # protocol_options:
2998 # tcp:
2999 # ack: true
3000 # sequence: 10
3001 # source:
3002 # any: true
3003 # port_protocol:
3004 # eq: www
3005 # name: R1_TRAFFIC
3006 # afi: ipv6
3007
3008 # Using rendered
3009
3010 - name: Render the provided configuration into platform specific configuration lines
3011 cisco.ios.ios_acls:
3012 config:
3013 - afi: ipv4
3014 acls:
3015 - name: 110
3016 aces:
3017 - grant: deny
3018 sequence: 10
3019 protocol_options:
3020 tcp:
3021 syn: true
3022 source:
3023 address: 192.0.2.0
3024 wildcard_bits: 0.0.0.255
3025 destination:
3026 address: 192.0.3.0
3027 wildcard_bits: 0.0.0.255
3028 port_protocol:
3029 eq: www
3030 dscp: ef
3031 ttl:
3032 eq: 10
3033 - name: 150
3034 aces:
3035 - grant: deny
3036 protocol_options:
3037 tcp:
3038 syn: true
3039 source:
3040 address: 198.51.100.0
3041 wildcard_bits: 0.0.0.255
3042 port_protocol:
3043 eq: telnet
3044 destination:
3045 address: 198.51.110.0
3046 wildcard_bits: 0.0.0.255
3047 port_protocol:
3048 eq: telnet
3049 dscp: ef
3050 ttl:
3051 eq: 10
3052 state: rendered
3053
3054 # Module Execution Result:
3055 # ------------------------
3056 #
3057 # rendered:
3058 # - ip access-list extended 110
3059 # - 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www syn dscp ef ttl eq 10
3060 # - ip access-list extended 150
3061 # - deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq telnet syn dscp ef ttl eq 10
3062
3063 # Using Parsed
3064
3065 # File: parsed.cfg
3066 # ----------------
3067 #
3068 # IPv6 access-list R1_TRAFFIC
3069 # deny tcp any eq www any eq telnet ack dscp af11
3070
3071 - name: Parse the commands for provided configuration
3072 cisco.ios.ios_acls:
3073 running_config: "{{ lookup('file', 'parsed.cfg') }}"
3074 state: parsed
3075
3076 # Module Execution Result:
3077 # ------------------------
3078 #
3079 # parsed:
3080 # - acls:
3081 # - aces:
3082 # - destination:
3083 # any: true
3084 # port_protocol:
3085 # eq: telnet
3086 # dscp: af11
3087 # grant: deny
3088 # protocol: tcp
3089 # protocol_options:
3090 # tcp:
3091 # ack: true
3092 # sequence: 10
3093 # source:
3094 # any: true
3095 # port_protocol:
3096 # eq: www
3097 # name: R1_TRAFFIC
3098 # afi: ipv6
3099 """
3100
3101 RETURN = """
3102 before:
3103 description: The configuration prior to the module execution.
3104 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
3105 type: dict
3106 sample: >
3107 This output will always be in the same format as the
3108 module argspec.
3109 after:
3110 description: The resulting configuration after module execution.
3111 returned: when changed
3112 type: dict
3113 sample: >
3114 This output will always be in the same format as the
3115 module argspec.
3116 commands:
3117 description: The set of commands pushed to the remote device.
3118 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
3119 type: list
3120 sample:
3121 - ip access-list extended 110
3122 - deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
3123 - permit ip host 2.2.2.2 host 3.3.3.3
3124 rendered:
3125 description: The provided configuration in the task rendered in device-native format (offline).
3126 returned: when I(state) is C(rendered)
3127 type: list
3128 sample:
3129 - ip access-list extended test
3130 - permit ip host 2.2.2.2 host 3.3.3.3
3131 - permit tcp host 1.1.1.1 host 5.5.5.5 eq www
3132 gathered:
3133 description: Facts about the network resource gathered from the remote device as structured data.
3134 returned: when I(state) is C(gathered)
3135 type: list
3136 sample: >
3137 This output will always be in the same format as the
3138 module argspec.
3139 parsed:
3140 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
3141 returned: when I(state) is C(parsed)
3142 type: list
3143 sample: >
3144 This output will always be in the same format as the
3145 module argspec.
3146 """
3147
3148 from ansible.module_utils.basic import AnsibleModule
3149
3150 from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.acls.acls import (
3151 AclsArgs,
3152 )
3153 from ansible_collections.cisco.ios.plugins.module_utils.network.ios.config.acls.acls import Acls
3154
3155
3156 def main():
3157 """
3158 Main entry point for module execution
3159
3160 :returns: the result form module invocation
3161 """
3162 module = AnsibleModule(
3163 argument_spec=AclsArgs.argument_spec,
3164 mutually_exclusive=[["config", "running_config"]],
3165 required_if=[
3166 ["state", "merged", ["config"]],
3167 ["state", "replaced", ["config"]],
3168 ["state", "overridden", ["config"]],
3169 ["state", "rendered", ["config"]],
3170 ["state", "parsed", ["running_config"]],
3171 ],
3172 supports_check_mode=True,
3173 )
3174
3175 result = Acls(module).execute_module()
3176 module.exit_json(**result)
3177
3178
3179 if __name__ == "__main__":
3180 main()