Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_bgp_address_family.py

raw symbols SCIP
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_bgp_address_family
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 module: nxos_bgp_address_family
18 short_description: BGP Address Family resource module.
19 description:
20 - This module manages BGP Address Family configuration on devices running Cisco NX-OS.
21 version_added: 2.0.0
22 notes:
23 - Tested against NX-OS 9.3.6.
24 - Unsupported for Cisco MDS
25 - For managing BGP neighbor address family configurations please use
26 the M(cisco.nxos.nxos_bgp_neighbor_address_family) module.
27 - This module works with connection C(network_cli) and C(httpapi).
28 author: Nilashish Chakraborty (@NilashishC)
29 options:
30 running_config:
31 description:
32 - This option is used only with state I(parsed).
33 - The value of this option should be the output received from the NX-OS device
34 by executing the command B(show running-config | section '^router bgp').
35 - The state I(parsed) reads the configuration from C(running_config) option and
36 transforms it into Ansible structured data as per the resource module's argspec
37 and the value is then returned in the I(parsed) key within the result.
38 type: str
39 config:
40 description: A list of BGP process configuration.
41 type: dict
42 suboptions:
43 as_number:
44 description: Autonomous System Number of the router.
45 type: str
46 address_family:
47 description: Address Family related configurations.
48 type: list
49 elements: dict
50 suboptions:
51 afi:
52 description: Address Family indicator.
53 type: str
54 choices: ["ipv4", "ipv6", "link-state", "vpnv4", "vpnv6", "l2vpn"]
55 required: true
56 safi:
57 description: Sub Address Family indicator.
58 type: str
59 choices: ["unicast", "multicast", "mvpn", "evpn"]
60 additional_paths:
61 description: Additional paths configuration.
62 type: dict
63 suboptions:
64 install_backup:
65 description: Install backup path.
66 type: bool
67 receive:
68 description: Additional paths Receive capability.
69 type: bool
70 selection:
71 description: Additional paths selection
72 type: dict
73 suboptions:
74 route_map:
75 description: Route-map for additional paths selection
76 type: str
77 send:
78 description: Additional paths Send capability
79 type: bool
80 advertise_pip:
81 description: Advertise physical ip for type-5 route.
82 type: bool
83 advertise_l2vpn_evpn:
84 description: Enable advertising EVPN routes.
85 type: bool
86 advertise_system_mac:
87 description: Advertise extra EVPN RT-2 with system MAC.
88 type: bool
89 allow_vni_in_ethertag:
90 description: Allow VNI in Ethernet Tag field in EVPN route.
91 type: bool
92 aggregate_address:
93 description: Configure BGP aggregate prefixes
94 type: list
95 elements: dict
96 suboptions:
97 prefix:
98 description: Aggregate prefix.
99 type: str
100 advertise_map:
101 description: Select attribute information from specific routes.
102 type: str
103 as_set:
104 description: Generate AS-SET information.
105 type: bool
106 attribute_map:
107 description: Set attribute information of aggregate.
108 type: str
109 summary_only:
110 description: Do not advertise more specifics.
111 type: bool
112 suppress_map:
113 description: Conditionally filter more specific routes.
114 type: str
115 client_to_client:
116 description: Configure client-to-client route reflection.
117 type: dict
118 suboptions:
119 no_reflection:
120 description: Reflection of routes permitted.
121 type: bool
122 dampen_igp_metric:
123 description: Dampen IGP metric-related changes.
124 type: int
125 dampening:
126 description: Configure route flap dampening.
127 type: dict
128 suboptions:
129 set:
130 description: Set route flap dampening.
131 type: bool
132 decay_half_life:
133 description: Decay half life.
134 type: int
135 start_reuse_route:
136 description: Value to start reusing a route.
137 type: int
138 start_suppress_route:
139 description: Value to start suppressing a route.
140 type: int
141 max_suppress_time:
142 description: Maximum suppress time for stable route.
143 type: int
144 route_map:
145 description: Apply route-map to specify dampening criteria.
146 type: str
147 default_information:
148 description: Control distribution of default information.
149 type: dict
150 suboptions:
151 originate:
152 description: Distribute a default route.
153 type: bool
154 default_metric:
155 description: Set metric of redistributed routes.
156 type: int
157 distance:
158 description: Configure administrative distance.
159 type: dict
160 suboptions:
161 ebgp_routes:
162 description: Distance for EBGP routes.
163 type: int
164 ibgp_routes:
165 description: Distance for IBGP routes.
166 type: int
167 local_routes:
168 description: Distance for local routes.
169 type: int
170 export_gateway_ip:
171 description: Export Gateway IP to Type-5 EVPN routes for VRF
172 type: bool
173 inject_map:
174 description: Routemap which specifies prefixes to inject.
175 type: list
176 elements: dict
177 suboptions:
178 route_map:
179 description: Route-map name.
180 type: str
181 exist_map:
182 description: Routemap which specifies exist condition.
183 type: str
184 copy_attributes:
185 description: Copy attributes from aggregate.
186 type: bool
187 maximum_paths:
188 description: Forward packets over multipath paths.
189 type: dict
190 suboptions:
191 parallel_paths:
192 description: Number of parallel paths.
193 type: int
194 ibgp:
195 description: Configure multipath for IBGP paths.
196 type: dict
197 suboptions:
198 parallel_paths:
199 description: Number of parallel paths.
200 type: int
201 eibgp:
202 description: Configure multipath for both EBGP and IBGP paths.
203 type: dict
204 suboptions:
205 parallel_paths:
206 description: Number of parallel paths.
207 type: int
208 local:
209 description: Configure multipath for local paths.
210 type: dict
211 suboptions:
212 parallel_paths:
213 description: Number of parallel paths.
214 type: int
215 mixed:
216 description: Configure multipath for local and remote paths.
217 type: dict
218 suboptions:
219 parallel_paths:
220 description: Number of parallel paths.
221 type: int
222 networks:
223 description: Configure an IP prefix to advertise.
224 type: list
225 elements: dict
226 suboptions:
227 prefix:
228 description: IP prefix in CIDR format.
229 type: str
230 route_map:
231 description: Route-map name.
232 type: str
233 nexthop:
234 description: Nexthop tracking.
235 type: dict
236 suboptions:
237 route_map:
238 description: Route-map name.
239 type: str
240 trigger_delay:
241 description: Set the delay to trigger nexthop tracking.
242 type: dict
243 suboptions:
244 critical_delay:
245 description:
246 - Nexthop changes affecting reachability.
247 - Delay value (miliseconds).
248 type: int
249 non_critical_delay:
250 description:
251 - Other nexthop changes.
252 - Delay value (miliseconds).
253 type: int
254 redistribute:
255 description: Configure redistribution.
256 type: list
257 elements: dict
258 suboptions:
259 protocol:
260 description:
261 - The name of the protocol.
262 type: str
263 choices: ["am", "direct", "eigrp", "isis", "lisp", "ospf", "ospfv3", "rip", "static", "hmm"]
264 required: true
265 id:
266 description:
267 - The identifier for the protocol specified.
268 type: str
269 route_map:
270 description:
271 - The route map policy to constrain redistribution.
272 type: str
273 required: true
274 retain:
275 description: Retain the routes based on Target VPN Extended Communities.
276 type: dict
277 suboptions:
278 route_target:
279 description: Specify Target VPN Extended Communities
280 type: dict
281 suboptions:
282 retain_all:
283 description: All the routes regardless of Target-VPN community
284 type: bool
285 route_map:
286 description: Apply route-map to filter routes.
287 type: str
288 suppress_inactive:
289 description: Advertise only active routes to peers.
290 type: bool
291 table_map:
292 description:
293 - Policy for filtering/modifying OSPF routes before sending them to RIB.
294 type: dict
295 suboptions:
296 name:
297 description:
298 - The Route Map name.
299 type: str
300 required: true
301 filter:
302 description:
303 - Block the OSPF routes from being sent to RIB.
304 type: bool
305 timers:
306 description: Configure bgp related timers.
307 type: dict
308 suboptions:
309 bestpath_defer:
310 description: Configure bestpath defer timer value for batch prefix processing.
311 type: dict
312 suboptions:
313 defer_time:
314 description: Bestpath defer time (mseconds).
315 type: int
316 maximum_defer_time:
317 description: Maximum bestpath defer time (mseconds).
318 type: int
319 wait_igp_convergence:
320 description: Delay initial bestpath until redistributed IGPs have converged.
321 type: bool
322 vrf:
323 description: Virtual Router Context.
324 type: str
325 state:
326 description:
327 - The state the configuration should be left in.
328 - State I(deleted) only removes BGP attributes that this modules
329 manages and does not negate the BGP process completely.
330 - Refer to examples for more details.
331 type: str
332 choices:
333 - merged
334 - replaced
335 - overridden
336 - deleted
337 - parsed
338 - gathered
339 - rendered
340 default: merged
341 """
342 EXAMPLES = """
343 # Using merged
344
345 # Before state:
346 # -------------
347 # Nexus9000v# show running-config | section "^router bgp"
348 # Nexus9000v#
349
350 - name: Merge the provided configuration with the existing running configuration
351 cisco.nxos.nxos_bgp_address_family:
352 config:
353 as_number: 65536
354 address_family:
355 - afi: ipv4
356 safi: multicast
357 networks:
358 - prefix: 192.0.2.32/27
359 - prefix: 192.0.2.64/27
360 route_map: rmap1
361 nexthop:
362 route_map: rmap2
363 trigger_delay:
364 critical_delay: 120
365 non_critical_delay: 180
366 - afi: ipv4
367 safi: unicast
368 vrf: site-1
369 default_information:
370 originate: true
371 aggregate_address:
372 - prefix: 203.0.113.0/24
373 as_set: true
374 summary_only: true
375 - afi: ipv6
376 safi: multicast
377 vrf: site-1
378 redistribute:
379 - protocol: ospfv3
380 id: 100
381 route_map: rmap-ospf-1
382 - protocol: eigrp
383 id: 101
384 route_map: rmap-eigrp-1
385
386 # Task output:
387 # ------------
388 # before: {}
389 #
390 # commands:
391 # - router bgp 65536
392 # - address-family ipv4 multicast
393 # - nexthop route-map rmap2
394 # - nexthop trigger-delay critical 120 non-critical 180
395 # - network 192.0.2.32/27
396 # - network 192.0.2.64/27 route-map rmap1
397 # - vrf site-1
398 # - address-family ipv4 unicast
399 # - default-information originate
400 # - aggregate-address 203.0.113.0/24 as-set summary-only
401 # - address-family ipv6 multicast
402 # - redistribute ospfv3 100 route-map rmap-ospf-1
403 # - redistribute eigrp 101 route-map rmap-eigrp-1
404 #
405 # after:
406 # as_number: "65536"
407 # address_family:
408 # - afi: ipv4
409 # safi: multicast
410 # networks:
411 # - prefix: 192.0.2.32/27
412 # - prefix: 192.0.2.64/27
413 # route_map: rmap1
414 # nexthop:
415 # route_map: rmap2
416 # trigger_delay:
417 # critical_delay: 120
418 # non_critical_delay: 180
419 # - afi: ipv4
420 # safi: unicast
421 # vrf: site-1
422 # default_information:
423 # originate: true
424 # aggregate_address:
425 # - prefix: 203.0.113.0/24
426 # as_set: true
427 # summary_only: true
428 # - afi: ipv6
429 # safi: multicast
430 # vrf: site-1
431 # redistribute:
432 # - id: "100"
433 # protocol: ospfv3
434 # route_map: rmap-ospf-1
435 # - id: "101"
436 # protocol: eigrp
437 # route_map: rmap-eigrp-1
438
439 # After state:
440 # ------------
441 # Nexus9000v# show running-config | section "^router bgp"
442 # router bgp 65536
443 # address-family ipv4 multicast
444 # nexthop route-map rmap2
445 # nexthop trigger-delay critical 120 non-critical 180
446 # network 192.0.2.32/27
447 # network 192.0.2.64/27 route-map rmap1
448 # vrf site-1
449 # address-family ipv4 unicast
450 # default-information originate
451 # aggregate-address 203.0.113.0/24 as-set summary-only
452 # address-family ipv6 multicast
453 # redistribute ospfv3 100 route-map rmap-ospf-1
454 # redistribute eigrp 101 route-map rmap-eigrp-1
455 #
456
457 # Using replaced
458
459 # Before state:
460 # -------------
461 # Nexus9000v# show running-config | section "^router bgp"
462 # router bgp 65536
463 # address-family ipv4 multicast
464 # nexthop route-map rmap2
465 # nexthop trigger-delay critical 120 non-critical 180
466 # network 192.0.2.32/27
467 # network 192.0.2.64/27 route-map rmap1
468 # vrf site-1
469 # address-family ipv4 unicast
470 # default-information originate
471 # aggregate-address 203.0.113.0/24 as-set summary-only
472 # address-family ipv6 multicast
473 # redistribute ospfv3 100 route-map rmap-ospf-1
474 # redistribute eigrp 101 route-map rmap-eigrp-1
475
476 - name: Replace configuration of specified AFs
477 cisco.nxos.nxos_bgp_address_family:
478 config:
479 as_number: 65536
480 address_family:
481 - afi: ipv4
482 safi: multicast
483 networks:
484 - prefix: 192.0.2.64/27
485 route_map: rmap1
486 nexthop:
487 route_map: rmap2
488 trigger_delay:
489 critical_delay: 120
490 non_critical_delay: 180
491 aggregate_address:
492 - prefix: 203.0.113.0/24
493 as_set: true
494 summary_only: true
495 - afi: ipv4
496 safi: unicast
497 vrf: site-1
498 state: replaced
499
500 # Task output:
501 # ------------
502 # before:
503 # as_number: "65536"
504 # address_family:
505 # - afi: ipv4
506 # safi: multicast
507 # networks:
508 # - prefix: 192.0.2.32/27
509 # - prefix: 192.0.2.64/27
510 # route_map: rmap1
511 # nexthop:
512 # route_map: rmap2
513 # trigger_delay:
514 # critical_delay: 120
515 # non_critical_delay: 180
516 # - afi: ipv4
517 # safi: unicast
518 # vrf: site-1
519 # default_information:
520 # originate: true
521 # aggregate_address:
522 # - prefix: 203.0.113.0/24
523 # as_set: true
524 # summary_only: true
525 # - afi: ipv6
526 # safi: multicast
527 # vrf: site-1
528 # redistribute:
529 # - id: "100"
530 # protocol: ospfv3
531 # route_map: rmap-ospf-1
532 # - id: "101"
533 # protocol: eigrp
534 # route_map: rmap-eigrp-1
535 #
536 # commands:
537 # - router bgp 65536
538 # - address-family ipv4 multicast
539 # - no network 192.0.2.32/27
540 # - aggregate-address 203.0.113.0/24 as-set summary-only
541 # - vrf site-1
542 # - address-family ipv4 unicast
543 # - no default-information originate
544 # - no aggregate-address 203.0.113.0/24 as-set summary-only
545 #
546 # after:
547 # as_number: "65536"
548 # address_family:
549 # - afi: ipv4
550 # safi: multicast
551 # networks:
552 # - prefix: 192.0.2.64/27
553 # route_map: rmap1
554 # nexthop:
555 # route_map: rmap2
556 # trigger_delay:
557 # critical_delay: 120
558 # non_critical_delay: 180
559 # aggregate_address:
560 # - prefix: 203.0.113.0/24
561 # as_set: true
562 # summary_only: true
563 #
564 # - afi: ipv4
565 # safi: unicast
566 # vrf: site-1
567 #
568 # - afi: ipv6
569 # safi: multicast
570 # vrf: site-1
571 # redistribute:
572 # - protocol: ospfv3
573 # id: "100"
574 # route_map: rmap-ospf-1
575 # - protocol: eigrp
576 # id: "101"
577 # route_map: rmap-eigrp-1
578
579 # After state:
580 # ------------
581 # Nexus9000v# show running-config | section "^router bgp"
582 # router bgp 65536
583 # address-family ipv4 multicast
584 # nexthop route-map rmap2
585 # nexthop trigger-delay critical 120 non-critical 180
586 # network 192.0.2.64/27 route-map rmap1
587 # aggregate-address 203.0.113.0/24 as-set summary-only
588 # vrf site-1
589 # address-family ipv4 unicast
590 # address-family ipv6 multicast
591 # redistribute ospfv3 100 route-map rmap-ospf-1
592 # redistribute eigrp 101 route-map rmap-eigrp-1
593
594 # Using overridden
595
596 # Before state:
597 # -------------
598 # Nexus9000v# show running-config | section "^router bgp"
599 # router bgp 65536
600 # address-family ipv4 multicast
601 # nexthop route-map rmap2
602 # nexthop trigger-delay critical 120 non-critical 180
603 # network 192.0.2.32/27
604 # network 192.0.2.64/27 route-map rmap1
605 # vrf site-1
606 # address-family ipv4 unicast
607 # default-information originate
608 # aggregate-address 203.0.113.0/24 as-set summary-only
609 # address-family ipv6 multicast
610 # redistribute ospfv3 100 route-map rmap-ospf-1
611 # redistribute eigrp 101 route-map rmap-eigrp-1
612
613 - name: Override all BGP AF configuration with provided configuration
614 cisco.nxos.nxos_bgp_address_family: &overridden
615 config:
616 as_number: 65536
617 address_family:
618 - afi: ipv4
619 safi: multicast
620 networks:
621 - prefix: 192.0.2.64/27
622 route_map: rmap1
623 aggregate_address:
624 - prefix: 203.0.113.0/24
625 as_set: true
626 summary_only: true
627 - afi: ipv4
628 safi: unicast
629 vrf: site-1
630 state: overridden
631
632 # Task output:
633 # ------------
634 # before:
635 # as_number: "65536"
636 # address_family:
637 # - afi: ipv4
638 # safi: multicast
639 # networks:
640 # - prefix: 192.0.2.32/27
641 # - prefix: 192.0.2.64/27
642 # route_map: rmap1
643 # nexthop:
644 # route_map: rmap2
645 # trigger_delay:
646 # critical_delay: 120
647 # non_critical_delay: 180
648 # - afi: ipv4
649 # safi: unicast
650 # vrf: site-1
651 # default_information:
652 # originate: true
653 # aggregate_address:
654 # - prefix: 203.0.113.0/24
655 # as_set: true
656 # summary_only: true
657 # - afi: ipv6
658 # safi: multicast
659 # vrf: site-1
660 # redistribute:
661 # - id: "100"
662 # protocol: ospfv3
663 # route_map: rmap-ospf-1
664 # - id: "101"
665 # protocol: eigrp
666 # route_map: rmap-eigrp-1
667 #
668 # commands:
669 # - router bgp 65536
670 # - vrf site-1
671 # - no address-family ipv6 multicast
672 # - exit
673 # - address-family ipv4 multicast
674 # - no nexthop route-map rmap2
675 # - no nexthop trigger-delay critical 120 non-critical 180
676 # - aggregate-address 203.0.113.0/24 as-set summary-only
677 # - no network 192.0.2.32/27
678 # - vrf site-1
679 # - address-family ipv4 unicast
680 # - no default-information originate
681 # - no aggregate-address 203.0.113.0/24 as-set summary-only
682 #
683 # after:
684 # as_number: "65536"
685 # address_family:
686 # - afi: ipv4
687 # safi: multicast
688 # networks:
689 # - prefix: 192.0.2.64/27
690 # route_map: rmap1
691 # aggregate_address:
692 # - prefix: 203.0.113.0/24
693 # as_set: true
694 # summary_only: true
695 # - afi: ipv4
696 # safi: unicast
697 # vrf: site-1
698
699 #
700 # After state:
701 # ------------
702 # Nexus9000v# show running-config | section "^router bgp"
703 # router bgp 65536
704 # address-family ipv4 multicast
705 # network 192.0.2.64/27 route-map rmap1
706 # aggregate-address 203.0.113.0/24 as-set summary-only
707 # vrf site-1
708 # address-family ipv4 unicast
709 #
710
711 # Using deleted to remove specified AFs
712
713 # Before state:
714 # -------------
715 # Nexus9000v# show running-config | section "^router bgp"
716 # router bgp 65536
717 # address-family ipv4 multicast
718 # nexthop route-map rmap2
719 # nexthop trigger-delay critical 120 non-critical 180
720 # network 192.0.2.32/27
721 # network 192.0.2.64/27 route-map rmap1
722 # vrf site-1
723 # address-family ipv4 unicast
724 # default-information originate
725 # aggregate-address 203.0.113.0/24 as-set summary-only
726 # address-family ipv6 multicast
727 # redistribute ospfv3 100 route-map rmap-ospf-1
728 # redistribute eigrp 101 route-map rmap-eigrp-1
729
730 - name: Delete specified BGP AFs
731 cisco.nxos.nxos_bgp_address_family:
732 config:
733 as_number: 65536
734 address_family:
735 - afi: ipv4
736 safi: multicast
737 - vrf: site-1
738 afi: ipv6
739 safi: multicast
740 state: deleted
741
742 # Task output:
743 # ------------
744 # before:
745 # as_number: "65536"
746 # address_family:
747 # - afi: ipv4
748 # safi: multicast
749 # networks:
750 # - prefix: 192.0.2.32/27
751 # - prefix: 192.0.2.64/27
752 # route_map: rmap1
753 # nexthop:
754 # route_map: rmap2
755 # trigger_delay:
756 # critical_delay: 120
757 # non_critical_delay: 180
758 # - afi: ipv4
759 # safi: unicast
760 # vrf: site-1
761 # default_information:
762 # originate: true
763 # aggregate_address:
764 # - prefix: 203.0.113.0/24
765 # as_set: true
766 # summary_only: true
767 # - afi: ipv6
768 # safi: multicast
769 # vrf: site-1
770 # redistribute:
771 # - id: "100"
772 # protocol: ospfv3
773 # route_map: rmap-ospf-1
774 # - id: "101"
775 # protocol: eigrp
776 # route_map: rmap-eigrp-1
777 #
778 # commands:
779 # - router bgp 65563
780 # - no address-family ipv4 multicast
781 # - vrf site-1
782 # - no address-family ipv6 multicast
783 #
784 # after:
785 # as_number: "65536"
786 # address_family:
787 # - afi: ipv4
788 # safi: unicast
789 # vrf: site-1
790 # default_information:
791 # originate: true
792 # aggregate_address:
793 # - prefix: 203.0.113.0/24
794 # as_set: true
795 # summary_only: true
796
797 # After state:
798 # ------------
799 # Nexus9000v# show running-config | section "^router bgp"
800 # router bgp 65536
801 # vrf site-1
802 # address-family ipv4 unicast
803 # default-information originate
804 # aggregate-address 203.0.113.0/24 as-set summary-only
805
806 # Using deleted to remove all BGP AFs
807
808 # Before state:
809 # -------------
810 # Nexus9000v# show running-config | section "^router bgp"
811 # router bgp 65536
812 # address-family ipv4 multicast
813 # nexthop route-map rmap2
814 # nexthop trigger-delay critical 120 non-critical 180
815 # network 192.0.2.32/27
816 # network 192.0.2.64/27 route-map rmap1
817 # vrf site-1
818 # address-family ipv4 unicast
819 # default-information originate
820 # aggregate-address 203.0.113.0/24 as-set summary-only
821 # address-family ipv6 multicast
822 # redistribute ospfv3 100 route-map rmap-ospf-1
823 # redistribute eigrp 101 route-map rmap-eigrp-1
824
825 - name: Delete all BGP AFs
826 cisco.nxos.nxos_bgp_address_family:
827 state: deleted
828
829 # Task output:
830 # ------------
831 # before:
832 # as_number: "65536"
833 # address_family:
834 # - afi: ipv4
835 # safi: multicast
836 # networks:
837 # - prefix: 192.0.2.32/27
838 # - prefix: 192.0.2.64/27
839 # route_map: rmap1
840 # nexthop:
841 # route_map: rmap2
842 # trigger_delay:
843 # critical_delay: 120
844 # non_critical_delay: 180
845 # - afi: ipv4
846 # safi: unicast
847 # vrf: site-1
848 # default_information:
849 # originate: true
850 # aggregate_address:
851 # - prefix: 203.0.113.0/24
852 # as_set: true
853 # summary_only: true
854 # - afi: ipv6
855 # safi: multicast
856 # vrf: site-1
857 # redistribute:
858 # - id: "100"
859 # protocol: ospfv3
860 # route_map: rmap-ospf-1
861 # - id: "101"
862 # protocol: eigrp
863 # route_map: rmap-eigrp-1
864 #
865 # commands:
866 # - router bgp 65563
867 # - no address-family ipv4 multicast
868 # - vrf site-1
869 # - no address-family ipv4 unicast
870 # - no address-family ipv6 multicast
871 #
872 # after:
873 # as_number: "65536"
874
875 # After state:
876 # ------------
877 # Nexus9000v# show running-config | section "^router bgp"
878 # router bgp 65536
879 # Nexus9000v#
880
881 # Using rendered
882
883 - name: Render platform specific configuration lines with state rendered (without connecting to the device)
884 cisco.nxos.nxos_bgp_address_family:
885 config:
886 as_number: 65536
887 address_family:
888 - afi: ipv4
889 safi: multicast
890 networks:
891 - prefix: 192.0.2.32/27
892 - prefix: 192.0.2.64/27
893 route_map: rmap1
894 nexthop:
895 route_map: rmap2
896 trigger_delay:
897 critical_delay: 120
898 non_critical_delay: 180
899 - afi: ipv4
900 safi: unicast
901 vrf: site-1
902 default_information:
903 originate: true
904 aggregate_address:
905 - prefix: 203.0.113.0/24
906 as_set: true
907 summary_only: true
908 - afi: ipv6
909 safi: multicast
910 vrf: site-1
911 redistribute:
912 - protocol: ospfv3
913 id: 100
914 route_map: rmap-ospf-1
915 - protocol: eigrp
916 id: 101
917 route_map: rmap-eigrp-1
918 state: rendered
919
920 # Task Output:
921 # ------------
922 # rendered:
923 # - router bgp 65536
924 # - address-family ipv4 multicast
925 # - nexthop route-map rmap2
926 # - nexthop trigger-delay critical 120 non-critical 180
927 # - network 192.0.2.32/27
928 # - network 192.0.2.64/27 route-map rmap1
929 # - vrf site-1
930 # - address-family ipv4 unicast
931 # - default-information originate
932 # - aggregate-address 203.0.113.0/24 as-set summary-only
933 # - address-family ipv6 multicast
934 # - redistribute ospfv3 100 route-map rmap-ospf-1
935 # - redistribute eigrp 101 route-map rmap-eigrp-1
936
937 # Using parsed
938
939 # parsed.cfg
940 # ------------
941 # router bgp 65536
942 # address-family ipv4 multicast
943 # nexthop route-map rmap2
944 # nexthop trigger-delay critical 120 non-critical 180
945 # network 192.0.2.32/27
946 # network 192.0.2.64/27 route-map rmap1
947 # vrf site-1
948 # address-family ipv4 unicast
949 # default-information originate
950 # aggregate-address 203.0.113.0/24 as-set summary-only
951 # address-family ipv6 multicast
952 # redistribute ospfv3 100 route-map rmap-ospf-1
953 # redistribute eigrp 101 route-map rmap-eigrp-1
954
955 - name: Parse externally provided BGP AF config
956 cisco.nxos.nxos_bgp_address_family:
957 running_config: "{{ lookup('file', 'parsed.cfg') }}"
958 state: parsed
959
960 # Task output:
961 # ------------
962 # parsed:
963 # as_number: "65536"
964 # address_family:
965 # - afi: ipv4
966 # safi: multicast
967 # networks:
968 # - prefix: 192.0.2.32/27
969 # - prefix: 192.0.2.64/27
970 # route_map: rmap1
971 # nexthop:
972 # route_map: rmap2
973 # trigger_delay:
974 # critical_delay: 120
975 # non_critical_delay: 180
976 # - afi: ipv4
977 # safi: unicast
978 # vrf: site-1
979 # default_information:
980 # originate: true
981 # aggregate_address:
982 # - prefix: 203.0.113.0/24
983 # as_set: true
984 # summary_only: true
985 # - afi: ipv6
986 # safi: multicast
987 # vrf: site-1
988 # redistribute:
989 # - id: "100"
990 # protocol: ospfv3
991 # route_map: rmap-ospf-1
992 # - id: "101"
993 # protocol: eigrp
994 # route_map: rmap-eigrp-1
995 """
996 RETURN = """
997 before:
998 description: The configuration prior to the module execution.
999 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
1000 type: dict
1001 sample: >
1002 This output will always be in the same format as the
1003 module argspec.
1004 after:
1005 description: The resulting configuration after module execution.
1006 returned: when changed
1007 type: dict
1008 sample: >
1009 This output will always be in the same format as the
1010 module argspec.
1011 commands:
1012 description: The set of commands pushed to the remote device.
1013 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
1014 type: list
1015 sample:
1016 - router bgp 65536
1017 - address-family ipv4 multicast
1018 - nexthop route-map rmap2
1019 rendered:
1020 description: The provided configuration in the task rendered in device-native format (offline).
1021 returned: when I(state) is C(rendered)
1022 type: list
1023 sample:
1024 - router bgp 65536
1025 - address-family ipv4 multicast
1026 - nexthop route-map rmap2
1027 gathered:
1028 description: Facts about the network resource gathered from the remote device as structured data.
1029 returned: when I(state) is C(gathered)
1030 type: dict
1031 sample: >
1032 This output will always be in the same format as the
1033 module argspec.
1034 parsed:
1035 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
1036 returned: when I(state) is C(parsed)
1037 type: dict
1038 sample: >
1039 This output will always be in the same format as the
1040 module argspec.
1041 """
1042
1043 from ansible.module_utils.basic import AnsibleModule
1044
1045 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_address_family.bgp_address_family import (
1046 Bgp_address_familyArgs,
1047 )
1048 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.bgp_address_family.bgp_address_family import (
1049 Bgp_address_family,
1050 )
1051
1052
1053 def main():
1054 """
1055 Main entry point for module execution
1056
1057 :returns: the result form module invocation
1058 """
1059 module = AnsibleModule(
1060 argument_spec=Bgp_address_familyArgs.argument_spec,
1061 mutually_exclusive=[["config", "running_config"]],
1062 required_if=[
1063 ["state", "merged", ["config"]],
1064 ["state", "replaced", ["config"]],
1065 ["state", "overridden", ["config"]],
1066 ["state", "rendered", ["config"]],
1067 ["state", "parsed", ["running_config"]],
1068 ],
1069 supports_check_mode=True,
1070 )
1071
1072 result = Bgp_address_family(module).execute_module()
1073 module.exit_json(**result)
1074
1075
1076 if __name__ == "__main__":
1077 main()