Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_bgp_neighbor_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_neighbor_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_neighbor_address_family
18 short_description: BGP Neighbor Address Family resource module.
19 description:
20 - This module manages BGP Neighbor 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 address family configurations please use
26 the M(cisco.nxos.nxos_bgp_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: BGP Neighbor AF configuration.
41 type: dict
42 suboptions:
43 as_number:
44 description: Autonomous System Number of the router.
45 type: str
46 neighbors: &nbr
47 description: A list of BGP Neighbor AF configuration.
48 type: list
49 elements: dict
50 suboptions:
51 neighbor_address:
52 description: IP/IPv6 address of the neighbor.
53 type: str
54 required: true
55 address_family:
56 description: BGP Neighbor Address Family related configurations.
57 type: list
58 elements: dict
59 suboptions:
60 afi:
61 description: Address Family indicator.
62 type: str
63 choices: ["ipv4", "ipv6", "link-state", "vpnv4", "vpnv6", "l2vpn"]
64 required: true
65 safi:
66 description: Sub Address Family indicator.
67 type: str
68 choices: ["unicast", "multicast", "mvpn", "evpn"]
69 advertise_map:
70 description: Specify route-map for conditional advertisement.
71 type: dict
72 suboptions:
73 route_map:
74 description: Route-map name.
75 type: str
76 required: true
77 exist_map:
78 description: Condition route-map to advertise only when prefix in condition exists.
79 type: str
80 non_exist_map:
81 description: Condition route-map to advertise only when prefix in condition does not exist.
82 type: str
83 advertisement_interval:
84 description: Minimum interval between sending BGP routing updates.
85 type: int
86 allowas_in:
87 description: Accept as-path with my AS present in it.
88 type: dict
89 suboptions:
90 set:
91 description: Activate allowas-in property.
92 type: bool
93 max_occurences:
94 description: Number of occurrences of AS number, default is 3.
95 type: int
96 as_override:
97 description: Override matching AS-number while sending update.
98 type: bool
99 capability:
100 description: Advertise capability to the peer.
101 type: dict
102 suboptions:
103 additional_paths:
104 description: Additional paths capability.
105 type: dict
106 suboptions:
107 receive:
108 description: Additional paths Receive capability.
109 type: str
110 choices: ["enable", "disable"]
111 send:
112 description: Additional paths Send capability.
113 type: str
114 choices: ["enable", "disable"]
115 default_originate:
116 description: Originate a default toward this peer.
117 type: dict
118 suboptions:
119 set:
120 description: Set default-originate attribute.
121 type: bool
122 route_map:
123 description: Route-map to specify criteria for originating default.
124 type: str
125 disable_peer_as_check:
126 description: Disable checking of peer AS-number while advertising.
127 type: bool
128 filter_list:
129 description: Name of filter-list.
130 type: dict
131 suboptions:
132 inbound:
133 description: Apply policy to incoming routes.
134 type: str
135 outbound:
136 description: Apply policy to outgoing routes.
137 type: str
138 inherit:
139 description: Inherit a template.
140 type: dict
141 suboptions:
142 template:
143 description: Template name.
144 type: str
145 sequence:
146 description: Sequence number.
147 type: int
148 maximum_prefix:
149 description: Maximum number of prefixes from this neighbor.
150 type: dict
151 suboptions:
152 max_prefix_limit:
153 description: Maximum prefix limit.
154 type: int
155 generate_warning_threshold:
156 description: Threshold percentage at which to generate a warning.
157 type: int
158 restart_interval:
159 description: Restart bgp connection after limit is exceeded.
160 type: int
161 warning_only:
162 description: Only give a warning message when limit is exceeded.
163 type: bool
164 next_hop_self:
165 description: Set our address as nexthop (non-reflected).
166 type: dict
167 suboptions:
168 set:
169 description: Set next-hop-self attribute.
170 type: bool
171 all_routes:
172 description: Set our address as nexthop for all routes.
173 type: bool
174 next_hop_third_party:
175 description: Compute a third-party nexthop if possible.
176 type: bool
177 prefix_list:
178 description: Apply prefix-list.
179 type: dict
180 suboptions:
181 inbound:
182 description: Apply policy to incoming routes.
183 type: str
184 outbound:
185 description: Apply policy to outgoing routes.
186 type: str
187 rewrite_evpn_rt_asn:
188 description: Auto generate RTs for EBGP neighbor.
189 type: bool
190 rewrite_rt_asn:
191 description: Auto generate RTs for EBGP neighbor.
192 type: bool
193 route_map:
194 description: Apply route-map to neighbor.
195 type: dict
196 suboptions:
197 inbound:
198 description: Apply policy to incoming routes.
199 type: str
200 outbound:
201 description: Apply policy to outgoing routes.
202 type: str
203 route_reflector_client:
204 description: Configure a neighbor as Route reflector client.
205 type: bool
206 send_community:
207 description: Send Community attribute to this neighbor.
208 type: dict
209 suboptions:
210 set:
211 description: Set send-community attribute.
212 type: bool
213 extended:
214 description: Send Extended Community attribute.
215 type: bool
216 standard:
217 description: Send Standard Community attribute.
218 type: bool
219 both:
220 description: Send Standard and Extended Community attributes.
221 type: bool
222 soft_reconfiguration_inbound:
223 description: Soft reconfiguration.
224 type: dict
225 suboptions:
226 set:
227 description: Set soft-reconfiguration inbound attribute.
228 type: bool
229 always:
230 description: Always perform inbound soft reconfiguration.
231 type: bool
232 soo:
233 description: Specify Site-of-origin extcommunity.
234 type: str
235 suppress_inactive:
236 description: Advertise only active routes to peer.
237 type: bool
238 unsuppress_map:
239 description: Route-map to selectively unsuppress suppressed routes.
240 type: str
241 weight:
242 description: Set default weight for routes from this neighbor.
243 type: int
244 vrfs:
245 description: Virtual Router Context.
246 type: list
247 elements: dict
248 suboptions:
249 vrf:
250 description: VRF name.
251 type: str
252 neighbors: *nbr
253 state:
254 description:
255 - The state the configuration should be left in.
256 - State I(deleted) only removes BGP attributes that this modules
257 manages and does not negate the BGP process completely.
258 - Refer to examples for more details.
259 type: str
260 choices:
261 - merged
262 - replaced
263 - overridden
264 - deleted
265 - parsed
266 - gathered
267 - rendered
268 default: merged
269 """
270 EXAMPLES = """
271 # Using merged
272
273 # Before state:
274 # -------------
275 # Nexus9000v# show running-config | section "^router bgp"
276 # Nexus9000v#
277
278 - name: Merge the provided configuration with the existing running configuration
279 cisco.nxos.nxos_bgp_neighbor_address_family: &id001
280 config:
281 as_number: 65536
282 neighbors:
283 - neighbor_address: 192.0.2.32
284 address_family:
285 - afi: ipv4
286 safi: unicast
287 maximum_prefix:
288 max_prefix_limit: 20
289 generate_warning_threshold: 75
290 weight: 100
291 prefix_list:
292 inbound: rmap1
293 outbound: rmap2
294 - afi: ipv6
295 safi: unicast
296 - neighbor_address: 192.0.2.33
297 address_family:
298 - afi: ipv4
299 safi: multicast
300 inherit:
301 template: BasePolicy
302 sequence: 200
303 vrfs:
304 - vrf: site-1
305 neighbors:
306 - neighbor_address: 203.0.113.1
307 address_family:
308 - afi: ipv4
309 safi: unicast
310 suppress_inactive: true
311 next_hop_self:
312 set: true
313 - neighbor_address: 203.0.113.2
314 address_family:
315 - afi: ipv6
316 safi: unicast
317 - afi: ipv4
318 safi: multicast
319 send_community:
320 set: true
321
322 # Task output:
323 # ------------
324 # before: {}
325 #
326 # commands:
327 # - router bgp 65536
328 # - neighbor 192.0.2.32
329 # - address-family ipv4 unicast
330 # - maximum-prefix 20 75
331 # - weight 100
332 # - prefix-list rmap1 in
333 # - prefix-list rmap2 out
334 # - address-family ipv6 unicast
335 # - neighbor 192.0.2.33
336 # - address-family ipv4 multicast
337 # - inherit peer-policy BasePolicy 200
338 # - vrf site-1
339 # - neighbor 203.0.113.1
340 # - address-family ipv4 unicast
341 # - suppress-inactive
342 # - next-hop-self
343 # - neighbor 203.0.113.2
344 # - address-family ipv6 unicast
345 # - address-family ipv4 multicast
346 # - send-community
347 #
348 # after:
349 # as_number: "65536"
350 # neighbors:
351 # - neighbor_address: 192.0.2.32
352 # address_family:
353 # - afi: ipv4
354 # safi: unicast
355 # maximum_prefix:
356 # max_prefix_limit: 20
357 # generate_warning_threshold: 75
358 # weight: 100
359 # prefix_list:
360 # inbound: rmap1
361 # outbound: rmap2
362 # - afi: ipv6
363 # safi: unicast
364 # - neighbor_address: 192.0.2.33
365 # address_family:
366 # - afi: ipv4
367 # safi: multicast
368 # inherit:
369 # template: BasePolicy
370 # sequence: 200
371 # vrfs:
372 # - vrf: site-1
373 # neighbors:
374 # - neighbor_address: 203.0.113.1
375 # address_family:
376 # - afi: ipv4
377 # safi: unicast
378 # suppress_inactive: true
379 # next_hop_self:
380 # set: true
381 # - neighbor_address: 203.0.113.2
382 # address_family:
383 # - afi: ipv4
384 # safi: multicast
385 # send_community:
386 # set: true
387 # - afi: ipv6
388 # safi: unicast
389
390 # After state:
391 # ------------
392 # Nexus9000v# show running-config | section "^router bgp"
393 # router bgp 65536
394 # neighbor 192.0.2.32
395 # address-family ipv4 unicast
396 # maximum-prefix 20 75
397 # weight 100
398 # prefix-list rmap1 in
399 # prefix-list rmap2 out
400 # address-family ipv6 unicast
401 # neighbor 192.0.2.33
402 # address-family ipv4 multicast
403 # inherit peer-policy BasePolicy 200
404 # vrf site-1
405 # neighbor 203.0.113.1
406 # address-family ipv4 unicast
407 # suppress-inactive
408 # next-hop-self
409 # neighbor 203.0.113.2
410 # address-family ipv4 multicast
411 # send-community
412 # address-family ipv6 unicast
413 #
414
415 # Using replaced
416
417 # Before state:
418 # -------------
419 # Nexus9000v# show running-config | section "^router bgp"
420 # router bgp 65536
421 # neighbor 192.0.2.32
422 # address-family ipv4 unicast
423 # maximum-prefix 20 75
424 # weight 100
425 # prefix-list rmap1 in
426 # prefix-list rmap2 out
427 # address-family ipv6 unicast
428 # neighbor 192.0.2.33
429 # address-family ipv4 multicast
430 # inherit peer-policy BasePolicy 200
431 # vrf site-1
432 # neighbor 203.0.113.1
433 # address-family ipv4 unicast
434 # suppress-inactive
435 # next-hop-self
436 # neighbor 203.0.113.2
437 # address-family ipv4 multicast
438 # send-community
439 # address-family ipv6 unicast
440 #
441
442 - name: Replace specified neighbor AFs with given configuration
443 cisco.nxos.nxos_bgp_neighbor_address_family: &replaced
444 config:
445 as_number: 65536
446 neighbors:
447 - neighbor_address: 192.0.2.32
448 address_family:
449 - afi: ipv4
450 safi: unicast
451 weight: 110
452 - afi: ipv6
453 safi: unicast
454 - neighbor_address: 192.0.2.33
455 address_family:
456 - afi: ipv4
457 safi: multicast
458 inherit:
459 template: BasePolicy
460 sequence: 200
461 vrfs:
462 - vrf: site-1
463 neighbors:
464 - neighbor_address: 203.0.113.1
465 address_family:
466 - afi: ipv4
467 safi: unicast
468 - neighbor_address: 203.0.113.2
469 address_family:
470 - afi: ipv6
471 safi: unicast
472 - afi: ipv4
473 safi: multicast
474 send_community:
475 set: true
476 state: replaced
477
478 # Task output:
479 # ------------
480 # before:
481 # as_number: "65536"
482 # neighbors:
483 # - neighbor_address: 192.0.2.32
484 # address_family:
485 # - afi: ipv4
486 # safi: unicast
487 # maximum_prefix:
488 # max_prefix_limit: 20
489 # generate_warning_threshold: 75
490 # weight: 100
491 # prefix_list:
492 # inbound: rmap1
493 # outbound: rmap2
494 # - afi: ipv6
495 # safi: unicast
496 # - neighbor_address: 192.0.2.33
497 # address_family:
498 # - afi: ipv4
499 # safi: multicast
500 # inherit:
501 # template: BasePolicy
502 # sequence: 200
503 # vrfs:
504 # - vrf: site-1
505 # neighbors:
506 # - neighbor_address: 203.0.113.1
507 # address_family:
508 # - afi: ipv4
509 # safi: unicast
510 # suppress_inactive: true
511 # next_hop_self:
512 # set: true
513 # - neighbor_address: 203.0.113.2
514 # address_family:
515 # - afi: ipv4
516 # safi: multicast
517 # send_community:
518 # set: true
519 # - afi: ipv6
520 # safi: unicast
521 #
522 # commands:
523 # - router bgp 65536
524 # - neighbor 192.0.2.32
525 # - address-family ipv4 unicast
526 # - no maximum-prefix 20 75
527 # - weight 110
528 # - no prefix-list rmap1 in
529 # - no prefix-list rmap2 out
530 # - vrf site-1
531 # - neighbor 203.0.113.1
532 # - address-family ipv4 unicast
533 # - no suppress-inactive
534 # - no next-hop-self
535 #
536 # after:
537 # as_number: "65536"
538 # neighbors:
539 # - neighbor_address: 192.0.2.32
540 # address_family:
541 # - afi: ipv4
542 # safi: unicast
543 # weight: 110
544 # - afi: ipv6
545 # safi: unicast
546 # - neighbor_address: 192.0.2.33
547 # address_family:
548 # - afi: ipv4
549 # safi: multicast
550 # inherit:
551 # template: BasePolicy
552 # sequence: 200
553 # vrfs:
554 # - vrf: site-1
555 # neighbors:
556 # - neighbor_address: 203.0.113.1
557 # address_family:
558 # - afi: ipv4
559 # safi: unicast
560 # - neighbor_address: 203.0.113.2
561 # address_family:
562 # - afi: ipv4
563 # safi: multicast
564 # send_community:
565 # set: true
566 # - afi: ipv6
567 # safi: unicast
568
569 # After state:
570 # ------------
571 # Nexus9000v# show running-config | section "^router bgp"
572 # router bgp 65536
573 # neighbor 192.0.2.32
574 # address-family ipv4 unicast
575 # weight 110
576 # address-family ipv6 unicast
577 # neighbor 192.0.2.33
578 # address-family ipv4 multicast
579 # inherit peer-policy BasePolicy 200
580 # vrf site-1
581 # neighbor 203.0.113.1
582 # address-family ipv4 unicast
583 # neighbor 203.0.113.2
584 # address-family ipv4 multicast
585 # send-community
586 # address-family ipv6 unicast
587 #
588
589 # Using overridden
590
591 # Before state:
592 # -------------
593 # Nexus9000v# show running-config | section "^router bgp"
594 # router bgp 65536
595 # neighbor 192.0.2.32
596 # address-family ipv4 unicast
597 # maximum-prefix 20 75
598 # weight 100
599 # prefix-list rmap1 in
600 # prefix-list rmap2 out
601 # address-family ipv6 unicast
602 # neighbor 192.0.2.33
603 # address-family ipv4 multicast
604 # inherit peer-policy BasePolicy 200
605 # vrf site-1
606 # neighbor 203.0.113.1
607 # address-family ipv4 unicast
608 # suppress-inactive
609 # next-hop-self
610 # neighbor 203.0.113.2
611 # address-family ipv4 multicast
612 # send-community
613 # address-family ipv6 unicast
614 #
615
616 - name: Override all BGP AF configuration with provided configuration
617 cisco.nxos.nxos_bgp_neighbor_address_family:
618 config:
619 as_number: 65536
620 neighbors:
621 - neighbor_address: 192.0.2.32
622 address_family:
623 - afi: ipv4
624 safi: unicast
625 vrfs:
626 - vrf: site-1
627 neighbors:
628 - neighbor_address: 203.0.113.1
629 address_family:
630 - afi: ipv4
631 safi: unicast
632 suppress_inactive: true
633 next_hop_self:
634 set: true
635 state: overridden
636
637 # Task output:
638 # ------------
639 # before:
640 # as_number: "65536"
641 # neighbors:
642 # - neighbor_address: 192.0.2.32
643 # address_family:
644 # - afi: ipv4
645 # safi: unicast
646 # maximum_prefix:
647 # max_prefix_limit: 20
648 # generate_warning_threshold: 75
649 # weight: 100
650 # prefix_list:
651 # inbound: rmap1
652 # outbound: rmap2
653 # - afi: ipv6
654 # safi: unicast
655 # - neighbor_address: 192.0.2.33
656 # address_family:
657 # - afi: ipv4
658 # safi: multicast
659 # inherit:
660 # template: BasePolicy
661 # sequence: 200
662 # vrfs:
663 # - vrf: site-1
664 # neighbors:
665 # - neighbor_address: 203.0.113.1
666 # address_family:
667 # - afi: ipv4
668 # safi: unicast
669 # suppress_inactive: true
670 # next_hop_self:
671 # set: true
672 # - neighbor_address: 203.0.113.2
673 # address_family:
674 # - afi: ipv4
675 # safi: multicast
676 # send_community:
677 # set: true
678 # - afi: ipv6
679 # safi: unicast
680 #
681 # commands:
682 # - router bgp 65536
683 # - neighbor 192.0.2.32
684 # - address-family ipv4 unicast
685 # - no maximum-prefix 20 75
686 # - no weight 100
687 # - no prefix-list rmap1 in
688 # - no prefix-list rmap2 out
689 # - no address-family ipv6 unicast
690 # - neighbor 192.0.2.33
691 # - no address-family ipv4 multicast
692 # - vrf site-1
693 # - neighbor 203.0.113.2
694 # - no address-family ipv4 multicast
695 # - no address-family ipv6 unicast
696 #
697 # after:
698 # as_number: "65536"
699 # neighbors:
700 # - neighbor_address: 192.0.2.32
701 # address_family:
702 # - afi: ipv4
703 # safi: unicast
704 # vrfs:
705 # - vrf: site-1
706 # neighbors:
707 # - neighbor_address: 203.0.113.1
708 # address_family:
709 # - afi: ipv4
710 # safi: unicast
711 # suppress_inactive: true
712 # next_hop_self:
713 # set: true
714
715 # After state:
716 # ------------
717 # Nexus9000v# show running-config | section "^router bgp"
718 # router bgp 65536
719 # neighbor 192.0.2.32
720 # address-family ipv4 unicast
721 # vrf site-1
722 # neighbor 203.0.113.1
723 # address-family ipv4 unicast
724 # suppress-inactive
725 # next-hop-self
726
727 # Using deleted to remove specified neighbor AFs
728
729 # Before state:
730 # -------------
731 # Nexus9000v# show running-config | section "^router bgp"
732 # router bgp 65536
733 # neighbor 192.0.2.32
734 # address-family ipv4 unicast
735 # maximum-prefix 20 75
736 # weight 100
737 # prefix-list rmap1 in
738 # prefix-list rmap2 out
739 # address-family ipv6 unicast
740 # neighbor 192.0.2.33
741 # address-family ipv4 multicast
742 # inherit peer-policy BasePolicy 200
743 # vrf site-1
744 # neighbor 203.0.113.1
745 # address-family ipv4 unicast
746 # suppress-inactive
747 # next-hop-self
748 # neighbor 203.0.113.2
749 # address-family ipv4 multicast
750 # send-community
751 # address-family ipv6 unicast
752 #
753
754 - name: Delete BGP configs handled by this module
755 cisco.nxos.nxos_bgp_neighbor_address_family:
756 config:
757 as_number: 65536
758 neighbors:
759 - neighbor_address: 192.0.2.32
760 address_family:
761 - afi: ipv4
762 safi: unicast
763 vrfs:
764 - vrf: site-1
765 neighbors:
766 - neighbor_address: 203.0.113.2
767 address_family:
768 - afi: ipv6
769 safi: unicast
770 state: deleted
771
772 # Task output:
773 # ------------
774 # before:
775 # as_number: "65536"
776 # neighbors:
777 # - neighbor_address: 192.0.2.32
778 # address_family:
779 # - afi: ipv4
780 # safi: unicast
781 # maximum_prefix:
782 # max_prefix_limit: 20
783 # generate_warning_threshold: 75
784 # weight: 100
785 # prefix_list:
786 # inbound: rmap1
787 # outbound: rmap2
788 # - afi: ipv6
789 # safi: unicast
790 # - neighbor_address: 192.0.2.33
791 # address_family:
792 # - afi: ipv4
793 # safi: multicast
794 # inherit:
795 # template: BasePolicy
796 # sequence: 200
797 # vrfs:
798 # - vrf: site-1
799 # neighbors:
800 # - neighbor_address: 203.0.113.1
801 # address_family:
802 # - afi: ipv4
803 # safi: unicast
804 # suppress_inactive: true
805 # next_hop_self:
806 # set: true
807 # - neighbor_address: 203.0.113.2
808 # address_family:
809 # - afi: ipv4
810 # safi: multicast
811 # send_community:
812 # set: true
813 # - afi: ipv6
814 # safi: unicast
815 #
816 # commands:
817 # - router bgp 65536
818 # - neighbor 192.0.2.32
819 # - no address-family ipv4 unicast
820 # - vrf site-1
821 # - neighbor 203.0.113.2
822 # - no address-family ipv6 unicast
823 #
824 # after:
825 # as_number: "65536"
826 # neighbors:
827 # - neighbor_address: 192.0.2.32
828 # address_family:
829 # - afi: ipv6
830 # safi: unicast
831 # - neighbor_address: 192.0.2.33
832 # address_family:
833 # - afi: ipv4
834 # safi: multicast
835 # inherit:
836 # template: BasePolicy
837 # sequence: 200
838 # vrfs:
839 # - vrf: site-1
840 # neighbors:
841 # - neighbor_address: 203.0.113.1
842 # address_family:
843 # - afi: ipv4
844 # safi: unicast
845 # suppress_inactive: true
846 # next_hop_self:
847 # set: true
848 # - neighbor_address: 203.0.113.2
849 # address_family:
850 # - afi: ipv4
851 # safi: multicast
852 # send_community:
853 # set: true
854 #
855 # After state:
856 # ------------
857 # Nexus9000v# show running-config | section "^router bgp"
858 # router bgp 65536
859 # neighbor 192.0.2.32
860 # address-family ipv6 unicast
861 # neighbor 192.0.2.33
862 # address-family ipv4 multicast
863 # inherit peer-policy BasePolicy 200
864 # vrf site-1
865 # neighbor 203.0.113.1
866 # address-family ipv4 unicast
867 # suppress-inactive
868 # next-hop-self
869 # neighbor 203.0.113.2
870 # address-family ipv4 multicast
871 # send-community
872 #
873
874 # Using deleted to remove all neighbor AFs
875
876 # Before state:
877 # -------------
878 # Nexus9000v# show running-config | section "^router bgp"
879 # router bgp 65536
880 # neighbor 192.0.2.32
881 # address-family ipv4 unicast
882 # maximum-prefix 20 75
883 # weight 100
884 # prefix-list rmap1 in
885 # prefix-list rmap2 out
886 # address-family ipv6 unicast
887 # neighbor 192.0.2.33
888 # address-family ipv4 multicast
889 # inherit peer-policy BasePolicy 200
890 # vrf site-1
891 # neighbor 203.0.113.1
892 # address-family ipv4 unicast
893 # suppress-inactive
894 # next-hop-self
895 # neighbor 203.0.113.2
896 # address-family ipv4 multicast
897 # send-community
898 # address-family ipv6 unicast
899 #
900
901 - name: Delete all BGP neighbor AF configs handled by this module
902 cisco.nxos.nxos_bgp_neighbor_address_family:
903 state: deleted
904
905 # Task output:
906 # ------------
907 # before:
908 # as_number: "65536"
909 # neighbors:
910 # - neighbor_address: 192.0.2.32
911 # address_family:
912 # - afi: ipv4
913 # safi: unicast
914 # maximum_prefix:
915 # max_prefix_limit: 20
916 # generate_warning_threshold: 75
917 # weight: 100
918 # prefix_list:
919 # inbound: rmap1
920 # outbound: rmap2
921 # - afi: ipv6
922 # safi: unicast
923 # - neighbor_address: 192.0.2.33
924 # address_family:
925 # - afi: ipv4
926 # safi: multicast
927 # inherit:
928 # template: BasePolicy
929 # sequence: 200
930 # vrfs:
931 # - vrf: site-1
932 # neighbors:
933 # - neighbor_address: 203.0.113.1
934 # address_family:
935 # - afi: ipv4
936 # safi: unicast
937 # suppress_inactive: true
938 # next_hop_self:
939 # set: true
940 # - neighbor_address: 203.0.113.2
941 # address_family:
942 # - afi: ipv4
943 # safi: multicast
944 # send_community:
945 # set: true
946 # - afi: ipv6
947 # safi: unicast
948 #
949 # commands:
950 # - router bgp 65536
951 # - neighbor 192.0.2.32
952 # - no address-family ipv4 unicast
953 # - no address-family ipv6 unicast
954 # - neighbor 192.0.2.33
955 # - no address-family ipv4 multicast
956 # - vrf site-1
957 # - neighbor 203.0.113.1
958 # - no address-family ipv4 unicast
959 # - neighbor 203.0.113.2
960 # - no address-family ipv6 unicast
961 # - no address-family ipv4 multicast
962 #
963 # after:
964 # as_number: "65536"
965 #
966 # After state:
967 # ------------
968 # Nexus9000v# show running-config | section "^router bgp"
969 # router bgp 65536
970 # neighbor 192.0.2.32
971 # neighbor 192.0.2.33
972 # vrf site-1
973 # neighbor 203.0.113.1
974 # neighbor 203.0.113.2
975 #
976
977 # Using rendered
978
979 - name: Render platform specific configuration lines with state rendered (without connecting to the device)
980 cisco.nxos.nxos_bgp_neighbor_address_family:
981 config:
982 as_number: 65536
983 neighbors:
984 - neighbor_address: 192.0.2.32
985 address_family:
986 - afi: ipv4
987 safi: unicast
988 maximum_prefix:
989 max_prefix_limit: 20
990 generate_warning_threshold: 75
991 weight: 100
992 prefix_list:
993 inbound: rmap1
994 outbound: rmap2
995 - afi: ipv6
996 safi: unicast
997 - neighbor_address: 192.0.2.33
998 address_family:
999 - afi: ipv4
1000 safi: multicast
1001 inherit:
1002 template: BasePolicy
1003 sequence: 200
1004 vrfs:
1005 - vrf: site-1
1006 neighbors:
1007 - neighbor_address: 203.0.113.1
1008 address_family:
1009 - afi: ipv4
1010 safi: unicast
1011 suppress_inactive: true
1012 next_hop_self:
1013 set: true
1014 - neighbor_address: 203.0.113.2
1015 address_family:
1016 - afi: ipv6
1017 safi: unicast
1018 - afi: ipv4
1019 safi: multicast
1020 send_community:
1021 set: true
1022 state: rendered
1023
1024 # Task output:
1025 # ------------
1026 # rendered:
1027 # - router bgp 65536
1028 # - neighbor 192.0.2.32
1029 # - address-family ipv4 unicast
1030 # - maximum-prefix 20 75
1031 # - weight 100
1032 # - prefix-list rmap1 in
1033 # - prefix-list rmap2 out
1034 # - address-family ipv6 unicast
1035 # - neighbor 192.0.2.33
1036 # - address-family ipv4 multicast
1037 # - inherit peer-policy BasePolicy 200
1038 # - vrf site-1
1039 # - neighbor 203.0.113.1
1040 # - address-family ipv4 unicast
1041 # - suppress-inactive
1042 # - next-hop-self
1043 # - neighbor 203.0.113.2
1044 # - address-family ipv6 unicast
1045 # - address-family ipv4 multicast
1046 # - send-community
1047
1048 # Using parsed
1049
1050 # parsed.cfg
1051 # ------------
1052 # router bgp 65536
1053 # neighbor 192.0.2.32
1054 # address-family ipv4 unicast
1055 # maximum-prefix 20 75
1056 # weight 100
1057 # prefix-list rmap1 in
1058 # prefix-list rmap2 out
1059 # address-family ipv6 unicast
1060 # neighbor 192.0.2.33
1061 # address-family ipv4 multicast
1062 # inherit peer-policy BasePolicy 200
1063 # vrf site-1
1064 # neighbor 203.0.113.1
1065 # address-family ipv4 unicast
1066 # suppress-inactive
1067 # next-hop-self
1068 # neighbor 203.0.113.2
1069 # address-family ipv4 multicast
1070 # send-community
1071 # address-family ipv6 unicast
1072
1073 - name: Parse externally provided BGP neighbor AF config
1074 register: result
1075 cisco.nxos.nxos_bgp_neighbor_address_family:
1076 running_config: "{{ lookup('file', 'parsed.cfg') }}"
1077 state: parsed
1078
1079 # Task output:
1080 # ------------
1081 # parsed:
1082 # as_number: "65536"
1083 # neighbors:
1084 # - neighbor_address: 192.0.2.32
1085 # address_family:
1086 # - afi: ipv4
1087 # safi: unicast
1088 # maximum_prefix:
1089 # max_prefix_limit: 20
1090 # generate_warning_threshold: 75
1091 # weight: 100
1092 # prefix_list:
1093 # inbound: rmap1
1094 # outbound: rmap2
1095 # - afi: ipv6
1096 # safi: unicast
1097 # - neighbor_address: 192.0.2.33
1098 # address_family:
1099 # - afi: ipv4
1100 # safi: multicast
1101 # inherit:
1102 # template: BasePolicy
1103 # sequence: 200
1104 # vrfs:
1105 # - vrf: site-1
1106 # neighbors:
1107 # - neighbor_address: 203.0.113.1
1108 # address_family:
1109 # - afi: ipv4
1110 # safi: unicast
1111 # suppress_inactive: true
1112 # next_hop_self:
1113 # set: true
1114 # - neighbor_address: 203.0.113.2
1115 # address_family:
1116 # - afi: ipv4
1117 # safi: multicast
1118 # send_community:
1119 # set: true
1120 # - afi: ipv6
1121 # safi: unicast
1122 """
1123 RETURN = """
1124 before:
1125 description: The configuration prior to the module execution.
1126 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
1127 type: dict
1128 sample: >
1129 This output will always be in the same format as the
1130 module argspec.
1131 after:
1132 description: The resulting configuration after module execution.
1133 returned: when changed
1134 type: dict
1135 sample: >
1136 This output will always be in the same format as the
1137 module argspec.
1138 commands:
1139 description: The set of commands pushed to the remote device.
1140 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
1141 type: list
1142 sample:
1143 - router bgp 65536
1144 - neighbor 192.0.2.32
1145 - address-family ipv4 unicast
1146 rendered:
1147 description: The provided configuration in the task rendered in device-native format (offline).
1148 returned: when I(state) is C(rendered)
1149 type: list
1150 sample:
1151 - router bgp 65536
1152 - neighbor 192.0.2.32
1153 - address-family ipv4 unicast
1154 gathered:
1155 description: Facts about the network resource gathered from the remote device as structured data.
1156 returned: when I(state) is C(gathered)
1157 type: dict
1158 sample: >
1159 This output will always be in the same format as the
1160 module argspec.
1161 parsed:
1162 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
1163 returned: when I(state) is C(parsed)
1164 type: dict
1165 sample: >
1166 This output will always be in the same format as the
1167 module argspec.
1168 """
1169
1170 from ansible.module_utils.basic import AnsibleModule
1171
1172 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_neighbor_address_family.bgp_neighbor_address_family import (
1173 Bgp_neighbor_address_familyArgs,
1174 )
1175 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.bgp_neighbor_address_family.bgp_neighbor_address_family import (
1176 Bgp_neighbor_address_family,
1177 )
1178
1179
1180 def main():
1181 """
1182 Main entry point for module execution
1183
1184 :returns: the result form module invocation
1185 """
1186 module = AnsibleModule(
1187 argument_spec=Bgp_neighbor_address_familyArgs.argument_spec,
1188 mutually_exclusive=[["config", "running_config"]],
1189 required_if=[
1190 ["state", "merged", ["config"]],
1191 ["state", "replaced", ["config"]],
1192 ["state", "overridden", ["config"]],
1193 ["state", "rendered", ["config"]],
1194 ["state", "parsed", ["running_config"]],
1195 ],
1196 supports_check_mode=True,
1197 )
1198
1199 result = Bgp_neighbor_address_family(module).execute_module()
1200 module.exit_json(**result)
1201
1202
1203 if __name__ == "__main__":
1204 main()