Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_bgp_global.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_bgp_global
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 module: nxos_bgp_global
18 short_description: BGP Global resource module.
19 description:
20 - This module manages global BGP configuration on devices running Cisco NX-OS.
21 version_added: 1.4.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 '^router bgp').
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 BGP process configuration.
39 type: dict
40 suboptions:
41 as_number:
42 description: Autonomous System Number of the router.
43 type: str
44 affinity_group:
45 description: Configure an affinity group.
46 type: dict
47 suboptions:
48 group_id:
49 description: Affinity Group ID.
50 type: int
51 bestpath: &bestpath
52 description: Define the default bestpath selection algorithm.
53 type: dict
54 suboptions:
55 always_compare_med:
56 description: Compare MED on paths from different AS.
57 type: bool
58 as_path:
59 description: AS-Path.
60 type: dict
61 suboptions:
62 ignore:
63 description: Ignore AS-Path during bestpath selection.
64 type: bool
65 multipath_relax:
66 description: Relax AS-Path restriction when choosing multipaths.
67 type: bool
68 compare_neighborid:
69 description: When more paths are available than max path config, use neighborid as tie-breaker.
70 type: bool
71 compare_routerid:
72 description: Compare router-id for identical EBGP paths.
73 type: bool
74 cost_community_ignore:
75 description: Ignore cost communities in bestpath selection.
76 type: bool
77 igp_metric_ignore:
78 description: Ignore IGP metric for next-hop during bestpath selection.
79 type: bool
80 med:
81 description: MED
82 type: dict
83 suboptions:
84 confed:
85 description: Compare MED only from paths originated from within a confederation.
86 type: bool
87 missing_as_worst:
88 description: Treat missing MED as highest MED.
89 type: bool
90 non_deterministic:
91 description: Not always pick the best-MED path among paths from same AS.
92 type: bool
93 cluster_id: &cluster_id
94 description: Configure Route Reflector Cluster-ID.
95 type: str
96 confederation: &confederation
97 description: AS confederation parameters.
98 type: dict
99 suboptions:
100 identifier:
101 description: Set routing domain confederation AS.
102 type: str
103 peers:
104 description: Peer ASs in BGP confederation.
105 type: list
106 elements: str
107 disable_policy_batching:
108 description: Disable batching evaluation of outbound policy for a peer.
109 type: dict
110 suboptions:
111 set:
112 description: Set policy batching.
113 type: bool
114 ipv4:
115 description: IPv4 address-family settings.
116 type: dict
117 suboptions:
118 prefix_list:
119 description: Name of prefix-list to apply.
120 type: str
121 ipv6:
122 description: IPv6 address-family settings.
123 type: dict
124 suboptions:
125 prefix_list:
126 description: Name of prefix-list to apply.
127 type: str
128 nexthop:
129 description: Batching based on nexthop.
130 type: bool
131 dynamic_med_interval:
132 description: Sets the interval for dampening of med changes.
133 type: int
134 enforce_first_as:
135 description: Enforce neighbor AS is the first AS in AS-PATH attribute (EBGP).
136 type: bool
137 enhanced_error:
138 description: Enable BGP Enhanced error handling.
139 type: bool
140 fabric_soo:
141 description: Fabric site of origin.
142 type: str
143 fast_external_fallover:
144 description: Immediately reset the session if the link to a directly connected BGP peer goes down.
145 type: bool
146 flush_routes:
147 description: Flush routes in RIB upon controlled restart.
148 type: bool
149 graceful_restart: &graceful_restart
150 description: Configure Graceful Restart functionality.
151 type: dict
152 suboptions:
153 set:
154 description: Enable graceful-restart.
155 type: bool
156 restart_time:
157 description: Maximum time for restart advertised to peers.
158 type: int
159 stalepath_time:
160 description: Maximum time to keep a restarting peer's stale routes.
161 type: int
162 helper:
163 description: Configure Graceful Restart Helper mode functionality.
164 type: bool
165 graceful_shutdown:
166 description: Graceful-shutdown for BGP protocol.
167 type: dict
168 suboptions:
169 activate:
170 description: Send graceful-shutdown community on all routes.
171 type: dict
172 suboptions:
173 set:
174 description: Activate graceful-shutdown.
175 type: bool
176 route_map:
177 description: Apply route-map to modify attributes for outbound.
178 type: str
179 aware:
180 description: Lower preference of routes carrying graceful-shutdown community.
181 type: bool
182 isolate:
183 description: Isolate this router from BGP perspective.
184 type: dict
185 suboptions:
186 set:
187 description: Withdraw remote BGP routes to isolate this router.
188 type: bool
189 include_local:
190 description: Withdraw both local and remote BGP routes.
191 type: bool
192 log_neighbor_changes: &log_nbr
193 description: Log a message for neighbor up/down event.
194 type: bool
195 maxas_limit: &maxas_limit
196 description: Allow AS-PATH attribute from EBGP neighbor imposing a limit on number of ASes.
197 type: int
198 neighbors: &nbr
199 description: Configure BGP neighbors.
200 type: list
201 elements: dict
202 suboptions:
203 neighbor_address:
204 description: IP address/Prefix of the neighbor or interface.
205 type: str
206 required: true
207 bfd:
208 description: Bidirectional Fast Detection for the neighbor.
209 type: dict
210 suboptions:
211 set:
212 description: Set BFD for this neighbor.
213 type: bool
214 singlehop:
215 description: Single-hop session.
216 type: bool
217 multihop:
218 description: Multihop session.
219 type: dict
220 suboptions:
221 set:
222 description: Set BFD multihop.
223 type: bool
224 interval:
225 description: Configure BFD session interval parameters.
226 type: dict
227 suboptions:
228 tx_interval:
229 description: TX interval in milliseconds.
230 type: int
231 min_rx_interval:
232 description: Minimum RX interval.
233 type: int
234 multiplier:
235 description: Detect Multiplier.
236 type: int
237 neighbor_affinity_group:
238 description: Configure an affinity group.
239 type: dict
240 suboptions:
241 group_id:
242 description: Affinity Group ID.
243 type: int
244 bmp_activate_server:
245 description: Specify server ID for activating BMP monitoring for the peer.
246 type: int
247 capability:
248 description: Capability.
249 type: dict
250 suboptions:
251 suppress_4_byte_as:
252 description: Suppress 4-byte AS Capability.
253 type: bool
254 description:
255 description: Neighbor specific description.
256 type: str
257 disable_connected_check:
258 description: Disable check for directly connected peer.
259 type: bool
260 dont_capability_negotiate:
261 description: Don't negotiate capability with this neighbor.
262 type: bool
263 dscp:
264 description: Set dscp value for tcp transport.
265 type: str
266 dynamic_capability:
267 description: Dynamic Capability
268 type: bool
269 ebgp_multihop:
270 description: Specify multihop TTL for remote peer.
271 type: int
272 graceful_shutdown:
273 description: Graceful-shutdown for this neighbor.
274 type: dict
275 suboptions:
276 activate:
277 description: Send graceful-shutdown community.
278 type: dict
279 suboptions:
280 set:
281 description: Set activate.
282 type: bool
283 route_map:
284 description: Apply route-map to modify attributes for outbound.
285 type: str
286 inherit:
287 description: Inherit a template.
288 type: dict
289 suboptions:
290 peer:
291 description: Peer template to inherit.
292 type: str
293 peer_session:
294 description: Peer-session template to inherit.
295 type: str
296 local_as:
297 description:
298 - Specify the local-as number for the eBGP neighbor.
299 - B(Deprecated), Use local_as_config instead, the facts would always render local_as information as a part of local_as_config as_number
300 - This option has been deprecated and will be removed in a release after 2027-01-01.
301 type: str
302 local_as_config:
303 description: Local Autonomous System Number options.
304 type: dict
305 suboptions:
306 as_number:
307 description:
308 - Set Specify the local-as number for the eBGP neighbor.
309 type: str
310 no_prepend:
311 description:
312 - Do not prepend the local-as number to updates from the eBGP neighbor.
313 type: bool
314 replace_as:
315 description:
316 - Prepend only the local-as number to updates to eBGP neighbor.
317 type: bool
318 dual_as:
319 description:
320 - Connect using either the local-as number or the real as.
321 type: bool
322 log_neighbor_changes:
323 description: Log message for neighbor up/down event.
324 type: dict
325 suboptions:
326 set:
327 description:
328 - Set log-neighbor-changes.
329 type: bool
330 disable:
331 description:
332 - Disable logging of neighbor up/down event.
333 type: bool
334 low_memory:
335 description: Behavior in low memory situations.
336 type: dict
337 suboptions:
338 exempt:
339 description: Do not shutdown this peer when under memory pressure.
340 type: bool
341 password:
342 description: Configure a password for neighbor.
343 type: dict
344 suboptions:
345 encryption:
346 description:
347 - 0 specifies an UNENCRYPTED neighbor password.
348 - 3 specifies an 3DES ENCRYPTED neighbor password will follow.
349 - 7 specifies a Cisco type 7 ENCRYPTED neighbor password will follow.
350 type: int
351 key:
352 description: Authentication password.
353 type: str
354 path_attribute:
355 description: BGP path attribute optional filtering.
356 type: list
357 elements: dict
358 suboptions:
359 action:
360 description: Action.
361 type: str
362 choices: ["discard", "treat-as-withdraw"]
363 type:
364 description: Path attribute type
365 type: int
366 range:
367 description: Path attribute range.
368 type: dict
369 suboptions:
370 start:
371 description: Path attribute range start value.
372 type: int
373 end:
374 description: Path attribute range end value.
375 type: int
376 peer_type:
377 description: Neighbor facing
378 type: str
379 choices: ["fabric-border-leaf", "fabric-external"]
380 remote_as:
381 description: Specify Autonomous System Number of the neighbor.
382 type: str
383 remote_as_route_map:
384 description: Route-map to match prefix peer AS number.
385 type: str
386 remove_private_as:
387 description: Remove private AS number from outbound updates.
388 type: dict
389 suboptions:
390 set:
391 description: Remove private AS.
392 type: bool
393 replace_as:
394 description: Replace.
395 type: bool
396 all:
397 description: All.
398 type: bool
399 shutdown:
400 description: Administratively shutdown this neighbor.
401 type: bool
402 timers:
403 description: Configure keepalive and hold timers.
404 type: dict
405 suboptions:
406 keepalive:
407 description: Keepalive interval (seconds).
408 type: int
409 holdtime:
410 description: Holdtime (seconds).
411 type: int
412 transport:
413 description: BGP transport connection.
414 type: dict
415 suboptions:
416 connection_mode:
417 description: Specify type of connection.
418 type: dict
419 suboptions:
420 passive:
421 description: Allow passive connection setup only.
422 type: bool
423 ttl_security:
424 description: Enable TTL Security Mechanism.
425 type: dict
426 suboptions:
427 hops:
428 description: Specify hop count for remote peer.
429 type: int
430 update_source:
431 description: Specify source of BGP session and updates.
432 type: str
433 neighbor_down: &nbr_down
434 description: Handle BGP neighbor down event, due to various reasons.
435 type: dict
436 suboptions:
437 fib_accelerate:
438 description: Accelerate the hardware updates for IP/IPv6 adjacencies for neighbor.
439 type: bool
440 nexthop:
441 description: Nexthop resolution options.
442 type: dict
443 suboptions:
444 suppress_default_resolution:
445 description: Prohibit use of default route for nexthop address resolution.
446 type: bool
447 rd:
448 description: Secondary Route Distinguisher for vxlan multisite border gateway.
449 type: dict
450 suboptions:
451 dual:
452 description: Generate Secondary RD for all VRFs and L2VNIs.
453 type: bool
454 id:
455 description: Specify 2 byte value for ID.
456 type: int
457 reconnect_interval: &reconn_intv
458 description: Configure connection reconnect interval.
459 type: int
460 router_id: &rtr_id
461 description: Specify the IP address to use as router-id.
462 type: str
463 shutdown: &shtdwn
464 description: Administratively shutdown BGP protocol.
465 type: bool
466 suppress_fib_pending: &suppr
467 description: Advertise only routes that are programmed in hardware to peers.
468 type: bool
469 timers: &timers
470 description: Configure bgp related timers.
471 type: dict
472 suboptions:
473 bestpath_limit:
474 description: Configure timeout for first bestpath after restart.
475 type: dict
476 suboptions:
477 timeout:
478 description: Bestpath timeout (seconds).
479 type: int
480 always:
481 description: Configure update-delay-always option.
482 type: bool
483 bgp:
484 description: Configure different bgp keepalive and holdtimes.
485 type: dict
486 suboptions:
487 keepalive:
488 description: Keepalive interval (seconds).
489 type: int
490 holdtime:
491 description: Holdtime (seconds).
492 type: int
493 prefix_peer_timeout:
494 description: Prefix Peer timeout (seconds).
495 type: int
496 prefix_peer_wait:
497 description: Configure wait timer for a prefix peer.
498 type: int
499 vrfs:
500 description: Virtual Router Context configurations.
501 type: list
502 elements: dict
503 suboptions:
504 vrf:
505 description: VRF name.
506 type: str
507 allocate_index:
508 description: Configure allocate-index.
509 type: int
510 bestpath: *bestpath
511 cluster_id: *cluster_id
512 confederation: *confederation
513 graceful_restart: *graceful_restart
514 local_as:
515 description: Specify the local-as for this vrf.
516 type: str
517 log_neighbor_changes: *log_nbr
518 maxas_limit: *maxas_limit
519 neighbors: *nbr
520 neighbor_down: *nbr_down
521 reconnect_interval: *reconn_intv
522 router_id: *rtr_id
523 timers: *timers
524 state:
525 description:
526 - The state the configuration should be left in.
527 - State I(purged) removes all the BGP configurations from the
528 target device. Use caution with this state.
529 - State I(deleted) only removes BGP attributes that this modules
530 manages and does not negate the BGP process completely. Thereby, preserving
531 address-family related configurations under BGP context.
532 - Running states I(deleted) and I(replaced) will result in an error if there
533 are address-family configuration lines present under a neighbor,
534 or a vrf context that is to be removed. Please use the
535 M(cisco.nxos.nxos_bgp_af) or M(cisco.nxos.nxos_bgp_neighbor_af)
536 modules for prior cleanup.
537 - States C(merged) and C(replaced) will result in a failure if BGP is already configured
538 with a different ASN than what is provided in the task. In such cases, please use
539 state C(purged) to remove the existing BGP process and proceed further.
540 - States C(replaced) and C(overridden) have the same behaviour for this module.
541 - Refer to examples for more details.
542 type: str
543 choices:
544 - merged
545 - replaced
546 - overridden
547 - deleted
548 - purged
549 - parsed
550 - gathered
551 - rendered
552 default: merged
553 """
554 EXAMPLES = """
555 # Using merged
556
557 # Before state:
558 # -------------
559 # Nexus9000v# show running-config | section "^router bgp"
560 # Nexus9000v#
561
562 - name: Merge the provided configuration with the existing running configuration
563 cisco.nxos.nxos_bgp_global:
564 config:
565 as_number: 65563
566 router_id: 192.168.1.1
567 bestpath:
568 as_path:
569 multipath_relax: true
570 compare_neighborid: true
571 cost_community_ignore: true
572 confederation:
573 identifier: 42
574 peers:
575 - 65020
576 - 65030
577 - 65040
578 log_neighbor_changes: true
579 maxas_limit: 20
580 neighbors:
581 - neighbor_address: 192.168.1.100
582 neighbor_affinity_group:
583 group_id: 160
584 bmp_activate_server: 1
585 remote_as: 65563
586 description: NBR-1
587 low_memory:
588 exempt: true
589 - neighbor_address: 192.168.1.101
590 remote_as: 65563
591 password:
592 encryption: 7
593 key: 12090404011C03162E
594 neighbor_down:
595 fib_accelerate: true
596 vrfs:
597 - vrf: site-1
598 allocate_index: 5000
599 local_as: 200
600 log_neighbor_changes: true
601 neighbors:
602 - neighbor_address: 198.51.100.1
603 description: site-1-nbr-1
604 password:
605 encryption: 3
606 key: 13D4D3549493D2877B1DC116EE27A6BE
607 remote_as: 65562
608 - neighbor_address: 198.51.100.2
609 remote_as: 65562
610 description: site-1-nbr-2
611 - vrf: site-2
612 local_as: 300
613 log_neighbor_changes: true
614 neighbors:
615 - neighbor_address: 203.0.113.2
616 description: site-2-nbr-1
617 password:
618 encryption: 3
619 key: AF92F4C16A0A0EC5BDF56CF58BC030F6
620 remote_as: 65568
621 neighbor_down:
622 fib_accelerate: true
623
624 # Task output:
625 # ------------
626 # before: {}
627 #
628 # commands:
629 # - router bgp 65563
630 # - bestpath as-path multipath-relax
631 # - bestpath compare-neighborid
632 # - bestpath cost-community ignore
633 # - confederation identifier 42
634 # - log-neighbor-changes
635 # - maxas-limit 20
636 # - neighbor-down fib-accelerate
637 # - router-id 192.168.1.1
638 # - confederation peers 65020 65030 65040
639 # - neighbor 192.168.1.100
640 # - remote-as 65563
641 # - affinity-group 160
642 # - bmp-activate-server 1
643 # - description NBR-1
644 # - low-memory exempt
645 # - neighbor 192.168.1.101
646 # - remote-as 65563
647 # - password 7 12090404011C03162E
648 # - vrf site-1
649 # - allocate-index 5000
650 # - local-as 200
651 # - log-neighbor-changes
652 # - neighbor 198.51.100.1
653 # - remote-as 65562
654 # - description site-1-nbr-1
655 # - password 3 13D4D3549493D2877B1DC116EE27A6BE
656 # - neighbor 198.51.100.2
657 # - remote-as 65562
658 # - description site-1-nbr-2
659 # - vrf site-2
660 # - local-as 300
661 # - log-neighbor-changes
662 # - neighbor-down fib-accelerate
663 # - neighbor 203.0.113.2
664 # - remote-as 65568
665 # - description site-2-nbr-1
666 # - password 3 AF92F4C16A0A0EC5BDF56CF58BC030F6
667 #
668 # after:
669 # as_number: '65563'
670 # bestpath:
671 # as_path:
672 # multipath_relax: true
673 # compare_neighborid: true
674 # cost_community_ignore: true
675 # confederation:
676 # identifier: '42'
677 # peers:
678 # - '65020'
679 # - '65030'
680 # - '65040'
681 # log_neighbor_changes: true
682 # maxas_limit: 20
683 # neighbor_down:
684 # fib_accelerate: true
685 # neighbors:
686 # - bmp_activate_server: 1
687 # description: NBR-1
688 # low_memory:
689 # exempt: true
690 # neighbor_address: 192.168.1.100
691 # neighbor_affinity_group:
692 # group_id: 160
693 # remote_as: '65563'
694 # - neighbor_address: 192.168.1.101
695 # password:
696 # encryption: 7
697 # key: 12090404011C03162E
698 # remote_as: '65563'
699 # router_id: 192.168.1.1
700 # vrfs:
701 # - allocate_index: 5000
702 # local_as: '200'
703 # log_neighbor_changes: true
704 # neighbors:
705 # - description: site-1-nbr-1
706 # neighbor_address: 198.51.100.1
707 # password:
708 # encryption: 3
709 # key: 13D4D3549493D2877B1DC116EE27A6BE
710 # remote_as: '65562'
711 # - description: site-1-nbr-2
712 # neighbor_address: 198.51.100.2
713 # remote_as: '65562'
714 # vrf: site-1
715 # - local_as: '300'
716 # log_neighbor_changes: true
717 # neighbor_down:
718 # fib_accelerate: true
719 # neighbors:
720 # - description: site-2-nbr-1
721 # neighbor_address: 203.0.113.2
722 # password:
723 # encryption: 3
724 # key: AF92F4C16A0A0EC5BDF56CF58BC030F6
725 # remote_as: '65568'
726 # vrf: site-2
727
728
729 # After state:
730 # ------------
731 # Nexus9000v# show running-config | section "^router bgp"
732 # router bgp 65563
733 # router-id 192.168.1.1
734 # confederation identifier 42
735 # confederation peers 65020 65030 65040
736 # bestpath as-path multipath-relax
737 # bestpath cost-community ignore
738 # bestpath compare-neighborid
739 # neighbor-down fib-accelerate
740 # maxas-limit 20
741 # log-neighbor-changes
742 # neighbor 192.168.1.100
743 # low-memory exempt
744 # bmp-activate-server 1
745 # remote-as 65563
746 # description NBR-1
747 # affinity-group 160
748 # neighbor 192.168.1.101
749 # remote-as 65563
750 # password 7 12090404011C03162E
751 # vrf site-1
752 # local-as 200
753 # log-neighbor-changes
754 # allocate-index 5000
755 # neighbor 198.51.100.1
756 # remote-as 65562
757 # description site-1-nbr-1
758 # password 3 13D4D3549493D2877B1DC116EE27A6BE
759 # neighbor 198.51.100.2
760 # remote-as 65562
761 # description site-1-nbr-2
762 # vrf site-2
763 # local-as 300
764 # neighbor-down fib-accelerate
765 # log-neighbor-changes
766 # neighbor 203.0.113.2
767 # remote-as 65568
768 # description site-2-nbr-1
769 # password 3 AF92F4C16A0A0EC5BDF56CF58BC030F6
770
771 # Using replaced
772
773 # Before state:
774 # -------------
775 # Nexus9000v# show running-config | section "^router bgp"
776 # router bgp 65563
777 # router-id 192.168.1.1
778 # confederation identifier 42
779 # confederation peers 65020 65030 65040
780 # bestpath as-path multipath-relax
781 # bestpath cost-community ignore
782 # bestpath compare-neighborid
783 # neighbor-down fib-accelerate
784 # maxas-limit 20
785 # log-neighbor-changes
786 # neighbor 192.168.1.100
787 # low-memory exempt
788 # bmp-activate-server 1
789 # remote-as 65563
790 # description NBR-1
791 # affinity-group 160
792 # neighbor 192.168.1.101
793 # remote-as 65563
794 # password 7 12090404011C03162E
795 # vrf site-1
796 # local-as 200
797 # log-neighbor-changes
798 # allocate-index 5000
799 # neighbor 198.51.100.1
800 # remote-as 65562
801 # description site-1-nbr-1
802 # password 3 13D4D3549493D2877B1DC116EE27A6BE
803 # neighbor 198.51.100.2
804 # remote-as 65562
805 # description site-1-nbr-2
806 # vrf site-2
807 # local-as 300
808 # neighbor-down fib-accelerate
809 # log-neighbor-changes
810 # neighbor 203.0.113.2
811 # remote-as 65568
812 # description site-2-nbr-1
813 # password 3 AF92F4C16A0A0EC5BDF56CF58BC030F6
814
815 - name: Replace BGP configuration with provided configuration
816 cisco.nxos.nxos_bgp_global:
817 config:
818 as_number: 65563
819 router_id: 192.168.1.1
820 bestpath:
821 compare_neighborid: true
822 cost_community_ignore: true
823 confederation:
824 identifier: 42
825 peers:
826 - 65020
827 - 65030
828 - 65050
829 maxas_limit: 40
830 neighbors:
831 - neighbor_address: 192.168.1.100
832 neighbor_affinity_group:
833 group_id: 160
834 bmp_activate_server: 1
835 remote_as: 65563
836 description: NBR-1
837 low_memory:
838 exempt: true
839 neighbor_down:
840 fib_accelerate: true
841 vrfs:
842 - vrf: site-2
843 local_as: 300
844 log_neighbor_changes: true
845 neighbors:
846 - neighbor_address: 203.0.113.2
847 password:
848 encryption: 7
849 key: 12090404011C03162E
850 neighbor_down:
851 fib_accelerate: true
852 state: replaced
853
854 # Task output:
855 # ------------
856 # before:
857 # as_number: '65563'
858 # bestpath:
859 # as_path:
860 # multipath_relax: true
861 # compare_neighborid: true
862 # cost_community_ignore: true
863 # confederation:
864 # identifier: '42'
865 # peers:
866 # - '65020'
867 # - '65030'
868 # - '65040'
869 # log_neighbor_changes: true
870 # maxas_limit: 20
871 # neighbor_down:
872 # fib_accelerate: true
873 # neighbors:
874 # - bmp_activate_server: 1
875 # description: NBR-1
876 # low_memory:
877 # exempt: true
878 # neighbor_address: 192.168.1.100
879 # neighbor_affinity_group:
880 # group_id: 160
881 # remote_as: '65563'
882 # - neighbor_address: 192.168.1.101
883 # password:
884 # encryption: 7
885 # key: 12090404011C03162E
886 # remote_as: '65563'
887 # router_id: 192.168.1.1
888 # vrfs:
889 # - allocate_index: 5000
890 # local_as: '200'
891 # log_neighbor_changes: true
892 # neighbors:
893 # - description: site-1-nbr-1
894 # neighbor_address: 198.51.100.1
895 # password:
896 # encryption: 3
897 # key: 13D4D3549493D2877B1DC116EE27A6BE
898 # remote_as: '65562'
899 # - description: site-1-nbr-2
900 # neighbor_address: 198.51.100.2
901 # remote_as: '65562'
902 # vrf: site-1
903 # - local_as: '300'
904 # log_neighbor_changes: true
905 # neighbor_down:
906 # fib_accelerate: true
907 # neighbors:
908 # - description: site-2-nbr-1
909 # neighbor_address: 203.0.113.2
910 # password:
911 # encryption: 3
912 # key: AF92F4C16A0A0EC5BDF56CF58BC030F6
913 # remote_as: '65568'
914 # vrf: site-2
915 #
916 # commands:
917 # - router bgp 65563
918 # - no bestpath as-path multipath-relax
919 # - no log-neighbor-changes
920 # - maxas-limit 40
921 # - no confederation peers 65020 65030 65040
922 # - confederation peers 65020 65030 65050
923 # - no neighbor 192.168.1.101
924 # - vrf site-2
925 # - neighbor 203.0.113.2
926 # - no remote-as 65568
927 # - no description site-2-nbr-1
928 # - password 7 12090404011C03162E
929 # - no vrf site-1
930
931 # after:
932 # as_number: '65563'
933 # bestpath:
934 # compare_neighborid: true
935 # cost_community_ignore: true
936 # confederation:
937 # identifier: '42'
938 # peers:
939 # - '65020'
940 # - '65030'
941 # - '65050'
942 # maxas_limit: 40
943 # neighbor_down:
944 # fib_accelerate: true
945 # neighbors:
946 # - bmp_activate_server: 1
947 # description: NBR-1
948 # low_memory:
949 # exempt: true
950 # neighbor_address: 192.168.1.100
951 # neighbor_affinity_group:
952 # group_id: 160
953 # remote_as: '65563'
954 # router_id: 192.168.1.1
955 # vrfs:
956 # - local_as: '300'
957 # log_neighbor_changes: true
958 # neighbor_down:
959 # fib_accelerate: true
960 # neighbors:
961 # - neighbor_address: 203.0.113.2
962 # password:
963 # encryption: 7
964 # key: 12090404011C03162E
965 # vrf: site-2
966 #
967 # After state:
968 # ------------
969 # Nexus9000v# show running-config | section "^router bgp"
970 # router bgp 65563
971 # router-id 192.168.1.1
972 # confederation identifier 42
973 # confederation peers 65020 65030 65050
974 # bestpath cost-community ignore
975 # bestpath compare-neighborid
976 # neighbor-down fib-accelerate
977 # maxas-limit 40
978 # neighbor 192.168.1.100
979 # low-memory exempt
980 # bmp-activate-server 1
981 # remote-as 65563
982 # description NBR-1
983 # affinity-group 160
984 # vrf site-2
985 # local-as 300
986 # neighbor-down fib-accelerate
987 # log-neighbor-changes
988 # neighbor 203.0.113.2
989 # password 7 12090404011C03162E
990
991 # Using deleted
992
993 # Before state:
994 # -------------
995 # Nexus9000v# show running-config | section "^router bgp"
996 # router bgp 65563
997 # router-id 192.168.1.1
998 # confederation identifier 42
999 # confederation peers 65020 65030 65040
1000 # bestpath as-path multipath-relax
1001 # bestpath cost-community ignore
1002 # bestpath compare-neighborid
1003 # neighbor-down fib-accelerate
1004 # maxas-limit 20
1005 # log-neighbor-changes
1006 # address-family ipv4 unicast
1007 # default-metric 400
1008 # suppress-inactive
1009 # default-information originate
1010 # address-family ipv6 multicast
1011 # wait-igp-convergence
1012 # redistribute eigrp eigrp-1 route-map site-1-rmap
1013 # neighbor 192.168.1.100
1014 # low-memory exempt
1015 # bmp-activate-server 1
1016 # remote-as 65563
1017 # description NBR-1
1018 # affinity-group 160
1019 # neighbor 192.168.1.101
1020 # remote-as 65563
1021 # password 7 12090404011C03162E
1022 # vrf site-1
1023 # local-as 200
1024 # log-neighbor-changes
1025 # allocate-index 5000
1026 # address-family ipv4 multicast
1027 # maximum-paths 40
1028 # dampen-igp-metric 1200
1029 # neighbor 198.51.100.1
1030 # remote-as 65562
1031 # description site-1-nbr-1
1032 # password 3 13D4D3549493D2877B1DC116EE27A6BE
1033 # neighbor 198.51.100.2
1034 # remote-as 65562
1035 # description site-1-nbr-2
1036 # vrf site-2
1037 # local-as 300
1038 # neighbor-down fib-accelerate
1039 # log-neighbor-changes
1040 # neighbor 203.0.113.2
1041 # remote-as 65568
1042 # description site-1-nbr-1
1043 # password 3 AF92F4C16A0A0EC5BDF56CF58BC030F6
1044
1045 - name: Delete BGP configurations handled by this module
1046 cisco.nxos.nxos_bgp_global:
1047 state: deleted
1048
1049 # Task output:
1050 # ------------
1051
1052 # before:
1053 # as_number: '65563'
1054 # bestpath:
1055 # as_path:
1056 # multipath_relax: true
1057 # compare_neighborid: true
1058 # cost_community_ignore: true
1059 # confederation:
1060 # identifier: '42'
1061 # peers:
1062 # - '65020'
1063 # - '65030'
1064 # - '65040'
1065 # log_neighbor_changes: true
1066 # maxas_limit: 20
1067 # neighbor_down:
1068 # fib_accelerate: true
1069 # neighbors:
1070 # - bmp_activate_server: 1
1071 # description: NBR-1
1072 # low_memory:
1073 # exempt: true
1074 # neighbor_address: 192.168.1.100
1075 # neighbor_affinity_group:
1076 # group_id: 160
1077 # remote_as: '65563'
1078 # - neighbor_address: 192.168.1.101
1079 # password:
1080 # encryption: 7
1081 # key: 12090404011C03162E
1082 # remote_as: '65563'
1083 # router_id: 192.168.1.1
1084 # vrfs:
1085 # - allocate_index: 5000
1086 # local_as: '200'
1087 # log_neighbor_changes: true
1088 # neighbors:
1089 # - description: site-1-nbr-1
1090 # neighbor_address: 198.51.100.1
1091 # password:
1092 # encryption: 3
1093 # key: 13D4D3549493D2877B1DC116EE27A6BE
1094 # remote_as: '65562'
1095 # - description: site-1-nbr-2
1096 # neighbor_address: 198.51.100.2
1097 # remote_as: '65562'
1098 # vrf: site-1
1099 # - local_as: '300'
1100 # log_neighbor_changes: true
1101 # neighbor_down:
1102 # fib_accelerate: true
1103 # neighbors:
1104 # - description: site-1-nbr-1
1105 # neighbor_address: 203.0.113.2
1106 # password:
1107 # encryption: 3
1108 # key: AF92F4C16A0A0EC5BDF56CF58BC030F6
1109 # remote_as: '65568'
1110 # vrf: site-2
1111 #
1112 # commands:
1113 # - router bgp 65563
1114 # - no bestpath as-path multipath-relax
1115 # - no bestpath compare-neighborid
1116 # - no bestpath cost-community ignore
1117 # - no confederation identifier 42
1118 # - no log-neighbor-changes
1119 # - no maxas-limit 20
1120 # - no neighbor-down fib-accelerate
1121 # - no router-id 192.168.1.1
1122 # - no confederation peers 65020 65030 65040
1123 # - no neighbor 192.168.1.100
1124 # - no neighbor 192.168.1.101
1125 # - no vrf site-1
1126 # - no vrf site-2
1127 #
1128 # after:
1129 # as_number: '65563'
1130 #
1131 # After state:
1132 # ------------
1133 # Nexus9000v# show running-config | section "^router bgp"
1134 # router bgp 65563
1135 # address-family ipv4 unicast
1136 # default-metric 400
1137 # suppress-inactive
1138 # default-information originate
1139 # address-family ipv6 multicast
1140 # wait-igp-convergence
1141 # redistribute eigrp eigrp-1 route-map site-1-rmap
1142 #
1143
1144 # Using purged
1145
1146 # Before state:
1147 # -------------
1148 # Nexus9000v# show running-config | section "^router bgp"
1149 # router bgp 65563
1150 # router-id 192.168.1.1
1151 # confederation identifier 42
1152 # confederation peers 65020 65030 65040
1153 # bestpath as-path multipath-relax
1154 # bestpath cost-community ignore
1155 # bestpath compare-neighborid
1156 # neighbor-down fib-accelerate
1157 # maxas-limit 20
1158 # log-neighbor-changes
1159 # address-family ipv4 unicast
1160 # default-metric 400
1161 # suppress-inactive
1162 # default-information originate
1163 # address-family ipv6 multicast
1164 # wait-igp-convergence
1165 # redistribute eigrp eigrp-1 route-map site-1-rmap
1166 # neighbor 192.168.1.100
1167 # low-memory exempt
1168 # bmp-activate-server 1
1169 # remote-as 65563
1170 # description NBR-1
1171 # affinity-group 160
1172 # neighbor 192.168.1.101
1173 # remote-as 65563
1174 # password 7 12090404011C03162E
1175 # vrf site-1
1176 # local-as 200
1177 # log-neighbor-changes
1178 # allocate-index 5000
1179 # address-family ipv4 multicast
1180 # maximum-paths 40
1181 # dampen-igp-metric 1200
1182 # neighbor 198.51.100.1
1183 # remote-as 65562
1184 # description site-1-nbr-1
1185 # password 3 13D4D3549493D2877B1DC116EE27A6BE
1186 # neighbor 198.51.100.2
1187 # remote-as 65562
1188 # description site-1-nbr-2
1189 # vrf site-2
1190 # local-as 300
1191 # neighbor-down fib-accelerate
1192 # log-neighbor-changes
1193 # neighbor 203.0.113.2
1194 # remote-as 65568
1195 # description site-1-nbr-1
1196 # password 3 AF92F4C16A0A0EC5BDF56CF58BC030F6
1197
1198 - name: Purge all BGP configurations from the device
1199 cisco.nxos.nxos_bgp_global:
1200 state: purged
1201
1202 # Task output:
1203 # ------------
1204
1205 # before:
1206 # as_number: '65563'
1207 # bestpath:
1208 # as_path:
1209 # multipath_relax: true
1210 # compare_neighborid: true
1211 # cost_community_ignore: true
1212 # confederation:
1213 # identifier: '42'
1214 # peers:
1215 # - '65020'
1216 # - '65030'
1217 # - '65040'
1218 # log_neighbor_changes: true
1219 # maxas_limit: 20
1220 # neighbor_down:
1221 # fib_accelerate: true
1222 # neighbors:
1223 # - bmp_activate_server: 1
1224 # description: NBR-1
1225 # low_memory:
1226 # exempt: true
1227 # neighbor_address: 192.168.1.100
1228 # neighbor_affinity_group:
1229 # group_id: 160
1230 # remote_as: '65563'
1231 # - neighbor_address: 192.168.1.101
1232 # password:
1233 # encryption: 7
1234 # key: 12090404011C03162E
1235 # remote_as: '65563'
1236 # router_id: 192.168.1.1
1237 # vrfs:
1238 # - allocate_index: 5000
1239 # local_as: '200'
1240 # log_neighbor_changes: true
1241 # neighbors:
1242 # - description: site-1-nbr-1
1243 # neighbor_address: 198.51.100.1
1244 # password:
1245 # encryption: 3
1246 # key: 13D4D3549493D2877B1DC116EE27A6BE
1247 # remote_as: '65562'
1248 # - description: site-1-nbr-2
1249 # neighbor_address: 198.51.100.2
1250 # remote_as: '65562'
1251 # vrf: site-1
1252 # - local_as: '300'
1253 # log_neighbor_changes: true
1254 # neighbor_down:
1255 # fib_accelerate: true
1256 # neighbors:
1257 # - description: site-1-nbr-1
1258 # neighbor_address: 203.0.113.2
1259 # password:
1260 # encryption: 3
1261 # key: AF92F4C16A0A0EC5BDF56CF58BC030F6
1262 # remote_as: '65568'
1263 # vrf: site-2
1264 #
1265 # commands:
1266 # - no router bgp 65563
1267 #
1268 # after: {}
1269 #
1270 # After state:
1271 # ------------
1272 # Nexus9000v# show running-config | section "^router bgp"
1273 # Nexus9000v#
1274
1275 # Using rendered
1276
1277 - name: Render platform specific configuration lines (without connecting to the device)
1278 cisco.nxos.nxos_bgp_global:
1279 config:
1280 as_number: 65563
1281 router_id: 192.168.1.1
1282 bestpath:
1283 as_path:
1284 multipath_relax: true
1285 compare_neighborid: true
1286 cost_community_ignore: true
1287 confederation:
1288 identifier: 42
1289 peers:
1290 - 65020
1291 - 65030
1292 - 65040
1293 log_neighbor_changes: true
1294 maxas_limit: 20
1295 neighbors:
1296 - neighbor_address: 192.168.1.100
1297 neighbor_affinity_group:
1298 group_id: 160
1299 bmp_activate_server: 1
1300 remote_as: 65563
1301 description: NBR-1
1302 low_memory:
1303 exempt: true
1304 - neighbor_address: 192.168.1.101
1305 remote_as: 65563
1306 password:
1307 encryption: 7
1308 key: 12090404011C03162E
1309 neighbor_down:
1310 fib_accelerate: true
1311 vrfs:
1312 - vrf: site-1
1313 allocate_index: 5000
1314 local_as: 200
1315 log_neighbor_changes: true
1316 neighbors:
1317 - neighbor_address: 198.51.100.1
1318 description: site-1-nbr-1
1319 password:
1320 encryption: 3
1321 key: 13D4D3549493D2877B1DC116EE27A6BE
1322 remote_as: 65562
1323 - neighbor_address: 198.51.100.2
1324 remote_as: 65562
1325 description: site-1-nbr-2
1326 - vrf: site-2
1327 local_as: 300
1328 log_neighbor_changes: true
1329 neighbors:
1330 - neighbor_address: 203.0.113.2
1331 description: site-1-nbr-1
1332 password:
1333 encryption: 3
1334 key: AF92F4C16A0A0EC5BDF56CF58BC030F6
1335 remote_as: 65568
1336 neighbor_down:
1337 fib_accelerate: true
1338
1339 # Task output:
1340 # ------------
1341 # rendered:
1342 # - router bgp 65563
1343 # - bestpath as-path multipath-relax
1344 # - bestpath compare-neighborid
1345 # - bestpath cost-community ignore
1346 # - confederation identifier 42
1347 # - log-neighbor-changes
1348 # - maxas-limit 20
1349 # - neighbor-down fib-accelerate
1350 # - router-id 192.168.1.1
1351 # - confederation peers 65020 65030 65040
1352 # - neighbor 192.168.1.100
1353 # - remote-as 65563
1354 # - affinity-group 160
1355 # - bmp-activate-server 1
1356 # - description NBR-1
1357 # - low-memory exempt
1358 # - neighbor 192.168.1.101
1359 # - remote-as 65563
1360 # - password 7 12090404011C03162E
1361 # - vrf site-1
1362 # - allocate-index 5000
1363 # - local-as 200
1364 # - log-neighbor-changes
1365 # - neighbor 198.51.100.1
1366 # - remote-as 65562
1367 # - description site-1-nbr-1
1368 # - password 3 13D4D3549493D2877B1DC116EE27A6BE
1369 # - neighbor 198.51.100.2
1370 # - remote-as 65562
1371 # - description site-1-nbr-2
1372 # - vrf site-2
1373 # - local-as 300
1374 # - log-neighbor-changes
1375 # - neighbor-down fib-accelerate
1376 # - neighbor 203.0.113.2
1377 # - remote-as 65568
1378 # - description site-1-nbr-1
1379 # - password 3 AF92F4C16A0A0EC5BDF56CF58BC030F6
1380
1381 # Using parsed
1382
1383 # parsed.cfg
1384 # ------------
1385 # router bgp 65563
1386 # router-id 192.168.1.1
1387 # confederation identifier 42
1388 # confederation peers 65020 65030 65040
1389 # bestpath as-path multipath-relax
1390 # bestpath cost-community ignore
1391 # bestpath compare-neighborid
1392 # neighbor-down fib-accelerate
1393 # maxas-limit 20
1394 # log-neighbor-changes
1395 # neighbor 192.168.1.100
1396 # low-memory exempt
1397 # bmp-activate-server 1
1398 # remote-as 65563
1399 # description NBR-1
1400 # affinity-group 160
1401 # neighbor 192.168.1.101
1402 # remote-as 65563
1403 # password 7 12090404011C03162E
1404 # vrf site-1
1405 # local-as 200
1406 # log-neighbor-changes
1407 # allocate-index 5000
1408 # neighbor 198.51.100.1
1409 # remote-as 65562
1410 # description site-1-nbr-1
1411 # password 3 13D4D3549493D2877B1DC116EE27A6BE
1412 # neighbor 198.51.100.2
1413 # remote-as 65562
1414 # description site-1-nbr-2
1415 # vrf site-2
1416 # local-as 300
1417 # neighbor-down fib-accelerate
1418 # log-neighbor-changes
1419 # neighbor 203.0.113.2
1420 # remote-as 65568
1421 # description site-1-nbr-1
1422 # password 3 AF92F4C16A0A0EC5BDF56CF58BC030F6
1423
1424 - name: Parse externally provided BGP config
1425 cisco.nxos.nxos_bgp_global:
1426 running_config: "{{ lookup('file', 'parsed.cfg') }}"
1427 state: parsed
1428
1429 # Task output:
1430 # ------------
1431 # parsed:
1432 # as_number: '65563'
1433 # bestpath:
1434 # as_path:
1435 # multipath_relax: true
1436 # compare_neighborid: true
1437 # cost_community_ignore: true
1438 # confederation:
1439 # identifier: '42'
1440 # peers:
1441 # - '65020'
1442 # - '65030'
1443 # - '65040'
1444 # log_neighbor_changes: true
1445 # maxas_limit: 20
1446 # neighbor_down:
1447 # fib_accelerate: true
1448 # neighbors:
1449 # - bmp_activate_server: 1
1450 # description: NBR-1
1451 # low_memory:
1452 # exempt: true
1453 # neighbor_address: 192.168.1.100
1454 # neighbor_affinity_group:
1455 # group_id: 160
1456 # remote_as: '65563'
1457 # - neighbor_address: 192.168.1.101
1458 # password:
1459 # encryption: 7
1460 # key: 12090404011C03162E
1461 # remote_as: '65563'
1462 # router_id: 192.168.1.1
1463 # vrfs:
1464 # - allocate_index: 5000
1465 # local_as: '200'
1466 # log_neighbor_changes: true
1467 # neighbors:
1468 # - description: site-1-nbr-1
1469 # neighbor_address: 198.51.100.1
1470 # password:
1471 # encryption: 3
1472 # key: 13D4D3549493D2877B1DC116EE27A6BE
1473 # remote_as: '65562'
1474 # - description: site-1-nbr-2
1475 # neighbor_address: 198.51.100.2
1476 # remote_as: '65562'
1477 # vrf: site-1
1478 # - local_as: '300'
1479 # log_neighbor_changes: true
1480 # neighbor_down:
1481 # fib_accelerate: true
1482 # neighbors:
1483 # - description: site-1-nbr-1
1484 # neighbor_address: 203.0.113.2
1485 # password:
1486 # encryption: 3
1487 # key: AF92F4C16A0A0EC5BDF56CF58BC030F6
1488 # remote_as: '65568'
1489 # vrf: site-2
1490
1491 # Using gathered
1492
1493 # existing config
1494 #
1495 # Nexus9000v# show running-config | section "^router bgp"
1496 # router bgp 65563
1497 # router-id 192.168.1.1
1498 # confederation identifier 42
1499 # confederation peers 65020 65030 65050
1500 # bestpath cost-community ignore
1501 # bestpath compare-neighborid
1502 # neighbor-down fib-accelerate
1503 # maxas-limit 40
1504 # neighbor 192.168.1.100
1505 # low-memory exempt
1506 # bmp-activate-server 1
1507 # remote-as 65563
1508 # description NBR-1
1509 # affinity-group 160
1510 # vrf site-1
1511 # vrf site-2
1512 # local-as 300
1513 # neighbor-down fib-accelerate
1514 # log-neighbor-changes
1515 # neighbor 203.0.113.2
1516 # password 7 12090404011C03162E
1517
1518 - name: Gather BGP facts using gathered
1519 cisco.nxos.nxos_bgp_global:
1520 state: gathered
1521
1522 # Task output:
1523 # ------------
1524 # gathered:
1525 # as_number: '65563'
1526 # bestpath:
1527 # compare_neighborid: true
1528 # cost_community_ignore: true
1529 # confederation:
1530 # identifier: '42'
1531 # peers:
1532 # - '65020'
1533 # - '65030'
1534 # - '65050'
1535 # maxas_limit: 40
1536 # neighbor_down:
1537 # fib_accelerate: true
1538 # neighbors:
1539 # - bmp_activate_server: 1
1540 # description: NBR-1
1541 # low_memory:
1542 # exempt: true
1543 # neighbor_address: 192.168.1.100
1544 # neighbor_affinity_group:
1545 # group_id: 160
1546 # remote_as: '65563'
1547 # router_id: 192.168.1.1
1548 # vrfs:
1549 # - vrf: site-1
1550 # - local_as: '300'
1551 # log_neighbor_changes: true
1552 # neighbor_down:
1553 # fib_accelerate: true
1554 # neighbors:
1555 # - neighbor_address: 203.0.113.2
1556 # password:
1557 # encryption: 7
1558 # key: 12090404011C03162E
1559 # vrf: site-2
1560
1561 # Remove a neighbor having AF configurations with state replaced (will fail)
1562
1563 # Before state:
1564 # -------------
1565 # Nexus9000v# show running-config | section "^router bgp"
1566 # router bgp 65536
1567 # log-neighbor-changes
1568 # maxas-limit 20
1569 # router-id 198.51.100.2
1570 # neighbor 203.0.113.2
1571 # address-family ipv4 unicast
1572 # next-hop-self
1573 # remote-as 65538
1574 # affinity-group 160
1575 # description NBR-1
1576 # low-memory exempt
1577 # neighbor 192.0.2.1
1578 # remote-as 65537
1579 # password 7 12090404011C03162E
1580
1581 - name: Remove a neighbor having AF configurations (should fail)
1582 cisco.nxos.nxos_bgp_global:
1583 config:
1584 as_number: 65536
1585 router_id: 198.51.100.2
1586 maxas_limit: 20
1587 log_neighbor_changes: true
1588 neighbors:
1589 - neighbor_address: 192.0.2.1
1590 remote_as: 65537
1591 password:
1592 encryption: 7
1593 key: 12090404011C03162E
1594 state: replaced
1595
1596 # Task output:
1597 # ------------
1598 # fatal: [Nexus9000v]: FAILED! => changed=false
1599 # msg: Neighbor 203.0.113.2 has address-family configurations.
1600 # Please use the nxos_bgp_neighbor_af module to remove those first.
1601
1602 # Remove a VRF having AF configurations with state replaced (will fail)
1603
1604 # Before state:
1605 # -------------
1606 # Nexus9000v# show running-config | section "^router bgp"
1607 # router bgp 65536
1608 # log-neighbor-changes
1609 # maxas-limit 20
1610 # router-id 198.51.100.2
1611 # neighbor 192.0.2.1
1612 # remote-as 65537
1613 # password 7 12090404011C03162E
1614 # vrf site-1
1615 # address-family ipv4 unicast
1616 # default-information originate
1617 # neighbor 203.0.113.2
1618 # remote-as 65538
1619 # affinity-group 160
1620 # description NBR-1
1621 # low-memory exempt
1622 # vrf site-2
1623 # neighbor-down fib-accelerate
1624
1625 - name: Remove a VRF having AF configurations (should fail)
1626 cisco.nxos.nxos_bgp_global:
1627 config:
1628 as_number: 65536
1629 router_id: 198.51.100.2
1630 maxas_limit: 20
1631 log_neighbor_changes: true
1632 neighbors:
1633 - neighbor_address: 192.0.2.1
1634 remote_as: 65537
1635 password:
1636 encryption: 7
1637 key: 12090404011C03162E
1638 vrfs:
1639 - vrf: site-2
1640 neighbor_down:
1641 fib_accelerate: true
1642 state: replaced
1643
1644 # Task output:
1645 # ------------
1646 # fatal: [Nexus9000v]: FAILED! => changed=false
1647 # msg: VRF site-1 has address-family configurations.
1648 # Please use the nxos_bgp_af module to remove those first.
1649 """
1650
1651 RETURN = """
1652 before:
1653 description: The configuration prior to the model invocation.
1654 returned: always
1655 type: dict
1656 sample: >
1657 The configuration returned will always be in the same format
1658 of the parameters above.
1659 after:
1660 description: The resulting configuration model invocation.
1661 returned: when changed
1662 type: dict
1663 sample: >
1664 The configuration returned will always be in the same format
1665 of the parameters above.
1666 commands:
1667 description: The set of commands pushed to the remote device.
1668 returned: always
1669 type: list
1670 sample:
1671 - router bgp 65563
1672 - maxas-limit 20
1673 - router-id 192.168.1.1
1674 - confederation peers 65020 65030 65040
1675 - neighbor 192.168.1.100
1676 - remote-as 65563
1677 - affinity-group 160
1678 - bmp-activate-server 1
1679 - description NBR-1
1680 - low-memory exempt
1681 - vrf site-1
1682 - log-neighbor-changes
1683 - neighbor 198.51.100.1
1684 - remote-as 65562
1685 - description site-1-nbr-1
1686 - password 3 13D4D3549493D2877B1DC116EE27A6BE
1687 rendered:
1688 description: The provided configuration in the task rendered in device-native format (offline).
1689 returned: when I(state) is C(rendered)
1690 type: list
1691 sample:
1692 - router bgp 65563
1693 - maxas-limit 20
1694 - router-id 192.168.1.1
1695 gathered:
1696 description: Facts about the network resource gathered from the remote device as structured data.
1697 returned: when I(state) is C(gathered)
1698 type: dict
1699 sample: >
1700 This output will always be in the same format as the
1701 module argspec.
1702 parsed:
1703 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
1704 returned: when I(state) is C(parsed)
1705 type: dict
1706 sample: >
1707 This output will always be in the same format as the
1708 module argspec.
1709 """
1710
1711 from ansible.module_utils.basic import AnsibleModule
1712
1713 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_global.bgp_global import (
1714 Bgp_globalArgs,
1715 )
1716 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.bgp_global.bgp_global import (
1717 Bgp_global,
1718 )
1719
1720
1721 def main():
1722 """
1723 Main entry point for module execution
1724
1725 :returns: the result form module invocation
1726 """
1727 module = AnsibleModule(
1728 argument_spec=Bgp_globalArgs.argument_spec,
1729 mutually_exclusive=[["config", "running_config"]],
1730 required_if=[
1731 ["state", "merged", ["config"]],
1732 ["state", "replaced", ["config"]],
1733 ["state", "rendered", ["config"]],
1734 ["state", "parsed", ["running_config"]],
1735 ],
1736 supports_check_mode=True,
1737 )
1738
1739 result = Bgp_global(module).execute_module()
1740 module.exit_json(**result)
1741
1742
1743 if __name__ == "__main__":
1744 main()