Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_route_maps.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 nxos_route_maps
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 module: nxos_route_maps
18 short_description: Route Maps resource module.
19 description:
20 - This module manages route maps configuration on devices running Cisco NX-OS.
21 version_added: 2.2.0
22 notes:
23 - Tested against NX-OS 9.3.6.
24 - Unsupported for Cisco MDS
25 - This module works with connection C(network_cli) and C(httpapi).
26 author: Nilashish Chakraborty (@NilashishC)
27 options:
28 running_config:
29 description:
30 - This option is used only with state I(parsed).
31 - The value of this option should be the output received from the NX-OS device
32 by executing the command B(show running-config | section '^route-map').
33 - The state I(parsed) reads the configuration from C(running_config) option and
34 transforms it into Ansible structured data as per the resource module's argspec
35 and the value is then returned in the I(parsed) key within the result.
36 type: str
37 config:
38 description: A list of route-map configuration.
39 type: list
40 elements: dict
41 suboptions:
42 route_map:
43 description: Route-map name.
44 type: str
45 entries:
46 description: List of entries (identified by sequence number) for this route-map.
47 type: list
48 elements: dict
49 suboptions:
50 sequence:
51 description: Sequence to insert to/delete from existing route-map entry.
52 type: int
53 action:
54 description: Route map denies or permits set operations.
55 type: str
56 choices: ["deny", "permit"]
57 continue_sequence:
58 description: Continue on a different entry within the route-map.
59 type: int
60 description:
61 description: Description of the route-map.
62 type: str
63 match:
64 description: Match values from routing table.
65 type: dict
66 suboptions:
67 as_number:
68 description: Match BGP peer AS number.
69 type: dict
70 suboptions:
71 asn:
72 description: AS number.
73 type: list
74 elements: str
75 as_path_list:
76 description: AS path access list name.
77 type: list
78 elements: str
79 as_path:
80 description: Match BGP AS path access-list.
81 type: list
82 elements: str
83 community:
84 description: Match BGP community list.
85 type: dict
86 suboptions:
87 community_list:
88 description: Community list.
89 type: list
90 elements: str
91 exact_match:
92 description: Do exact matching of communities.
93 type: bool
94 evpn:
95 description: Match BGP EVPN Routes.
96 type: dict
97 suboptions:
98 route_types:
99 description: Match route type for evpn route.
100 type: list
101 elements: str
102 extcommunity:
103 description: Match BGP community list.
104 type: dict
105 suboptions:
106 extcommunity_list:
107 description: Extended Community list.
108 type: list
109 elements: str
110 exact_match:
111 description: Do exact matching of extended communities.
112 type: bool
113 interfaces:
114 description: Match first hop interface of route.
115 type: list
116 elements: str
117 ip:
118 description: Configure IP specific information.
119 type: dict
120 suboptions: &id001
121 address:
122 description: Match address of route or match packet.
123 type: dict
124 suboptions:
125 access_list:
126 description: IP access-list name (for use in route-maps for PBR only).
127 type: str
128 prefix_lists:
129 description: Match entries of prefix-lists.
130 type: list
131 elements: str
132 multicast:
133 description: Match multicast attributes.
134 type: dict
135 suboptions:
136 source:
137 description: Multicast source address.
138 type: str
139 group:
140 description:
141 - Multicast Group prefix.
142 - Mutually exclusive with group_range.
143 type: dict
144 suboptions:
145 prefix:
146 description: IPv4 group prefix.
147 type: str
148 group_range:
149 description:
150 - Multicast Group address range.
151 - Mutually exclusive with group.
152 type: dict
153 suboptions:
154 first:
155 description: First Group address.
156 type: str
157 last:
158 description: Last Group address.
159 type: str
160 rp:
161 description: Rendezvous point.
162 type: dict
163 suboptions:
164 prefix:
165 description: IPv4 rendezvous prefix.
166 type: str
167 rp_type:
168 description: Multicast rendezvous point type.
169 type: str
170 choices: ["ASM", "Bidir"]
171 next_hop:
172 description: Match next-hop address of route.
173 type: dict
174 suboptions:
175 prefix_lists:
176 description: Match entries of prefix-lists.
177 type: list
178 elements: str
179 route_source:
180 description: Match advertising source address of route.
181 type: dict
182 suboptions:
183 prefix_lists:
184 description: Match entries of prefix-lists.
185 type: list
186 elements: str
187 ipv6:
188 description: Configure IPv6 specific information.
189 type: dict
190 suboptions: *id001
191 mac_list:
192 description: Match entries of mac-lists.
193 type: list
194 elements: str
195 metric:
196 description: Match metric of route.
197 type: list
198 elements: int
199 ospf_area:
200 description: Match ospf area.
201 type: list
202 elements: int
203 route_types:
204 description: Match route-type of route.
205 type: list
206 elements: str
207 choices: ["external", "inter-area", "internal", "intra-area", "level-1", "level-2", "local", "nssa-external", "type-1", "type-2"]
208 source_protocol:
209 description: Match source protocol.
210 type: list
211 elements: str
212 tags:
213 description: Match tag of route.
214 type: list
215 elements: int
216 set:
217 description: Set values in destination routing protocol.
218 type: dict
219 suboptions:
220 as_path:
221 description: Prepend string for a BGP AS-path attribute.
222 type: dict
223 suboptions:
224 prepend:
225 description: Prepend to the AS-Path.
226 type: dict
227 suboptions:
228 as_number:
229 description: AS number.
230 type: list
231 elements: str
232 last_as:
233 description: Number of last-AS prepends.
234 type: int
235 tag:
236 description: Set the tag as an AS-path attribute.
237 type: bool
238 comm_list:
239 description: Set BGP community list (for deletion).
240 type: str
241 community:
242 description: Set BGP community attribute.
243 type: dict
244 suboptions:
245 additive:
246 description: Add to existing community.
247 type: bool
248 graceful_shutdown:
249 description: Graceful Shutdown (well-known community).
250 type: bool
251 internet:
252 description: Internet (well-known community).
253 type: bool
254 local_as:
255 description: Do not send outside local AS (well-known community).
256 type: bool
257 no_advertise:
258 description: Do not advertise to any peer (well-known community).
259 type: bool
260 no_export:
261 description: Do not export to next AS (well-known community).
262 type: bool
263 number:
264 description: "Community number aa:nn format"
265 type: list
266 elements: str
267 dampening:
268 description: Set BGP route flap dampening parameters.
269 type: dict
270 suboptions:
271 half_life:
272 description: Half-life time for the penalty.
273 type: int
274 start_reuse_route:
275 description: Value to start reusing a route.
276 type: int
277 start_suppress_route:
278 description: Value to start suppressing a route.
279 type: int
280 max_suppress_time:
281 description: Maximum suppress time for stable route.
282 type: int
283 distance:
284 description: Configure administrative distance.
285 type: dict
286 suboptions:
287 igp_ebgp_routes:
288 description: Administrative distance for IGP or EBGP routes
289 type: int
290 internal_routes:
291 description: Distance for internal routes.
292 type: int
293 local_routes:
294 description: Distance for local routes.
295 type: int
296 evpn:
297 description: Set BGP EVPN Routes.
298 type: dict
299 suboptions:
300 gateway_ip:
301 description:
302 - Set gateway IP for type 5 EVPN routes.
303 - Cannot set ip and use-nexthop in the same route-map sequence.
304 type: dict
305 suboptions:
306 ip:
307 description: Gateway IP address.
308 type: str
309 use_nexthop:
310 description: Use nexthop address as gateway IP.
311 type: bool
312 extcomm_list:
313 description: Set BGP extcommunity list (for deletion).
314 type: str
315 extcommunity:
316 description: Set BGP extcommunity attribute.
317 type: dict
318 suboptions:
319 rt:
320 description: Route-Target.
321 type: dict
322 suboptions:
323 additive:
324 description: Add to existing rt extcommunity.
325 type: bool
326 extcommunity_numbers:
327 description:
328 - Extcommunity number.
329 - "Supported formats are ASN2:NN, ASN4:NN, IPV4:NN."
330 type: list
331 elements: str
332 forwarding_address:
333 description: Set the forwarding address.
334 type: bool
335 null_interface:
336 description: Output Null interface.
337 type: str
338 ip:
339 description: Configure IP features.
340 type: dict
341 suboptions: &id002
342 address:
343 description: Specify IP address.
344 type: dict
345 suboptions:
346 prefix_list:
347 description: Name of prefix list (Max Size 63).
348 type: str
349 precedence:
350 description: Set precedence field.
351 type: str
352 next_hop:
353 description: Set next-hop IP address (for policy-based routing)
354 type: dict
355 suboptions:
356 address:
357 description: Set space-separated list of next-hop IP addresses. Address ordering is important. Also don`t use unnecessary spaces.
358 type: str
359 drop_on_fail:
360 description: Drop packets instead of using default routing when the configured next hop becomes unreachable
361 type: bool
362 default: false
363 force_order:
364 description: Enable next-hop ordering as specified in the address parameter.
365 type: bool
366 default: false
367 load_share:
368 description: Enable traffic load balancing across a maximum of 32 next-hop addresses
369 type: bool
370 default: false
371 peer_address:
372 description:
373 - BGP prefix next hop is set to the local address of the peer.
374 - If no next hop is set in the route map, the next hop is set to the one stored in the path.
375 type: bool
376 redist_unchanged:
377 description:
378 - Set for next-hop address conservation for non-local generated routes.
379 - Used with redistribute command. Available to maintain BGP routing compliant with RFC 4271 on Nexus OS.
380 type: bool
381 unchanged:
382 description: Set for next-hop address conservation in eBGP outgoing updates
383 type: bool
384 verify_availability:
385 description: Set next-hop ip address tracking with IP SLA
386 type: list
387 elements: dict
388 suboptions:
389 address:
390 description: Set one next-hop address
391 type: str
392 required: true
393 track:
394 description: Set track number
395 type: int
396 required: true
397 drop_on_fail:
398 description: Drop packets instead of using default routing when the configured next hop becomes unreachable
399 type: bool
400 default: false
401 force_order:
402 description: Enable next-hop ordering as specified in the address parameter.
403 type: bool
404 default: false
405 load_share:
406 description: Enable traffic load balancing across a maximum of 32 next-hop addresses
407 type: bool
408 default: false
409 ipv6:
410 description: Configure IPv6 features.
411 type: dict
412 suboptions:
413 address:
414 description: Specify IP address.
415 type: dict
416 suboptions:
417 prefix_list:
418 description: Name of prefix list (Max Size 63).
419 type: str
420 precedence:
421 description: Set precedence field.
422 type: str
423 label_index:
424 description: Set Segment Routing (SR) label index of route.
425 type: int
426 level:
427 description: Where to import route.
428 type: str
429 choices: ["level-1", "level-1-2", "level-2"]
430 local_preference:
431 description: BGP local preference path attribute.
432 type: int
433 metric:
434 description: Set metric for destination routing protocol.
435 type: dict
436 suboptions:
437 bandwidth:
438 description: Metric value or Bandwidth in Kbits per second (Max Size 11).
439 type: int
440 igrp_delay_metric:
441 description: IGRP delay metric.
442 type: int
443 igrp_reliability_metric:
444 description: IGRP reliability metric where 255 is 100 percent reliable.
445 type: int
446 igrp_effective_bandwidth_metric:
447 description: IGRP Effective bandwidth metric (Loading) 255 is 100%.
448 type: int
449 igrp_mtu:
450 description: IGRP MTU of the path.
451 type: int
452 metric_type:
453 description: Type of metric for destination routing protocol.
454 type: str
455 choices: ["external", "internal", "type-1", "type-2"]
456 nssa_only:
457 description: OSPF NSSA Areas.
458 type: bool
459 origin:
460 description: BGP origin code.
461 type: str
462 choices: ["egp", "igp", "incomplete"]
463 path_selection:
464 description: Path selection criteria for BGP.
465 type: str
466 choices: ["all", "backup", "best2", "multipaths"]
467 tag:
468 description: Tag value for destination routing protocol.
469 type: int
470 weight:
471 description: BGP weight for routing table.
472 type: int
473 state:
474 description:
475 - The state the configuration should be left in.
476 - With state I(replaced), for the listed route-maps,
477 sequences that are in running-config but not in the task are negated.
478 - With state I(overridden), all route-maps that are in running-config but
479 not in the task are negated.
480 - Please refer to examples for more details.
481 type: str
482 choices:
483 - merged
484 - replaced
485 - overridden
486 - deleted
487 - parsed
488 - gathered
489 - rendered
490 default: merged
491 """
492 EXAMPLES = """
493 # Using merged
494
495 # Before state:
496 # -------------
497 # nxos-9k-rdo# show running-config | section "^route-map"
498 # nxos-9k-rdo#
499
500 - name: Merge the provided configuration with the existing running configuration
501 cisco.nxos.nxos_route_maps:
502 config:
503 - route_map: rmap1
504 entries:
505 - sequence: 10
506 action: permit
507 description: rmap1-10-permit
508 match:
509 ip:
510 address:
511 access_list: acl_1
512 as_path: Allow40
513 as_number:
514 asn: 65564
515
516 - sequence: 20
517 action: deny
518 description: rmap1-20-deny
519 match:
520 community:
521 community_list:
522 - BGPCommunity1
523 - BGPCommunity2
524 ip:
525 address:
526 prefix_lists:
527 - AllowPrefix1
528 - AllowPrefix2
529 set:
530 dampening:
531 half_life: 30
532 start_reuse_route: 1500
533 start_suppress_route: 10000
534 max_suppress_time: 120
535
536 - route_map: rmap2
537 entries:
538 - sequence: 20
539 action: permit
540 description: rmap2-20-permit
541 continue_sequence: 40
542 match:
543 ipv6:
544 address:
545 prefix_lists: AllowIPv6Prefix
546 interfaces: "{{ nxos_int1 }}"
547 set:
548 as_path:
549 prepend:
550 as_number:
551 - 65563
552 - 65568
553 - 65569
554 comm_list: BGPCommunity
555
556 - sequence: 40
557 action: deny
558 description: rmap2-40-deny
559 match:
560 route_types:
561 - level-1
562 - level-2
563 tags: 2
564 ip:
565 multicast:
566 rp:
567 prefix: 192.0.2.0/24
568 rp_type: ASM
569 source: 203.0.113.0/24
570 group_range:
571 first: 239.0.0.1
572 last: 239.255.255.255
573
574 - route_map: rmap3
575 entries:
576 - sequence: 10
577 description: "*** first stanza ***"
578 action: permit
579 set:
580 ip:
581 next_hop:
582 verify_availability:
583 - address: 3.3.3.3
584 track: 1
585 - address: 4.4.4.4
586 track: 3
587
588 - sequence: 20
589 description: "*** second stanza ***"
590 action: permit
591 set:
592 ip:
593 next_hop:
594 address: 6.6.6.6 2.2.2.2
595 load_share: true
596 drop_on_fail: true
597
598 - sequence: 30
599 description: "*** third stanza ***"
600 action: permit
601 set:
602 ip:
603 next_hop:
604 peer_address: true
605
606 - sequence: 40
607 description: "*** fourth stanza ***"
608 action: permit
609 set:
610 ip:
611 next_hop:
612 unchanged: true
613 redist_unchanged: true
614 state: merged
615
616 # Task output
617 # -------------
618 # before: []
619 #
620 # commands:
621 # - "route-map rmap1 permit 10"
622 # - "match as-number 65564"
623 # - "match as-path Allow40"
624 # - "match ip address acl_1"
625 # - "description rmap1-10-permit"
626 # - "route-map rmap1 deny 20"
627 # - "match community BGPCommunity1 BGPCommunity2"
628 # - "match ip address prefix-list AllowPrefix1 AllowPrefix2"
629 # - "description rmap1-20-deny"
630 # - "set dampening 30 1500 10000 120"
631 # - "route-map rmap2 permit 20"
632 # - "match interface Ethernet1/1"
633 # - "match ipv6 address prefix-list AllowIPv6Prefix"
634 # - "set as-path prepend 65563 65568 65569"
635 # - "description rmap2-20-permit"
636 # - "continue 40"
637 # - "set comm-list BGPCommunity delete"
638 # - "route-map rmap2 deny 40"
639 # - "match ip multicast source 203.0.113.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 192.0.2.0/24 rp-type ASM"
640 # - "match route-type level-1 level-2"
641 # - "match tag 2"
642 # - "description rmap2-40-deny"
643 # - "route-map rmap3 permit 10"
644 # - "description *** first stanza ***"
645 # - "set ip next-hop verify-availability 3.3.3.3 track 1"
646 # - "set ip next-hop verify-availability 4.4.4.4 track 3"
647 # - "route-map rmap3 permit 20"
648 # - "description *** second stanza ***"
649 # - "set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail"
650 # - "route-map rmap3 permit 30"
651 # - "description *** third stanza ***"
652 # - "set ip next-hop peer-address"
653 # - "route-map rmap3 permit 40"
654 # - "description *** fourth stanza ***"
655 # - "set ip next-hop unchanged"
656 # - "set ip next-hop redist-unchanged"
657 #
658 # after:
659 # - route_map: rmap1
660 # entries:
661 # - action: permit
662 # description: rmap1-10-permit
663 # match:
664 # as_number:
665 # asn:
666 # - '65564'
667 # as_path:
668 # - Allow40
669 # ip:
670 # address:
671 # access_list: acl_1
672 # sequence: 10
673 #
674 # - action: deny
675 # description: rmap1-20-deny
676 # match:
677 # community:
678 # community_list:
679 # - BGPCommunity1
680 # - BGPCommunity2
681 # ip:
682 # address:
683 # prefix_lists:
684 # - AllowPrefix1
685 # - AllowPrefix2
686 # sequence: 20
687 # set:
688 # dampening:
689 # half_life: 30
690 # max_suppress_time: 120
691 # start_reuse_route: 1500
692 # start_suppress_route: 10000
693 #
694 # - route_map: rmap2
695 # entries:
696 # - action: permit
697 # continue_sequence: 40
698 # description: rmap2-20-permit
699 # match:
700 # interfaces:
701 # - Ethernet1/1
702 # ipv6:
703 # address:
704 # prefix_lists:
705 # - AllowIPv6Prefix
706 # sequence: 20
707 # set:
708 # as_path:
709 # prepend:
710 # as_number:
711 # - '65563'
712 # - '65568'
713 # - '65569'
714 # comm_list: BGPCommunity
715 #
716 # - action: deny
717 # description: rmap2-40-deny
718 # match:
719 # ip:
720 # multicast:
721 # group_range:
722 # first: 239.0.0.1
723 # last: 239.255.255.255
724 # rp:
725 # prefix: 192.0.2.0/24
726 # rp_type: ASM
727 # source: 203.0.113.0/24
728 # route_types:
729 # - level-1
730 # - level-2
731 # tags:
732 # - 2
733 # sequence: 40
734 #
735 # - route_map: rmap3
736 # entries:
737 # - sequence: 10
738 # description: "*** first stanza ***"
739 # action: permit
740 # set:
741 # ip:
742 # next_hop:
743 # verify_availability:
744 # - address: 3.3.3.3
745 # track: 1
746 # - address: 4.4.4.4
747 # track: 3
748 #
749 # - sequence: 20
750 # description: "*** second stanza ***"
751 # action: permit
752 # set:
753 # ip:
754 # next_hop:
755 # address: 6.6.6.6 2.2.2.2
756 # load_share: true
757 # drop_on_fail: true
758 #
759 # - sequence: 30
760 # description: "*** third stanza ***"
761 # action: permit
762 # set:
763 # ip:
764 # next_hop:
765 # peer_address: true
766 #
767 # - sequence: 40
768 # description: "*** fourth stanza ***"
769 # action: permit
770 # set:
771 # ip:
772 # next_hop:
773 # unchanged: true
774 # redist_unchanged: true
775
776 # After state:
777 # ------------
778 # nxos-9k-rdo# show running-config | section "^route-map"
779 # route-map rmap1 permit 10
780 # match as-number 65564
781 # match as-path Allow40
782 # match ip address acl_1
783 # description rmap1-10-permit
784 # route-map rmap1 deny 20
785 # match community BGPCommunity1 BGPCommunity2
786 # match ip address prefix-list AllowPrefix1 AllowPrefix2
787 # description rmap1-20-deny
788 # set dampening 30 1500 10000 120
789 # route-map rmap2 permit 20
790 # match interface Ethernet1/1
791 # match ipv6 address prefix-list AllowIPv6Prefix
792 # set as-path prepend 65563 65568 65569
793 # description rmap2-20-permit
794 # continue 40
795 # set comm-list BGPCommunity delete
796 # route-map rmap2 deny 40
797 # match ip multicast source 203.0.113.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 192.0.2.0/24 rp-type ASM
798 # match route-type level-1 level-2
799 # match tag 2
800 # description rmap2-40-deny
801 # route-map rmap3 permit 10
802 # description *** first stanza ***
803 # set ip next-hop verify-availability 3.3.3.3 track 1
804 # set ip next-hop verify-availability 4.4.4.4 track 3
805 # route-map rmap3 permit 20
806 # description *** second stanza ***
807 # set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail
808 # route-map rmap3 permit 30
809 # description *** third stanza ***
810 # set ip next-hop peer-address
811 # route-map rmap3 permit 40
812 # description *** fourth stanza ***
813 # set ip next-hop unchanged
814 # set ip next-hop redist-unchanged
815 #
816 # Using replaced
817 # (for the listed route-map(s), sequences that are in running-config but not in the task are negated)
818
819 # Before state:
820 # ------------
821 # nxos-9k-rdo# show running-config | section "^route-map"
822 # route-map rmap1 permit 10
823 # match as-number 65564
824 # match as-path Allow40
825 # match ip address acl_1
826 # description rmap1-10-permit
827 # route-map rmap1 deny 20
828 # match community BGPCommunity1 BGPCommunity2
829 # match ip address prefix-list AllowPrefix1 AllowPrefix2
830 # description rmap1-20-deny
831 # set dampening 30 1500 10000 120
832 # route-map rmap2 permit 20
833 # match interface Ethernet1/1
834 # match ipv6 address prefix-list AllowIPv6Prefix
835 # set as-path prepend 65563 65568 65569
836 # description rmap2-20-permit
837 # continue 40
838 # set comm-list BGPCommunity delete
839 # route-map rmap2 deny 40
840 # match ip multicast source 203.0.113.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 192.0.2.0/24 rp-type ASM
841 # match route-type level-1 level-2
842 # match tag 2
843 # description rmap2-40-deny
844 # route-map rmap3 permit 10
845 # description *** first stanza ***
846 # set ip next-hop verify-availability 3.3.3.3 track 1
847 # set ip next-hop verify-availability 4.4.4.4 track 3
848 # route-map rmap3 permit 20
849 # description *** second stanza ***
850 # set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail
851 # route-map rmap3 permit 30
852 # description *** third stanza ***
853 # set ip next-hop peer-address
854 # route-map rmap3 permit 40
855 # description *** fourth stanza ***
856 # set ip next-hop unchanged
857 # set ip next-hop redist-unchanged
858 #
859 - name: Replace route-maps configurations of listed route-maps with provided configurations
860 cisco.nxos.nxos_route_maps:
861 config:
862 - route_map: rmap1
863 entries:
864 - sequence: 20
865 action: deny
866 description: rmap1-20-deny
867 match:
868 community:
869 community_list:
870 - BGPCommunity4
871 - BGPCommunity5
872 ip:
873 address:
874 prefix_lists:
875 - AllowPrefix1
876 set:
877 community:
878 local_as: true
879
880 - route_map: rmap3
881 entries:
882 - sequence: 10
883 description: "*** first stanza ***"
884 action: permit
885 set:
886 ip:
887 next_hop:
888 verify_availability:
889 - address: 3.3.3.3
890 track: 1
891 - sequence: 20
892 description: "*** second stanza ***"
893 action: permit
894 set:
895 ip:
896 next_hop:
897 peer_address: true
898 - sequence: 30
899 description: "*** third stanza ***"
900 action: permit
901 set:
902 ip:
903 next_hop:
904 address: 6.6.6.6 2.2.2.2
905 load_share: true
906 drop_on_fail: true
907 state: replaced
908
909 # Task output
910 # -------------
911 # before:
912 # - route_map: rmap1
913 # entries:
914 # - action: permit
915 # description: rmap1-10-permit
916 # match:
917 # as_number:
918 # asn:
919 # - '65564'
920 # as_path:
921 # - Allow40
922 # ip:
923 # address:
924 # access_list: acl_1
925 # sequence: 10
926 #
927 # - action: deny
928 # description: rmap1-20-deny
929 # match:
930 # community:
931 # community_list:
932 # - BGPCommunity1
933 # - BGPCommunity2
934 # ip:
935 # address:
936 # prefix_lists:
937 # - AllowPrefix1
938 # - AllowPrefix2
939 # sequence: 20
940 # set:
941 # dampening:
942 # half_life: 30
943 # max_suppress_time: 120
944 # start_reuse_route: 1500
945 # start_suppress_route: 10000
946 #
947 # - route_map: rmap2
948 # entries:
949 # - action: permit
950 # continue_sequence: 40
951 # description: rmap2-20-permit
952 # match:
953 # interfaces:
954 # - Ethernet1/1
955 # ipv6:
956 # address:
957 # prefix_lists:
958 # - AllowIPv6Prefix
959 # sequence: 20
960 # set:
961 # as_path:
962 # prepend:
963 # as_number:
964 # - '65563'
965 # - '65568'
966 # - '65569'
967 # comm_list: BGPCommunity
968 #
969 # - action: deny
970 # description: rmap2-40-deny
971 # match:
972 # ip:
973 # multicast:
974 # group_range:
975 # first: 239.0.0.1
976 # last: 239.255.255.255
977 # rp:
978 # prefix: 192.0.2.0/24
979 # rp_type: ASM
980 # source: 203.0.113.0/24
981 # route_types:
982 # - level-1
983 # - level-2
984 # tags:
985 # - 2
986 # sequence: 40
987 #
988 # - route_map: rmap3
989 # entries:
990 # - sequence: 10
991 # description: "*** first stanza ***"
992 # action: permit
993 # set:
994 # ip:
995 # next_hop:
996 # verify_availability:
997 # - address: 3.3.3.3
998 # track: 1
999 # - address: 4.4.4.4
1000 # track: 3
1001 #
1002 # - sequence: 20
1003 # description: "*** second stanza ***"
1004 # action: permit
1005 # set:
1006 # ip:
1007 # next_hop:
1008 # address: 6.6.6.6 2.2.2.2
1009 # load_share: true
1010 # drop_on_fail: true
1011 #
1012 # - sequence: 30
1013 # description: "*** third stanza ***"
1014 # action: permit
1015 # set:
1016 # ip:
1017 # next_hop:
1018 # peer_address: true
1019 #
1020 # - sequence: 40
1021 # description: "*** fourth stanza ***"
1022 # action: permit
1023 # set:
1024 # ip:
1025 # next_hop:
1026 # unchanged: true
1027 # redist_unchanged: true
1028 #
1029 # commands:
1030 # - no route-map rmap1 permit 10
1031 # - route-map rmap1 deny 20
1032 # - no match community BGPCommunity1 BGPCommunity2
1033 # - match community BGPCommunity4 BGPCommunity5
1034 # - no match ip address prefix-list AllowPrefix1 AllowPrefix2
1035 # - match ip address prefix-list AllowPrefix1
1036 # - no set dampening 30 1500 10000 120
1037 # - set community local-AS
1038 # - route-map rmap3 permit 10
1039 # - no set ip next-hop verify-availability 4.4.4.4 track 3
1040 # - route-map rmap3 permit 20
1041 # - no set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail
1042 # - set ip next-hop peer-address
1043 # - route-map rmap3 permit 30
1044 # - no set ip next-hop peer-address
1045 # - set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail
1046 # - no route-map rmap3 permit 40
1047 #
1048 # after:
1049 # - route_map: rmap1
1050 # entries:
1051 # - sequence: 20
1052 # action: deny
1053 # description: rmap1-20-deny
1054 # match:
1055 # community:
1056 # community_list:
1057 # - BGPCommunity4
1058 # - BGPCommunity5
1059 # ip:
1060 # address:
1061 # prefix_lists:
1062 # - AllowPrefix1
1063 # set:
1064 # community:
1065 # local_as: true
1066 #
1067 # - route_map: rmap2
1068 # entries:
1069 # - action: permit
1070 # continue_sequence: 40
1071 # description: rmap2-20-permit
1072 # match:
1073 # interfaces:
1074 # - Ethernet1/1
1075 # ipv6:
1076 # address:
1077 # prefix_lists:
1078 # - AllowIPv6Prefix
1079 # sequence: 20
1080 # set:
1081 # as_path:
1082 # prepend:
1083 # as_number:
1084 # - '65563'
1085 # - '65568'
1086 # - '65569'
1087 # comm_list: BGPCommunity
1088 #
1089 # - action: deny
1090 # description: rmap2-40-deny
1091 # match:
1092 # ip:
1093 # multicast:
1094 # group_range:
1095 # first: 239.0.0.1
1096 # last: 239.255.255.255
1097 # rp:
1098 # prefix: 192.0.2.0/24
1099 # rp_type: ASM
1100 # source: 203.0.113.0/24
1101 # route_types:
1102 # - level-1
1103 # - level-2
1104 # tags:
1105 # - 2
1106 # sequence: 40
1107 #
1108 # - route_map: rmap3
1109 # entries:
1110 # - sequence: 10
1111 # description: "*** first stanza ***"
1112 # action: permit
1113 # set:
1114 # ip:
1115 # next_hop:
1116 # verify_availability:
1117 # - address: 3.3.3.3
1118 # track: 1
1119 # - sequence: 20
1120 # description: "*** second stanza ***"
1121 # action: permit
1122 # set:
1123 # ip:
1124 # next_hop:
1125 # peer_address: true
1126 # - sequence: 30
1127 # description: "*** third stanza ***"
1128 # action: permit
1129 # set:
1130 # ip:
1131 # next_hop:
1132 # address: 6.6.6.6 2.2.2.2
1133 # load_share: true
1134 # drop_on_fail: true
1135
1136 # After state:
1137 # ------------
1138 # nxos-9k-rdo# show running-config | section "^route-map"
1139 # route-map rmap1 deny 20
1140 # description rmap1-20-deny
1141 # match community BGPCommunity4 BGPCommunity5
1142 # match ip address prefix-list AllowPrefix1
1143 # set community local-AS
1144 # route-map rmap2 permit 20
1145 # match interface Ethernet1/1
1146 # match ipv6 address prefix-list AllowIPv6Prefix
1147 # set as-path prepend 65563 65568 65569
1148 # description rmap2-20-permit
1149 # continue 40
1150 # set comm-list BGPCommunity delete
1151 # route-map rmap2 deny 40
1152 # match ip multicast source 203.0.113.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 192.0.2.0/24 rp-type ASM
1153 # match route-type level-1 level-2
1154 # match tag 2
1155 # description rmap2-40-deny
1156 # route-map rmap3 permit 10
1157 # description *** first stanza ***
1158 # set ip next-hop verify-availability 3.3.3.3 track 1
1159 # route-map rmap3 permit 20
1160 # description *** second stanza ***
1161 # set ip next-hop peer-address
1162 # route-map rmap3 permit 30
1163 # description *** third stanza ***
1164 # set ip next-hop 6.6.6.6 2.2.2.2 load-share drop-on-fail
1165
1166 # Using overridden
1167
1168 # Before state:
1169 # ------------
1170 # nxos-9k-rdo# show running-config | section "^route-map"
1171 # route-map rmap1 permit 10
1172 # match as-number 65564
1173 # match as-path Allow40
1174 # match ip address acl_1
1175 # description rmap1-10-permit
1176 # route-map rmap1 deny 20
1177 # match community BGPCommunity1 BGPCommunity2
1178 # match ip address prefix-list AllowPrefix1 AllowPrefix2
1179 # description rmap1-20-deny
1180 # set dampening 30 1500 10000 120
1181 # route-map rmap2 permit 20
1182 # match interface Ethernet1/1
1183 # match ipv6 address prefix-list AllowIPv6Prefix
1184 # set as-path prepend 65563 65568 65569
1185 # description rmap2-20-permit
1186 # continue 40
1187 # set comm-list BGPCommunity delete
1188 # route-map rmap2 deny 40
1189 # match ip multicast source 203.0.113.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 192.0.2.0/24 rp-type ASM
1190 # match route-type level-1 level-2
1191 # match tag 2
1192 # description rmap2-40-deny
1193
1194 - name: Override all route-maps configuration with provided configuration
1195 cisco.nxos.nxos_route_maps:
1196 config:
1197 - route_map: rmap1
1198 entries:
1199 - sequence: 20
1200 action: deny
1201 description: rmap1-20-deny
1202 match:
1203 community:
1204 community_list:
1205 - BGPCommunity4
1206 - BGPCommunity5
1207 ip:
1208 address:
1209 prefix_lists:
1210 - AllowPrefix1
1211 set:
1212 community:
1213 local_as: true
1214 state: overridden
1215
1216 # Task output
1217 # -------------
1218 # before:
1219 # - route_map: rmap1
1220 # entries:
1221 # - action: permit
1222 # description: rmap1-10-permit
1223 # match:
1224 # as_number:
1225 # asn:
1226 # - '65564'
1227 # as_path:
1228 # - Allow40
1229 # ip:
1230 # address:
1231 # access_list: acl_1
1232 # sequence: 10
1233 #
1234 # - action: deny
1235 # description: rmap1-20-deny
1236 # match:
1237 # community:
1238 # community_list:
1239 # - BGPCommunity1
1240 # - BGPCommunity2
1241 # ip:
1242 # address:
1243 # prefix_lists:
1244 # - AllowPrefix1
1245 # - AllowPrefix2
1246 # sequence: 20
1247 # set:
1248 # dampening:
1249 # half_life: 30
1250 # max_suppress_time: 120
1251 # start_reuse_route: 1500
1252 # start_suppress_route: 10000
1253 #
1254 # - route_map: rmap2
1255 # entries:
1256 # - action: permit
1257 # continue_sequence: 40
1258 # description: rmap2-20-permit
1259 # match:
1260 # interfaces:
1261 # - Ethernet1/1
1262 # ipv6:
1263 # address:
1264 # prefix_lists:
1265 # - AllowIPv6Prefix
1266 # sequence: 20
1267 # set:
1268 # as_path:
1269 # prepend:
1270 # as_number:
1271 # - '65563'
1272 # - '65568'
1273 # - '65569'
1274 # comm_list: BGPCommunity
1275 #
1276 # - action: deny
1277 # description: rmap2-40-deny
1278 # match:
1279 # ip:
1280 # multicast:
1281 # group_range:
1282 # first: 239.0.0.1
1283 # last: 239.255.255.255
1284 # rp:
1285 # prefix: 192.0.2.0/24
1286 # rp_type: ASM
1287 # source: 203.0.113.0/24
1288 # route_types:
1289 # - level-1
1290 # - level-2
1291 # tags:
1292 # - 2
1293 # sequence: 40
1294 #
1295 # commands:
1296 # - no route-map rmap1 permit 10
1297 # - route-map rmap1 deny 20
1298 # - no match community BGPCommunity1 BGPCommunity2
1299 # - match community BGPCommunity4 BGPCommunity5
1300 # - no match ip address prefix-list AllowPrefix1 AllowPrefix2
1301 # - match ip address prefix-list AllowPrefix1
1302 # - no set dampening 30 1500 10000 120
1303 # - set community local-AS
1304 # - no route-map rmap2 permit 20
1305 # - no route-map rmap2 deny 40
1306 #
1307 # after:
1308 # - route_map: rmap1
1309 # entries:
1310 # - sequence: 20
1311 # action: deny
1312 # description: rmap1-20-deny
1313 # match:
1314 # community:
1315 # community_list:
1316 # - BGPCommunity4
1317 # - BGPCommunity5
1318 # ip:
1319 # address:
1320 # prefix_lists:
1321 # - AllowPrefix1
1322 # set:
1323 # community:
1324 # local_as: true
1325 #
1326 # After state:
1327 # ------------
1328 # nxos-9k-rdo# sh running-config | section "^route-map"
1329 # route-map rmap1 deny 20
1330 # description rmap1-20-deny
1331 # match community BGPCommunity4 BGPCommunity5
1332 # match ip address prefix-list AllowPrefix1
1333 # set community local-AS
1334
1335 # Using deleted to delete a single route-map
1336
1337 # Before state:
1338 # ------------
1339 # nxos-9k-rdo# show running-config | section "^route-map"
1340 # route-map rmap1 permit 10
1341 # match as-number 65564
1342 # match as-path Allow40
1343 # match ip address acl_1
1344 # description rmap1-10-permit
1345 # route-map rmap1 deny 20
1346 # match community BGPCommunity1 BGPCommunity2
1347 # match ip address prefix-list AllowPrefix1 AllowPrefix2
1348 # description rmap1-20-deny
1349 # set dampening 30 1500 10000 120
1350 # route-map rmap2 permit 20
1351 # match interface Ethernet1/1
1352 # match ipv6 address prefix-list AllowIPv6Prefix
1353 # set as-path prepend 65563 65568 65569
1354 # description rmap2-20-permit
1355 # continue 40
1356 # set comm-list BGPCommunity delete
1357 # route-map rmap2 deny 40
1358 # match ip multicast source 203.0.113.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 192.0.2.0/24 rp-type ASM
1359 # match route-type level-1 level-2
1360 # match tag 2
1361 # description rmap2-40-deny
1362
1363 - name: Delete single route-map
1364 cisco.nxos.nxos_route_maps:
1365 config:
1366 - route_map: rmap1
1367 state: deleted
1368
1369 # Task output
1370 # -------------
1371 # before:
1372 # - route_map: rmap1
1373 # entries:
1374 # - action: permit
1375 # description: rmap1-10-permit
1376 # match:
1377 # as_number:
1378 # asn:
1379 # - '65564'
1380 # as_path:
1381 # - Allow40
1382 # ip:
1383 # address:
1384 # access_list: acl_1
1385 # sequence: 10
1386 #
1387 # - action: deny
1388 # description: rmap1-20-deny
1389 # match:
1390 # community:
1391 # community_list:
1392 # - BGPCommunity1
1393 # - BGPCommunity2
1394 # ip:
1395 # address:
1396 # prefix_lists:
1397 # - AllowPrefix1
1398 # - AllowPrefix2
1399 # sequence: 20
1400 # set:
1401 # dampening:
1402 # half_life: 30
1403 # max_suppress_time: 120
1404 # start_reuse_route: 1500
1405 # start_suppress_route: 10000
1406 #
1407 # - route_map: rmap2
1408 # entries:
1409 # - action: permit
1410 # continue_sequence: 40
1411 # description: rmap2-20-permit
1412 # match:
1413 # interfaces:
1414 # - Ethernet1/1
1415 # ipv6:
1416 # address:
1417 # prefix_lists:
1418 # - AllowIPv6Prefix
1419 # sequence: 20
1420 # set:
1421 # as_path:
1422 # prepend:
1423 # as_number:
1424 # - '65563'
1425 # - '65568'
1426 # - '65569'
1427 # comm_list: BGPCommunity
1428 #
1429 # - action: deny
1430 # description: rmap2-40-deny
1431 # match:
1432 # ip:
1433 # multicast:
1434 # group_range:
1435 # first: 239.0.0.1
1436 # last: 239.255.255.255
1437 # rp:
1438 # prefix: 192.0.2.0/24
1439 # rp_type: ASM
1440 # source: 203.0.113.0/24
1441 # route_types:
1442 # - level-1
1443 # - level-2
1444 # tags:
1445 # - 2
1446 # sequence: 40
1447 #
1448 # commands:
1449 # - no route-map rmap1 permit 10
1450 # - no route-map rmap1 deny 20
1451 #
1452 # after:
1453 # - route_map: rmap2
1454 # entries:
1455 # - action: permit
1456 # continue_sequence: 40
1457 # description: rmap2-20-permit
1458 # match:
1459 # interfaces:
1460 # - Ethernet1/1
1461 # ipv6:
1462 # address:
1463 # prefix_lists:
1464 # - AllowIPv6Prefix
1465 # sequence: 20
1466 # set:
1467 # as_path:
1468 # prepend:
1469 # as_number:
1470 # - '65563'
1471 # - '65568'
1472 # - '65569'
1473 # comm_list: BGPCommunity
1474 #
1475 # - action: deny
1476 # description: rmap2-40-deny
1477 # match:
1478 # ip:
1479 # multicast:
1480 # group_range:
1481 # first: 239.0.0.1
1482 # last: 239.255.255.255
1483 # rp:
1484 # prefix: 192.0.2.0/24
1485 # rp_type: ASM
1486 # source: 203.0.113.0/24
1487 # route_types:
1488 # - level-1
1489 # - level-2
1490 # tags:
1491 # - 2
1492 # sequence: 40
1493 #
1494 # After state:
1495 # ------------
1496 # nxos-9k-rdo# sh running-config | section "^route-map"
1497 # route-map rmap2 permit 20
1498 # match interface Ethernet1/1
1499 # match ipv6 address prefix-list AllowIPv6Prefix
1500 # set as-path prepend 65563 65568 65569
1501 # description rmap2-20-permit
1502 # continue 40
1503 # set comm-list BGPCommunity delete
1504 # route-map rmap2 deny 40
1505 # match ip multicast source 203.0.113.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 192.0.2.0/24 rp-type ASM
1506 # match route-type level-1 level-2
1507 # match tag 2
1508 # description rmap2-40-deny
1509
1510 # Using deleted to delete all route-maps from the device running-config
1511
1512 # Before state:
1513 # ------------
1514 # nxos-9k-rdo# show running-config | section "^route-map"
1515 # route-map rmap1 permit 10
1516 # match as-number 65564
1517 # match as-path Allow40
1518 # match ip address acl_1
1519 # description rmap1-10-permit
1520 # route-map rmap1 deny 20
1521 # match community BGPCommunity1 BGPCommunity2
1522 # match ip address prefix-list AllowPrefix1 AllowPrefix2
1523 # description rmap1-20-deny
1524 # set dampening 30 1500 10000 120
1525 # route-map rmap2 permit 20
1526 # match interface Ethernet1/1
1527 # match ipv6 address prefix-list AllowIPv6Prefix
1528 # set as-path prepend 65563 65568 65569
1529 # description rmap2-20-permit
1530 # continue 40
1531 # set comm-list BGPCommunity delete
1532 # route-map rmap2 deny 40
1533 # match ip multicast source 203.0.113.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 192.0.2.0/24 rp-type ASM
1534 # match route-type level-1 level-2
1535 # match tag 2
1536 # description rmap2-40-deny
1537
1538 - name: Delete all route-maps
1539 cisco.nxos.nxos_route_maps:
1540 state: deleted
1541
1542 # Task output
1543 # -------------
1544 # before:
1545 # - route_map: rmap1
1546 # entries:
1547 # - action: permit
1548 # description: rmap1-10-permit
1549 # match:
1550 # as_number:
1551 # asn:
1552 # - '65564'
1553 # as_path:
1554 # - Allow40
1555 # ip:
1556 # address:
1557 # access_list: acl_1
1558 # sequence: 10
1559 #
1560 # - action: deny
1561 # description: rmap1-20-deny
1562 # match:
1563 # community:
1564 # community_list:
1565 # - BGPCommunity1
1566 # - BGPCommunity2
1567 # ip:
1568 # address:
1569 # prefix_lists:
1570 # - AllowPrefix1
1571 # - AllowPrefix2
1572 # sequence: 20
1573 # set:
1574 # dampening:
1575 # half_life: 30
1576 # max_suppress_time: 120
1577 # start_reuse_route: 1500
1578 # start_suppress_route: 10000
1579 #
1580 # - route_map: rmap2
1581 # entries:
1582 # - action: permit
1583 # continue_sequence: 40
1584 # description: rmap2-20-permit
1585 # match:
1586 # interfaces:
1587 # - Ethernet1/1
1588 # ipv6:
1589 # address:
1590 # prefix_lists:
1591 # - AllowIPv6Prefix
1592 # sequence: 20
1593 # set:
1594 # as_path:
1595 # prepend:
1596 # as_number:
1597 # - '65563'
1598 # - '65568'
1599 # - '65569'
1600 # comm_list: BGPCommunity
1601 #
1602 # - action: deny
1603 # description: rmap2-40-deny
1604 # match:
1605 # ip:
1606 # multicast:
1607 # group_range:
1608 # first: 239.0.0.1
1609 # last: 239.255.255.255
1610 # rp:
1611 # prefix: 192.0.2.0/24
1612 # rp_type: ASM
1613 # source: 203.0.113.0/24
1614 # route_types:
1615 # - level-1
1616 # - level-2
1617 # tags:
1618 # - 2
1619 # sequence: 40
1620 #
1621 # commands:
1622 # - no route-map rmap1 permit 10
1623 # - no route-map rmap1 deny 20
1624 # - no route-map rmap2 permit 20
1625 # - no route-map rmap2 deny 40
1626 #
1627 # after: []
1628 #
1629 # After state:
1630 # ------------
1631 # nxos-9k-rdo# sh running-config | section "^route-map"
1632
1633 - name: Render platform specific configuration lines with state rendered (without connecting to the device)
1634 cisco.nxos.nxos_route_maps:
1635 config:
1636 - route_map: rmap1
1637 entries:
1638 - sequence: 10
1639 action: permit
1640 description: rmap1-10-permit
1641 match:
1642 ip:
1643 address:
1644 access_list: acl_1
1645 as_path: Allow40
1646 as_number:
1647 asn: 65564
1648
1649 - sequence: 20
1650 action: deny
1651 description: rmap1-20-deny
1652 match:
1653 community:
1654 community_list:
1655 - BGPCommunity1
1656 - BGPCommunity2
1657 ip:
1658 address:
1659 prefix_lists:
1660 - AllowPrefix1
1661 - AllowPrefix2
1662 set:
1663 dampening:
1664 half_life: 30
1665 start_reuse_route: 1500
1666 start_suppress_route: 10000
1667 max_suppress_time: 120
1668
1669 - route_map: rmap2
1670 entries:
1671 - sequence: 20
1672 action: permit
1673 description: rmap2-20-permit
1674 continue_sequence: 40
1675 match:
1676 ipv6:
1677 address:
1678 prefix_lists: AllowIPv6Prefix
1679 interfaces: "{{ nxos_int1 }}"
1680 set:
1681 as_path:
1682 prepend:
1683 as_number:
1684 - 65563
1685 - 65568
1686 - 65569
1687 comm_list: BGPCommunity
1688
1689 - sequence: 40
1690 action: deny
1691 description: rmap2-40-deny
1692 match:
1693 route_types:
1694 - level-1
1695 - level-2
1696 tags: 2
1697 ip:
1698 multicast:
1699 rp:
1700 prefix: 192.0.2.0/24
1701 rp_type: ASM
1702 source: 203.0.113.0/24
1703 group_range:
1704 first: 239.0.0.1
1705 last: 239.255.255.255
1706 state: rendered
1707
1708 # Task Output (redacted)
1709 # -----------------------
1710 # rendered:
1711 # - "route-map rmap1 permit 10"
1712 # - "match as-number 65564"
1713 # - "match as-path Allow40"
1714 # - "match ip address acl_1"
1715 # - "description rmap1-10-permit"
1716 # - "route-map rmap1 deny 20"
1717 # - "match community BGPCommunity1 BGPCommunity2"
1718 # - "match ip address prefix-list AllowPrefix1 AllowPrefix2"
1719 # - "description rmap1-20-deny"
1720 # - "set dampening 30 1500 10000 120"
1721 # - "route-map rmap2 permit 20"
1722 # - "match interface Ethernet1/1"
1723 # - "match ipv6 address prefix-list AllowIPv6Prefix"
1724 # - "set as-path prepend 65563 65568 65569"
1725 # - "description rmap2-20-permit"
1726 # - "continue 40"
1727 # - "set comm-list BGPCommunity delete"
1728 # - "route-map rmap2 deny 40"
1729 # - "match ip multicast source 203.0.113.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 192.0.2.0/24 rp-type ASM"
1730 # - "match route-type level-1 level-2"
1731 # - "match tag 2"
1732 # - "description rmap2-40-deny"
1733
1734 # Using parsed
1735
1736 # parsed.cfg
1737 # ------------
1738 # route-map rmap1 permit 10
1739 # match as-number 65564
1740 # match as-path Allow40
1741 # match ip address acl_1
1742 # description rmap1-10-permit
1743 # route-map rmap1 deny 20
1744 # match community BGPCommunity1 BGPCommunity2
1745 # match ip address prefix-list AllowPrefix1 AllowPrefix2
1746 # description rmap1-20-deny
1747 # set dampening 30 1500 10000 120
1748 # route-map rmap2 permit 20
1749 # match interface Ethernet1/1
1750 # match ipv6 address prefix-list AllowIPv6Prefix
1751 # set as-path prepend 65563 65568 65569
1752 # description rmap2-20-permit
1753 # continue 40
1754 # set comm-list BGPCommunity delete
1755 # route-map rmap2 deny 40
1756 # match ip multicast source 203.0.113.0/24 group-range 239.0.0.1 to 239.255.255.255 rp 192.0.2.0/24 rp-type ASM
1757 # match route-type level-1 level-2
1758 # match tag 2
1759 # description rmap2-40-deny
1760
1761 - name: Parse externally provided route-maps configuration
1762 cisco.nxos.nxos_route_maps:
1763 running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}"
1764 state: parsed
1765
1766 # Task output (redacted)
1767 # -----------------------
1768 # parsed:
1769 # - route_map: rmap1
1770 # entries:
1771 # - action: permit
1772 # description: rmap1-10-permit
1773 # match:
1774 # as_number:
1775 # asn:
1776 # - '65564'
1777 # as_path:
1778 # - Allow40
1779 # ip:
1780 # address:
1781 # access_list: acl_1
1782 # sequence: 10
1783 #
1784 # - action: deny
1785 # description: rmap1-20-deny
1786 # match:
1787 # community:
1788 # community_list:
1789 # - BGPCommunity1
1790 # - BGPCommunity2
1791 # ip:
1792 # address:
1793 # prefix_lists:
1794 # - AllowPrefix1
1795 # - AllowPrefix2
1796 # sequence: 20
1797 # set:
1798 # dampening:
1799 # half_life: 30
1800 # max_suppress_time: 120
1801 # start_reuse_route: 1500
1802 # start_suppress_route: 10000
1803 #
1804 # - route_map: rmap2
1805 # entries:
1806 # - action: permit
1807 # continue_sequence: 40
1808 # description: rmap2-20-permit
1809 # match:
1810 # interfaces:
1811 # - Ethernet1/1
1812 # ipv6:
1813 # address:
1814 # prefix_lists:
1815 # - AllowIPv6Prefix
1816 # sequence: 20
1817 # set:
1818 # as_path:
1819 # prepend:
1820 # as_number:
1821 # - '65563'
1822 # - '65568'
1823 # - '65569'
1824 # comm_list: BGPCommunity
1825 #
1826 # - action: deny
1827 # description: rmap2-40-deny
1828 # match:
1829 # ip:
1830 # multicast:
1831 # group_range:
1832 # first: 239.0.0.1
1833 # last: 239.255.255.255
1834 # rp:
1835 # prefix: 192.0.2.0/24
1836 # rp_type: ASM
1837 # source: 203.0.113.0/24
1838 # route_types:
1839 # - level-1
1840 # - level-2
1841 # tags:
1842 # - 2
1843 # sequence: 40
1844
1845 # Using gathered
1846
1847 # Existing route-map config
1848 # ---------------------------
1849 # nxos-9k-rdo# show running-config | section "^route-map"
1850 # route-map rmap1 permit 10
1851 # match as-number 65564
1852 # match as-path Allow40
1853 # match ip address acl_1
1854 # description rmap1-10-permit
1855 # route-map rmap2 permit 20
1856 # match interface Ethernet1/1
1857 # match ipv6 address prefix-list AllowIPv6Prefix
1858 # set as-path prepend 65563 65568 65569
1859 # description rmap2-20-permit
1860 # continue 40
1861 # set comm-list BGPCommunity delete
1862
1863 - name: Gather route-maps facts using gathered
1864 cisco.nxos.nxos_route_maps:
1865 state: gathered
1866
1867 # gathered:
1868 # - route_map: rmap1
1869 # entries:
1870 # - action: permit
1871 # description: rmap1-10-permit
1872 # match:
1873 # as_number:
1874 # asn:
1875 # - '65564'
1876 # as_path:
1877 # - Allow40
1878 # ip:
1879 # address:
1880 # access_list: acl_1
1881 # sequence: 10
1882 #
1883 # - route_map: rmap2
1884 # entries:
1885 # - action: permit
1886 # continue_sequence: 40
1887 # description: rmap2-20-permit
1888 # match:
1889 # interfaces:
1890 # - Ethernet1/1
1891 # ipv6:
1892 # address:
1893 # prefix_lists:
1894 # - AllowIPv6Prefix
1895 # sequence: 20
1896 # set:
1897 # as_path:
1898 # prepend:
1899 # as_number:
1900 # - '65563'
1901 # - '65568'
1902 # - '65569'
1903 # comm_list: BGPCommunity
1904 #
1905 """
1906
1907 RETURN = """
1908 before:
1909 description: The configuration prior to the model invocation.
1910 returned: always
1911 type: dict
1912 sample: >
1913 The configuration returned will always be in the same format
1914 of the parameters above.
1915 after:
1916 description: The resulting configuration model invocation.
1917 returned: when changed
1918 type: dict
1919 sample: >
1920 The configuration returned will always be in the same format
1921 of the parameters above.
1922 commands:
1923 description: The set of commands pushed to the remote device.
1924 returned: always
1925 type: list
1926 sample:
1927 - "route-map rmap1 permit 10"
1928 - "match as-number 65564"
1929 - "match as-path Allow40"
1930 - "match ip address acl_1"
1931 - "description rmap1-10-permit"
1932 - "route-map rmap1 deny 20"
1933 - "match community BGPCommunity1 BGPCommunity2"
1934 """
1935
1936 from ansible.module_utils.basic import AnsibleModule
1937
1938 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.route_maps.route_maps import (
1939 Route_mapsArgs,
1940 )
1941 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.route_maps.route_maps import (
1942 Route_maps,
1943 )
1944
1945
1946 def main():
1947 """
1948 Main entry point for module execution
1949
1950 :returns: the result form module invocation
1951 """
1952 module = AnsibleModule(
1953 argument_spec=Route_mapsArgs.argument_spec,
1954 mutually_exclusive=[["config", "running_config"]],
1955 required_if=[
1956 ["state", "merged", ["config"]],
1957 ["state", "replaced", ["config"]],
1958 ["state", "overridden", ["config"]],
1959 ["state", "rendered", ["config"]],
1960 ["state", "parsed", ["running_config"]],
1961 ],
1962 supports_check_mode=True,
1963 )
1964
1965 result = Route_maps(module).execute_module()
1966 module.exit_json(**result)
1967
1968
1969 if __name__ == "__main__":
1970 main()