Debian Codegraph @

ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_l3_acls.py

raw symbols SCIP
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
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 sonic_l3_acls
9 """
10
11 from __future__ import absolute_import, division, print_function
12 __metaclass__ = type
13
14 DOCUMENTATION = """
15 ---
16 module: sonic_l3_acls
17 version_added: '2.1.0'
18 notes:
19 - Supports C(check_mode).
20 short_description: Manage Layer 3 access control lists (ACL) configurations on SONiC
21 description:
22 - This module provides configuration management of Layer 3 access control lists (ACL)
23 in devices running SONiC.
24 author: 'Arun Saravanan Balachandran (@ArunSaravananBalachandran)'
25 options:
26 config:
27 description:
28 - Specifies Layer 3 ACL configurations.
29 type: list
30 elements: dict
31 suboptions:
32 address_family:
33 description:
34 - Specifies the address family of the ACLs.
35 type: str
36 required: true
37 choices:
38 - ipv4
39 - ipv6
40 acls:
41 description:
42 - List of ACL configuration for the given address family.
43 type: list
44 elements: dict
45 suboptions:
46 name:
47 description:
48 - Specifies the ACL name.
49 type: str
50 required: true
51 remark:
52 description:
53 - Specifies remark for the ACL.
54 type: str
55 rules:
56 description:
57 - List of rules with the ACL.
58 - I(sequence_num), I(action), I(protocol), I(source) & I(destination) are required for adding a new rule.
59 - If I(state=deleted), options other than I(sequence_num) are not considered.
60 type: list
61 elements: dict
62 suboptions:
63 sequence_num:
64 description:
65 - Specifies the sequence number of the rule.
66 - The range is from 1 to 65535.
67 type: int
68 required: true
69 action:
70 description:
71 - Specifies the action taken on the matched packet.
72 type: str
73 choices:
74 - deny
75 - discard
76 - do-not-nat
77 - permit
78 - transit
79 protocol:
80 description:
81 - Specifies the protocol to match.
82 - Only one suboption can be specified for protocol in a rule.
83 type: dict
84 suboptions:
85 name:
86 description:
87 - Match packets with the given protocol.
88 - C(ip) - Match any IPv4 packets.
89 - C(ipv6) - Match any IPv6 packets.
90 - C(icmp) - Match ICMP packets.
91 - C(icmpv6) - Match ICMPv6 packets.
92 - C(tcp) - Match TCP packets.
93 - C(udp) - Match UDP packets.
94 - C(ip) and C(icmp) are valid only for IPv4 ACLs.
95 - C(ipv6) and C(icmpv6) are valid only for IPv6 ACLs.
96 type: str
97 choices:
98 - ip
99 - ipv6
100 - icmp
101 - icmpv6
102 - tcp
103 - udp
104 number:
105 description:
106 - Match packets with given protocol number.
107 - The range is from 0 to 255.
108 type: int
109 source:
110 description:
111 - Specifies the source of the packet.
112 - I(any), I(host) and I(prefix) are mutually exclusive.
113 type: dict
114 suboptions:
115 any:
116 description:
117 - Match any source network address.
118 type: bool
119 host:
120 description:
121 - Network address of a single source host.
122 type: str
123 prefix:
124 description:
125 - Source network prefix in the format A.B.C.D/mask (ipv4) or A::B/mask (ipv6).
126 type: str
127 port_number:
128 description:
129 - Specifies the source port (valid only for TCP or UDP)
130 - Only one suboption can be specified for port_number in a rule.
131 type: dict
132 suboptions:
133 eq:
134 description:
135 - Match packets with source port equal to the given port number.
136 - The range is from 0 to 65535.
137 type: int
138 gt:
139 description:
140 - Match packets with source port greater than the given port number.
141 - The range is from 0 to 65534.
142 type: int
143 lt:
144 description:
145 - Match packets with source port lesser than the given port number.
146 - The range is from 1 to 65535.
147 type: int
148 range:
149 description:
150 - Match packets with source port in the given range.
151 - I(begin) and I(end) are required together.
152 type: dict
153 suboptions:
154 begin:
155 description:
156 - Specifies the beginning of the port range.
157 - The range is from 0 to 65534.
158 type: int
159 end:
160 description:
161 - Specifies the end of the port range.
162 - The range is from 1 to 65535.
163 type: int
164 destination:
165 description:
166 - Specifies the destination of the packet.
167 - I(any), I(host) and I(prefix) are mutually exclusive.
168 type: dict
169 suboptions:
170 any:
171 description:
172 - Match any destination network address.
173 type: bool
174 host:
175 description:
176 - Network address of a single destination host.
177 type: str
178 prefix:
179 description:
180 - Destination network prefix in the format A.B.C.D/mask (ipv4) or A::B/mask (ipv6).
181 type: str
182 port_number:
183 description:
184 - Specifies the destination port (valid only for TCP or UDP)
185 - Only one suboption can be specified for port_number in a rule.
186 type: dict
187 suboptions:
188 eq:
189 description:
190 - Match packets with destination port equal to the given port number.
191 - The range is from 0 to 65535.
192 type: int
193 gt:
194 description:
195 - Match packets with destination port greater than the given port number.
196 - The range is from 0 to 65534.
197 type: int
198 lt:
199 description:
200 - Match packets with destination port lesser than the given port number.
201 - The range is from 1 to 65535.
202 type: int
203 range:
204 description:
205 - Match packets with destination port in the given range.
206 - I(begin) and I(end) are required together.
207 type: dict
208 suboptions:
209 begin:
210 description:
211 - Specifies the beginning of the port range.
212 - The range is from 0 to 65534.
213 type: int
214 end:
215 description:
216 - Specifies the end of the port range.
217 - The range is from 1 to 65535.
218 type: int
219 protocol_options:
220 description:
221 - Specifies the additional packet match options for the chosen protocol.
222 - I(icmp), I(icmpv6) and I(tcp) are mutually exclusive.
223 type: dict
224 suboptions:
225 icmp:
226 description:
227 - Packet match options for ICMP.
228 type: dict
229 suboptions:
230 code:
231 description:
232 - Match packets with given ICMP code.
233 - The range is from 0 to 255.
234 type: int
235 type:
236 description:
237 - Match packets with given ICMP type.
238 - The range is from 0 to 255.
239 type: int
240 icmpv6:
241 description:
242 - Packet match options for ICMPv6.
243 type: dict
244 suboptions:
245 code:
246 description:
247 - Match packets with given ICMPv6 code.
248 - The range is from 0 to 255.
249 type: int
250 type:
251 description:
252 - Match packets with given ICMPv6 type.
253 - The range is from 0 to 255.
254 type: int
255 tcp:
256 description:
257 - Packet match options for TCP.
258 - I(established) and other TCP flag options are mutually exclusive.
259 type: dict
260 suboptions:
261 established:
262 description:
263 - Match packets which are part of established TCP session.
264 type: bool
265 ack:
266 description:
267 - Match packets with ACK flag set.
268 type: bool
269 not_ack:
270 description:
271 - Match packets with ACK flag cleared.
272 type: bool
273 fin:
274 description:
275 - Match packets with FIN flag set.
276 type: bool
277 not_fin:
278 description:
279 - Match packets with FIN flag cleared.
280 type: bool
281 psh:
282 description:
283 - Match packets with PSH flag set.
284 type: bool
285 not_psh:
286 description:
287 - Match packets with PSH flag cleared.
288 type: bool
289 rst:
290 description:
291 - Match packets with RST flag set.
292 type: bool
293 not_rst:
294 description:
295 - Match packets with RST flag cleared.
296 type: bool
297 syn:
298 description:
299 - Match packets with SYN flag set.
300 type: bool
301 not_syn:
302 description:
303 - Match packets with SYN flag cleared.
304 type: bool
305 urg:
306 description:
307 - Match packets with URG flag set.
308 type: bool
309 not_urg:
310 description:
311 - Match packets with URG flag cleared.
312 type: bool
313 vlan_id:
314 description:
315 - Match packets with the given VLAN ID value.
316 type: int
317 dscp:
318 description:
319 - Match packets using DSCP value.
320 - Only one suboption can be specified for dscp in a rule.
321 type: dict
322 suboptions:
323 value:
324 description:
325 - Match packets with given DSCP value.
326 - The range is from 0 to 63.
327 type: int
328 af11:
329 description:
330 - Match packets with AF11 DSCP (001010 - Decimal value 10).
331 type: bool
332 af12:
333 description:
334 - Match packets with AF12 DSCP (001100 - Decimal value 12).
335 type: bool
336 af13:
337 description:
338 - Match packets with AF13 DSCP (001110 - Decimal value 14).
339 type: bool
340 af21:
341 description:
342 - Match packets with AF21 DSCP (010010 - Decimal value 18).
343 type: bool
344 af22:
345 description:
346 - Match packets with AF22 DSCP (010100 - Decimal value 20).
347 type: bool
348 af23:
349 description:
350 - Match packets with AF23 DSCP (010110 - Decimal value 22).
351 type: bool
352 af31:
353 description:
354 - Match packets with AF31 DSCP (011010 - Decimal value 26).
355 type: bool
356 af32:
357 description:
358 - Match packets with AF32 DSCP (011100 - Decimal value 28).
359 type: bool
360 af33:
361 description:
362 - Match packets with AF33 DSCP (011110 - Decimal value 30).
363 type: bool
364 af41:
365 description:
366 - Match packets with AF41 DSCP (100010 - Decimal value 34).
367 type: bool
368 af42:
369 description:
370 - Match packets with AF42 DSCP (100100 - Decimal value 36).
371 type: bool
372 af43:
373 description:
374 - Match packets with AF43 DSCP (100110 - Decimal value 38).
375 type: bool
376 cs1:
377 description:
378 - Match packets with CS1 DSCP (001000 - Decimal value 8).
379 type: bool
380 cs2:
381 description:
382 - Match packets with CS2 DSCP (010000 - Decimal value 16).
383 type: bool
384 cs3:
385 description:
386 - Match packets with CS3 DSCP (011000 - Decimal value 24).
387 type: bool
388 cs4:
389 description:
390 - Match packets with CS4 DSCP (100000 - Decimal value 32).
391 type: bool
392 cs5:
393 description:
394 - Match packets with CS5 DSCP (101000 - Decimal value 40).
395 type: bool
396 cs6:
397 description:
398 - Match packets with CS6 DSCP (110000 - Decimal value 48).
399 type: bool
400 cs7:
401 description:
402 - Match packets with CS7 DSCP (111000 - Decimal value 56).
403 type: bool
404 default:
405 description:
406 - Match packets with CS0 DSCP (000000 - Decimal value 0).
407 type: bool
408 ef:
409 description:
410 - Match packets with EF DSCP (101110 - Decimal value 46).
411 type: bool
412 voice_admit:
413 description:
414 - Match packets with VOICE-ADMIT DSCP (101100 - Decimal value 44).
415 type: bool
416 remark:
417 description:
418 - Specifies remark for the ACL rule.
419 type: str
420 state:
421 description:
422 - The state of the configuration after module completion.
423 - C(merged) - Merges provided L3 ACL configuration with on-device configuration.
424 - C(replaced) - Replaces on-device configuration of the specified L3 ACLs with provided configuration.
425 - C(overridden) - Overrides all on-device L3 ACL configurations with the provided configuration.
426 - C(deleted) - Deletes on-device L3 ACL configuration.
427 type: str
428 choices:
429 - merged
430 - replaced
431 - overridden
432 - deleted
433 default: merged
434 """
435
436 EXAMPLES = """
437 # Using "merged" state
438 #
439 # Before state:
440 # -------------
441 #
442 # sonic# show running-configuration ip access-list
443 # !
444 # ip access-list test
445 # seq 1 permit ip host 192.168.1.2 any
446 # sonic#
447 # sonic# show running-configuration ipv6 access-list
448 # !
449 # ipv6 access-list testv6
450 # seq 1 permit ipv6 host 192:168:1::2 any
451 # sonic#
452
453 - name: Merge provided Layer 3 ACL configurations
454 dellemc.enterprise_sonic.sonic_l3_acls:
455 config:
456 - address_family: 'ipv4'
457 acls:
458 - name: 'test'
459 rules:
460 - sequence_num: 2
461 action: 'permit'
462 protocol:
463 name: 'icmp'
464 source:
465 any: true
466 destination:
467 host: '192.168.1.2'
468 protocol_options:
469 icmp:
470 type: 8
471 - sequence_num: 3
472 action: 'deny'
473 protocol:
474 number: 2
475 source:
476 any: true
477 destination:
478 any: true
479 - sequence_num: 4
480 action: 'deny'
481 protocol:
482 name: 'ip'
483 source:
484 any: true
485 destination:
486 any: true
487 vlan_id: 10
488 remark: 'Vlan10'
489 - name: 'test1'
490 remark: 'test_ip_acl'
491 rules:
492 - sequence_num: 1
493 action: 'permit'
494 protocol:
495 name: 'tcp'
496 source:
497 prefix: '10.0.0.0/8'
498 destination:
499 any: true
500 - sequence_num: 2
501 action: 'deny'
502 protocol:
503 name: 'udp'
504 source:
505 any: true
506 destination:
507 prefix: '20.1.0.0/16'
508 port_number:
509 gt: 1024
510 - sequence_num: 3
511 action: 'deny'
512 protocol:
513 name: 'ip'
514 source:
515 any: true
516 destination:
517 any: true
518 dscp:
519 value: 63
520 - address_family: 'ipv6'
521 acls:
522 - name: 'testv6'
523 rules:
524 - sequence_num: 2
525 action: 'deny'
526 protocol:
527 name: 'icmpv6'
528 source:
529 any: true
530 destination:
531 any: true
532 - name: 'testv6-1'
533 remark: 'test_ipv6_acl'
534 rules:
535 - sequence_num: 1
536 action: 'permit'
537 protocol:
538 name: 'ipv6'
539 source:
540 prefix: '1000::/16'
541 destination:
542 any: true
543 dscp:
544 af22: true
545 - sequence_num: 2
546 action: 'deny'
547 protocol:
548 name: 'tcp'
549 source:
550 any: true
551 destination:
552 prefix: '2000::1000:0/112'
553 port_number:
554 range:
555 begin: 100
556 end: 1000
557 - sequence_num: 3
558 action: 'permit'
559 protocol:
560 name: 'tcp'
561 source:
562 any: true
563 destination:
564 any: true
565 protocol_options:
566 tcp:
567 established: true
568 - sequence_num: 4
569 action: 'deny'
570 protocol:
571 name: 'udp'
572 source:
573 any: true
574 port_number:
575 eq: 3000
576 destination:
577 any: true
578 state: merged
579
580 # After state:
581 # ------------
582 #
583 # sonic# show running-configuration ip access-list
584 # !
585 # ip access-list test
586 # seq 1 permit ip host 192.168.1.2 any
587 # seq 2 permit icmp any host 192.168.1.2 type 8
588 # seq 3 deny 2 any any
589 # seq 4 deny ip any any vlan 10 remark Vlan10
590 # !
591 # ip access-list test1
592 # remark test_ip_acl
593 # seq 1 permit tcp 10.0.0.0/8 any
594 # seq 2 deny udp any 20.1.0.0/16 gt 1024
595 # seq 3 deny ip any any dscp 63
596 # sonic#
597 # sonic# show running-configuration ipv6 access-list
598 # !
599 # ipv6 access-list testv6
600 # seq 1 permit ipv6 host 192:168:1::2 any
601 # seq 2 deny icmpv6 any any
602 # !
603 # ipv6 access-list testv6-1
604 # remark test_ipv6_acl
605 # seq 1 permit ipv6 1000::/16 any dscp af22
606 # seq 2 deny tcp any 2000::1000:0/112 range 100 1000
607 # seq 3 permit tcp any any established
608 # seq 4 deny udp any eq 3000 any
609 # sonic#
610
611
612 # Using "replaced" state
613 #
614 # Before state:
615 # -------------
616 #
617 # sonic# show running-configuration ip access-list
618 # !
619 # ip access-list test
620 # seq 1 permit ip host 192.168.1.2 any
621 # seq 2 permit icmp any host 192.168.1.2 type 8
622 # seq 3 deny 2 any any
623 # seq 4 deny ip any any vlan 10 remark Vlan10
624 # !
625 # ip access-list test1
626 # remark test_ip_acl
627 # seq 1 permit tcp 10.0.0.0/8 any
628 # seq 2 deny udp any 20.1.0.0/16 gt 1024
629 # seq 3 deny ip any any dscp 63
630 # sonic#
631 # sonic# show running-configuration ipv6 access-list
632 # !
633 # ipv6 access-list testv6
634 # seq 1 permit tcp host 3000::1 any established
635 # seq 2 permit udp any any
636 # seq 3 deny icmpv6 any any
637 # !
638 # ipv6 access-list testv6-1
639 # remark test_ipv6_acl
640 # seq 1 permit ipv6 1000::/16 any dscp af22
641 # seq 2 deny tcp any 2000::1000:0/112 range 100 1000
642 # seq 3 permit tcp any any established
643 # seq 4 deny udp any eq 3000 any
644 # sonic#
645
646 - name: Replace device configuration of specified Layer 3 ACLs with provided configuration
647 dellemc.enterprise_sonic.sonic_l3_acls:
648 config:
649 - address_family: 'ipv4'
650 acls:
651 - name: 'test2'
652 rules:
653 - sequence_num: 1
654 action: 'permit'
655 protocol:
656 name: 'tcp'
657 source:
658 prefix: '192.168.1.0/24'
659 destination:
660 any: true
661 - address_family: 'ipv6'
662 acls:
663 - name: 'testv6'
664 rules:
665 - sequence_num: 1
666 action: 'permit'
667 protocol:
668 name: 'tcp'
669 source:
670 host: '3000::1'
671 destination:
672 any: true
673 protocol_options:
674 tcp:
675 ack: true
676 syn: true
677 fin: true
678 - sequence_num: 2
679 action: 'deny'
680 protocol:
681 name: 'ipv6'
682 source:
683 any: true
684 destination:
685 any: true
686 state: replaced
687
688 # After state:
689 # ------------
690 #
691 # sonic# show running-configuration ip access-list
692 # !
693 # ip access-list test
694 # seq 1 permit ip host 192.168.1.2 any
695 # seq 2 permit icmp any host 192.168.1.3 type 8
696 # seq 3 deny 2 any any
697 # seq 4 deny ip any any vlan 10 remark Vlan10
698 # !
699 # ip access-list test1
700 # remark test_ip_acl
701 # seq 1 permit tcp 10.0.0.0/8 any
702 # seq 2 deny udp any 20.1.0.0/16 gt 1024
703 # seq 3 deny ip any any dscp 63
704 # !
705 # ip access-list test2
706 # seq 1 permit tcp 192.168.1.0/24 any
707 # sonic#
708 # sonic# show running-configuration ipv6 access-list
709 # !
710 # ipv6 access-list testv6
711 # seq 1 permit tcp host 3000::1 any fin syn ack
712 # seq 2 deny ipv6 any any
713 # !
714 # ipv6 access-list testv6-1
715 # remark test_ipv6_acl
716 # seq 1 permit ipv6 1000::/16 any dscp af22
717 # seq 2 deny tcp any 2000::1000:0/112 range 100 1000
718 # seq 3 permit tcp any any established
719 # seq 4 deny udp any eq 3000 any
720 # sonic#
721
722
723 # Using "overridden" state
724 #
725 # Before state:
726 # -------------
727 #
728 # sonic# show running-configuration ip access-list
729 # !
730 # ip access-list test
731 # seq 1 permit ip host 192.168.1.2 any
732 # seq 2 permit icmp any host 192.168.1.3 type 8
733 # seq 3 deny 2 any any
734 # seq 4 deny ip any any vlan 10 remark Vlan10
735 # !
736 # ip access-list test1
737 # remark test_ip_acl
738 # seq 1 permit tcp 10.0.0.0/8 any
739 # seq 2 deny udp any 20.1.0.0/16 gt 1024
740 # seq 3 deny ip any any dscp 63
741 # !
742 # ip access-list test2
743 # seq 1 permit tcp 192.168.1.0/24 any
744 # sonic#
745 # sonic# show running-configuration ipv6 access-list
746 # !
747 # ipv6 access-list testv6
748 # seq 1 permit tcp 3000::/16 any
749 # seq 2 deny ipv6 any any
750 # !
751 # ipv6 access-list testv6-1
752 # remark test_ipv6_acl
753 # seq 1 permit ipv6 1000::/16 any dscp af22
754 # seq 2 deny tcp any 2000::1000:0/112 range 100 1000
755 # seq 3 permit tcp any any established
756 # seq 4 deny udp any eq 3000 any
757 # sonic#
758
759 - name: Override device configuration of all Layer 3 ACLs with provided configuration
760 dellemc.enterprise_sonic.sonic_l3_acls:
761 config:
762 - address_family: 'ipv4'
763 acls:
764 - name: 'test_acl'
765 rules:
766 - sequence_num: 1
767 action: 'permit'
768 protocol:
769 name: 'ip'
770 source:
771 prefix: '100.1.1.0/24'
772 destination:
773 prefix: '100.1.2.0/24'
774 - sequence_num: 2
775 action: 'deny'
776 protocol:
777 name: 'udp'
778 source:
779 any: true
780 destination:
781 any: true
782 state: overridden
783
784 # After state:
785 # ------------
786 #
787 # sonic# show running-configuration ip access-list
788 # !
789 # ip access-list test_acl
790 # seq 1 permit ip 100.1.1.0/24 100.1.2.0/24
791 # seq 2 deny udp any any
792 # sonic#
793 # sonic# show running-configuration ipv6 access-list
794 # sonic#
795
796
797 # Using "deleted" state
798 #
799 # Before state:
800 # -------------
801 #
802 # sonic# show running-configuration ip access-list
803 # !
804 # ip access-list test
805 # seq 1 permit ip host 192.168.1.2 any
806 # seq 2 permit icmp any host 192.168.1.3 type 8
807 # seq 3 deny 2 any any
808 # seq 4 deny ip any any vlan 10 remark Vlan10
809 # !
810 # ip access-list test1
811 # remark test_ip_acl
812 # seq 1 permit tcp 10.0.0.0/8 any
813 # seq 2 deny udp any 20.1.0.0/16 gt 1024
814 # seq 3 deny ip any any dscp 63
815 # !
816 # ip access-list test2
817 # seq 1 permit tcp 192.168.1.0/24 any
818 # sonic#
819 # sonic# show running-configuration ipv6 access-list
820 # !
821 # ipv6 access-list testv6
822 # seq 1 permit tcp 3000::/16 any
823 # seq 2 deny ipv6 any any
824 # !
825 # ipv6 access-list testv6-1
826 # remark test_ipv6_acl
827 # seq 1 permit ipv6 1000::/16 any dscp af22
828 # seq 2 deny tcp any 2000::1000:0/112 range 100 1000
829 # seq 3 permit tcp any any established
830 # seq 4 deny udp any eq 3000 any
831 # sonic#
832
833 - name: Delete specified Layer 3 ACLs, ACL remark and ACL rule entries
834 dellemc.enterprise_sonic.sonic_l3_acls:
835 config:
836 - address_family: 'ipv4'
837 acls:
838 - name: 'test'
839 rules:
840 - sequence_num: 2
841 - name: 'test2'
842 - address_family: 'ipv6'
843 acls:
844 - name: 'testv6-1'
845 remark: 'test_ipv6_acl'
846 rules:
847 - sequence_num: 3
848 state: deleted
849
850 # After state:
851 # ------------
852 #
853 # sonic# show running-configuration ip access-list
854 # !
855 # ip access-list test
856 # seq 1 permit ip host 192.168.1.2 any
857 # seq 3 deny 2 any any
858 # seq 4 deny ip any any vlan 10 remark Vlan10
859 # !
860 # ip access-list test1
861 # remark test_ip_acl
862 # seq 1 permit tcp 10.0.0.0/8 any
863 # seq 2 deny udp any 20.1.0.0/16 gt 1024
864 # seq 3 deny ip any any dscp 63
865 # sonic#
866 # sonic# show running-configuration ipv6 access-list
867 # !
868 # ipv6 access-list testv6
869 # seq 1 permit tcp 3000::/16 any
870 # seq 2 deny ipv6 any any
871 # !
872 # ipv6 access-list testv6-1
873 # seq 1 permit ipv6 1000::/16 any dscp af22
874 # seq 2 deny tcp any 2000::1000:0/112 range 100 1000
875 # seq 4 deny udp any eq 3000 any
876 # sonic#
877
878
879 # Using "deleted" state
880 #
881 # Before state:
882 # -------------
883 #
884 # sonic# show running-configuration ip access-list
885 # !
886 # ip access-list test
887 # seq 1 permit ip host 192.168.1.2 any
888 # seq 2 permit icmp any host 192.168.1.3 type 8
889 # seq 3 deny 2 any any
890 # seq 4 deny ip any any vlan 10 remark Vlan10
891 # !
892 # ip access-list test1
893 # remark test_ip_acl
894 # seq 1 permit tcp 10.0.0.0/8 any
895 # seq 2 deny udp any 20.1.0.0/16 gt 1024
896 # seq 3 deny ip any any dscp 63
897 # !
898 # ip access-list test2
899 # seq 1 permit tcp 192.168.1.0/24 any
900 # sonic#
901 # sonic# show running-configuration ipv6 access-list
902 # !
903 # ipv6 access-list testv6
904 # seq 1 permit tcp 3000::/16 any
905 # seq 2 deny ipv6 any any
906 # !
907 # ipv6 access-list testv6-1
908 # remark test_ipv6_acl
909 # seq 1 permit ipv6 1000::/16 any dscp af22
910 # seq 2 deny tcp any 2000::1000:0/112 range 100 1000
911 # seq 3 permit tcp any any established
912 # seq 4 deny udp any eq 3000 any
913 # sonic#
914
915 - name: Delete all Layer 3 ACLs for an address-family
916 dellemc.enterprise_sonic.sonic_l3_acls:
917 config:
918 - address_family: 'ipv4'
919 state: deleted
920
921 # After state:
922 # ------------
923 #
924 # sonic# show running-configuration ip access-list
925 # sonic#
926 # sonic# show running-configuration ipv6 access-list
927 # !
928 # ipv6 access-list testv6
929 # seq 1 permit tcp 3000::/16 any
930 # seq 2 deny ipv6 any any
931 # !
932 # ipv6 access-list testv6-1
933 # remark test_ipv6_acl
934 # seq 1 permit ipv6 1000::/16 any dscp af22
935 # seq 2 deny tcp any 2000::1000:0/112 range 100 1000
936 # seq 3 permit tcp any any established
937 # seq 4 deny udp any eq 3000 any
938 # sonic#
939
940
941 # Using "deleted" state
942 #
943 # Before state:
944 # -------------
945 #
946 # sonic# show running-configuration ip access-list
947 # !
948 # ip access-list test
949 # seq 1 permit ip host 192.168.1.2 any
950 # seq 2 permit icmp any host 192.168.1.3 type 8
951 # seq 3 deny 2 any any
952 # seq 4 deny ip any any vlan 10 remark Vlan10
953 # !
954 # ip access-list test1
955 # remark test_ip_acl
956 # seq 1 permit tcp 10.0.0.0/8 any
957 # seq 2 deny udp any 20.1.0.0/16 gt 1024
958 # seq 3 deny ip any any dscp 63
959 # !
960 # ip access-list test2
961 # seq 1 permit tcp 192.168.1.0/24 any
962 # sonic#
963 # sonic# show running-configuration ipv6 access-list
964 # !
965 # ipv6 access-list testv6
966 # seq 1 permit tcp 3000::/16 any
967 # seq 2 deny ipv6 any any
968 # !
969 # ipv6 access-list testv6-1
970 # remark test_ipv6_acl
971 # seq 1 permit ipv6 1000::/16 any dscp af22
972 # seq 2 deny tcp any 2000::1000:0/112 range 100 1000
973 # seq 3 permit tcp any any established
974 # seq 4 deny udp any eq 3000 any
975 # sonic#
976
977 - name: Delete all Layer 3 ACL configurations
978 dellemc.enterprise_sonic.sonic_l3_acls:
979 config:
980 state: deleted
981
982 # After state:
983 # ------------
984 #
985 # sonic# show running-configuration ip access-list
986 # sonic#
987 # sonic# show running-configuration ipv6 access-list
988 # sonic#
989 """
990
991 RETURN = """
992 before:
993 description: The configuration prior to the module invocation.
994 returned: always
995 type: list
996 sample: >
997 The configuration returned will always be in the same format
998 as the parameters above.
999 after:
1000 description: The resulting configuration module invocation.
1001 returned: when changed
1002 type: list
1003 sample: >
1004 The configuration returned will always be in the same format
1005 as the parameters above.
1006 after_generated:
1007 description: The generated configuration module invocation.
1008 returned: when C(check_mode)
1009 type: list
1010 sample: >
1011 The configuration returned will always be in the same format
1012 as the parameters above.
1013 commands:
1014 description: The set of commands pushed to the remote device.
1015 returned: always
1016 type: list
1017 sample: ['command 1', 'command 2', 'command 3']
1018 """
1019
1020
1021 from ansible.module_utils.basic import AnsibleModule
1022 from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.l3_acls.l3_acls import L3_aclsArgs
1023 from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.l3_acls.l3_acls import L3_acls
1024
1025
1026 def main():
1027 """
1028 Main entry point for module execution
1029
1030 :returns: the result form module invocation
1031 """
1032 module = AnsibleModule(argument_spec=L3_aclsArgs.argument_spec,
1033 supports_check_mode=True)
1034
1035 result = L3_acls(module).execute_module()
1036 module.exit_json(**result)
1037
1038
1039 if __name__ == '__main__':
1040 main()