Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2023 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_templates
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 module: nxos_bgp_templates
18 short_description: BGP Templates resource module.
19 description:
20 - This module manages BGP templates on devices running Cisco NX-OS.
21 version_added: 4.2.0
22 notes:
23 - Tested against NX-OS 9.3.6.
24 - Unsupported for Cisco MDS
25 - This module works with connection C(network_cli) and C(httpapi).
26 author: Nilashish Chakraborty (@NilashishC)
27 options:
28 running_config:
29 description:
30 - This option is used only with state I(parsed).
31 - The value of this option should be the output received from the NX-OS device
32 by executing the command B(show running-config bgp | section 'template').
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 templates.
39 type: dict
40 suboptions:
41 as_number:
42 description: Autonomous System Number of the router.
43 type: str
44 neighbor:
45 description: Configure BGP peer templates.
46 type: list
47 elements: dict
48 suboptions:
49 name:
50 description: Name of the BGP peer template.
51 type: str
52 address_family:
53 description: Configure an address-family for peer.
54 type: list
55 elements: dict
56 suboptions:
57 afi:
58 description: Address Family indicator.
59 type: str
60 choices: ["ipv4", "ipv6", "link-state", "l2vpn"]
61 required: True
62 safi:
63 description: Sub Address Family indicator.
64 type: str
65 choices: ["unicast", "multicast", "mvpn", "evpn"]
66 advertise_map:
67 description: Specify route-map for conditional advertisement.
68 type: dict
69 suboptions:
70 route_map:
71 description: Route-map name.
72 type: str
73 required: True
74 exist_map:
75 description: Condition route-map to advertise only when prefix in condition exists.
76 type: str
77 non_exist_map:
78 description: Condition route-map to advertise only when prefix in condition does not exist.
79 type: str
80 advertisement_interval:
81 description: Minimum interval between sending BGP routing updates.
82 type: int
83 allowas_in:
84 description: Accept as-path with my AS present in it.
85 type: dict
86 suboptions:
87 set:
88 description: Activate allowas-in property.
89 type: bool
90 max_occurences:
91 description: Number of occurrences of AS number, default is 3.
92 type: int
93 as_override:
94 description: Override matching AS-number while sending update.
95 type: bool
96 capability:
97 description: Advertise capability to the peer.
98 type: dict
99 suboptions:
100 additional_paths:
101 description: Additional paths capability.
102 type: dict
103 suboptions:
104 receive:
105 description: Additional paths Receive capability.
106 type: str
107 choices: ["enable", "disable"]
108 send:
109 description: Additional paths Send capability.
110 type: str
111 choices: ["enable", "disable"]
112 default_originate:
113 description: Originate a default toward this peer.
114 type: dict
115 suboptions:
116 set:
117 description: Set default-originate attribute.
118 type: bool
119 route_map:
120 description: Route-map to specify criteria for originating default.
121 type: str
122 disable_peer_as_check:
123 description: Disable checking of peer AS-number while advertising.
124 type: bool
125 filter_list:
126 description: Name of filter-list.
127 type: dict
128 suboptions:
129 inbound:
130 description: Apply policy to incoming routes.
131 type: str
132 outbound:
133 description: Apply policy to outgoing routes.
134 type: str
135 inherit:
136 description: Inherit a peer-policy template.
137 type: dict
138 suboptions:
139 peer_policy:
140 description: Peer-policy template to inherit.
141 type: str
142 maximum_prefix:
143 description: Maximum number of prefixes from this neighbor.
144 type: dict
145 suboptions:
146 max_prefix_limit:
147 description: Maximum prefix limit.
148 type: int
149 generate_warning_threshold:
150 description: Threshold percentage at which to generate a warning.
151 type: int
152 restart_interval:
153 description: Restart bgp connection after limit is exceeded.
154 type: int
155 warning_only:
156 description: Only give a warning message when limit is exceeded.
157 type: bool
158 next_hop_self:
159 description: Set our address as nexthop (non-reflected).
160 type: dict
161 suboptions:
162 set:
163 description: Set next-hop-self attribute.
164 type: bool
165 all_routes:
166 description: Set our address as nexthop for all routes.
167 type: bool
168 next_hop_third_party:
169 description: Compute a third-party nexthop if possible.
170 type: bool
171 prefix_list:
172 description: Apply prefix-list.
173 type: dict
174 suboptions:
175 inbound:
176 description: Apply policy to incoming routes.
177 type: str
178 outbound:
179 description: Apply policy to outgoing routes.
180 type: str
181 route_map:
182 description: Apply route-map to neighbor.
183 type: dict
184 suboptions:
185 inbound:
186 description: Name of policy to apply to incoming routes.
187 type: str
188 outbound:
189 description: Name of policy to apply to outgoing routes.
190 type: str
191 route_reflector_client:
192 description: Configure a neighbor as Route reflector client.
193 type: bool
194 send_community:
195 description: Send Community attribute to this neighbor.
196 type: str
197 choices: ["standard", "extended", "both"]
198 soft_reconfiguration_inbound:
199 description: Soft reconfiguration.
200 type: dict
201 suboptions:
202 set:
203 description: Set soft-reconfiguration inbound attribute.
204 type: bool
205 always:
206 description: Always perform inbound soft reconfiguration.
207 type: bool
208 soo:
209 description: Specify Site-of-origin extcommunity.
210 type: str
211 suppress_inactive:
212 description: Advertise only active routes to peer.
213 type: bool
214 unsuppress_map:
215 description: Route-map to selectively unsuppress suppressed routes.
216 type: str
217 weight:
218 description: Set default weight for routes from this neighbor.
219 type: int
220 bfd:
221 description: Bidirectional Fast Detection for the neighbor.
222 type: dict
223 suboptions:
224 set:
225 description: Set BFD for this neighbor.
226 type: bool
227 singlehop:
228 description: Single-hop session.
229 type: bool
230 multihop:
231 description: Multihop session.
232 type: dict
233 suboptions:
234 set:
235 description: Set BFD multihop.
236 type: bool
237 interval:
238 description: Configure BFD session interval parameters.
239 type: dict
240 suboptions:
241 tx_interval:
242 description: TX interval in milliseconds.
243 type: int
244 required: true
245 min_rx_interval:
246 description: Minimum RX interval.
247 type: int
248 required: true
249 multiplier:
250 description: Detect Multiplier.
251 type: int
252 required: true
253 bmp_activate_server:
254 description: Specify server ID for activating BMP monitoring for the peer.
255 type: int
256 capability:
257 description: Capability.
258 type: dict
259 suboptions:
260 suppress_4_byte_as:
261 description: Suppress 4-byte AS Capability.
262 type: bool
263 description:
264 description: Neighbor specific descripion.
265 type: str
266 disable_connected_check:
267 description: Disable check for directly connected peer.
268 type: bool
269 dont_capability_negotiate:
270 description: Don't negotiate capability with this neighbor.
271 type: bool
272 dscp:
273 description: Set dscp value for tcp transport.
274 type: str
275 dynamic_capability:
276 description: Dynamic Capability
277 type: bool
278 ebgp_multihop:
279 description: Specify multihop TTL for remote peer.
280 type: int
281 graceful_shutdown:
282 description: Graceful-shutdown for this neighbor.
283 type: dict
284 suboptions:
285 activate:
286 description: Send graceful-shutdown community.
287 type: dict
288 suboptions:
289 set:
290 description: Set activate.
291 type: bool
292 route_map:
293 description: Apply route-map to modify attributes for outbound.
294 type: str
295 inherit:
296 description: Inherit a template.
297 type: dict
298 suboptions:
299 peer_session:
300 description: Peer-session template to inherit.
301 type: str
302 local_as:
303 description: Specify the local-as number for the eBGP neighbor.
304 type: str
305 log_neighbor_changes:
306 description: Log message for neighbor up/down event.
307 type: dict
308 suboptions:
309 set:
310 description:
311 - Set log-neighbor-changes.
312 type: bool
313 disable:
314 description:
315 - Disable logging of neighbor up/down event.
316 type: bool
317 low_memory:
318 description: Behaviour in low memory situations.
319 type: dict
320 suboptions:
321 exempt:
322 description: Do not shutdown this peer when under memory pressure.
323 type: bool
324 password:
325 description: Configure a password for neighbor.
326 type: dict
327 suboptions:
328 encryption:
329 description:
330 - 0 specifies an UNENCRYPTED neighbor password.
331 - 3 specifies an 3DES ENCRYPTED neighbor password will follow.
332 - 7 specifies a Cisco type 7 ENCRYPTED neighbor password will follow.
333 type: int
334 key:
335 description: Authentication password.
336 type: str
337 path_attribute:
338 description: BGP path attribute optional filtering.
339 type: list
340 elements: dict
341 suboptions:
342 action:
343 description: Action.
344 type: str
345 choices: ["discard", "treat-as-withdraw"]
346 type:
347 description: Path attribute type
348 type: int
349 range:
350 description: Path attribute range.
351 type: dict
352 suboptions:
353 start:
354 description: Path attribute range start value.
355 type: int
356 end:
357 description: Path attribute range end value.
358 type: int
359 remote_as:
360 description: Specify Autonomous System Number of the neighbor.
361 type: str
362 remove_private_as:
363 description: Remove private AS number from outbound updates.
364 type: dict
365 suboptions:
366 set:
367 description: Remove private AS.
368 type: bool
369 replace_as:
370 description: Replace.
371 type: bool
372 all:
373 description: All.
374 type: bool
375 shutdown:
376 description: Administratively shutdown this neighbor.
377 type: bool
378 timers:
379 description: Configure keepalive and hold timers.
380 type: dict
381 suboptions:
382 keepalive:
383 description: Keepalive interval (seconds).
384 type: int
385 holdtime:
386 description: Holdtime (seconds).
387 type: int
388 transport:
389 description: BGP transport connection.
390 type: dict
391 suboptions:
392 connection_mode:
393 description: Specify type of connection.
394 type: dict
395 suboptions:
396 passive:
397 description: Allow passive connection setup only.
398 type: bool
399 ttl_security:
400 description: Enable TTL Security Mechanism.
401 type: dict
402 suboptions:
403 hops:
404 description: Specify hop count for remote peer.
405 type: int
406 update_source:
407 description: Specify source of BGP session and updates.
408 type: str
409 state:
410 description:
411 - The state the configuration should be left in.
412 - Refer to examples for more details.
413 type: str
414 choices:
415 - merged
416 - replaced
417 - overridden
418 - deleted
419 - parsed
420 - gathered
421 - rendered
422 default: merged
423 """
424
425 EXAMPLES = """
426 # Using merged
427
428 # Before state:
429 # --------------
430 #
431 # nxos9k# show running-config | section "^router bgp"
432 # nxos9k#
433
434 - name: Merge the provided configuration with the existing running configuration
435 cisco.nxos.nxos_bgp_templates:
436 config:
437 as_number: 65536
438 neighbor:
439 - name: neighbor_tmplt_1
440 address_family:
441 - afi: ipv4
442 safi: unicast
443 advertise_map:
444 route_map: rmap1
445 non_exist_map: nemap1
446 advertisement_interval: 60
447 disable_peer_as_check: true
448 bmp_activate_server: 2
449 capability:
450 suppress_4_byte_as: true
451 description: Test_BGP_PEER_TEMPLATE_1
452 local_as: 65536
453 remote_as: 65001
454
455 - name: neighbor_tmplt_2
456 description: Test_BGP_PEER_TEMPLATE_2
457 address_family:
458 - afi: ipv4
459 safi: multicast
460 advertise_map:
461 route_map: rmap1
462 exist_map: emap1
463 as_override: true
464 filter_list:
465 inbound: flist1
466 outbound: flist2
467 inherit:
468 peer_session: psession1
469 timers:
470 holdtime: 100
471 keepalive: 45
472 # Task Output:
473 # ------------
474 # before: {}
475 #
476 # commands:
477 # - router bgp 65536
478 # - template peer neighbor_tmplt_1
479 # - bmp-activate-server 2
480 # - capability suppress 4-byte-as
481 # - description Test_BGP_PEER_TEMPLATE_1
482 # - local-as 65536
483 # - remote-as 65001
484 # - address-family ipv4 unicast
485 # - advertise-map rmap1 non-exist-map nemap1
486 # - advertisement-interval 60
487 # - disable-peer-as-check
488 # - template peer neighbor_tmplt_2
489 # - description Test_BGP_PEER_TEMPLATE_2
490 # - inherit peer-session psession1
491 # - timers 45 100
492 # - address-family ipv4 multicast
493 # - advertise-map rmap1 exist-map emap1
494 # - as-override
495 # - filter-list flist1 in
496 # - filter-list flist2 out
497 #
498 # after:
499 # as_number: "65536"
500 # neighbor:
501 # - name: neighbor_tmplt_1
502 # address_family:
503 # - afi: ipv4
504 # safi: unicast
505 # advertise_map:
506 # non_exist_map: nemap1
507 # route_map: rmap1
508 # advertisement_interval: 60
509 # disable_peer_as_check: true
510 # bmp_activate_server: 2
511 # capability:
512 # suppress_4_byte_as: true
513 # description: Test_BGP_PEER_TEMPLATE_1
514 # local_as: "65536"
515 # remote_as: "65001"
516 #
517 # - name: neighbor_tmplt_2
518 # description: Test_BGP_PEER_TEMPLATE_2
519 # address_family:
520 # - afi: ipv4
521 # safi: multicast
522 # advertise_map:
523 # exist_map: emap1
524 # route_map: rmap1
525 # as_override: true
526 # filter_list:
527 # inbound: flist1
528 # outbound: flist2
529 # inherit:
530 # peer_session: psession1
531 # timers:
532 # holdtime: 100
533 # keepalive: 45
534
535 # After state:
536 # --------------
537 #
538 # nxos9k# show running-config | section "^router bgp"
539 # router bgp 65536
540 # template peer neighbor_tmplt_1
541 # capability suppress 4-byte-as
542 # bmp-activate-server 2
543 # description Test_BGP_PEER_TEMPLATE_1
544 # local-as 65536
545 # remote-as 65001
546 # address-family ipv4 unicast
547 # advertise-map rmap1 non-exist-map nemap1
548 # advertisement-interval 60
549 # disable-peer-as-check
550 # template peer neighbor_tmplt_2
551 # description Test_BGP_PEER_TEMPLATE_2
552 # inherit peer-session psession1
553 # timers 45 100
554 # address-family ipv4 multicast
555 # advertise-map rmap1 exist-map emap1
556 # as-override
557 # filter-list flist1 in
558 # filter-list flist2 out
559
560 # Using replaced
561
562 # Before state:
563 # -------------
564 #
565 # nxos9k# show running-config | section "^router bgp"
566 # router bgp 65536
567 # template peer neighbor_tmplt_1
568 # capability suppress 4-byte-as
569 # description Test_BGP_PEER_TEMPLATE_1
570 # bmp-activate-server 2
571 # local-as 65536
572 # remote-as 65001
573 # address-family ipv4 unicast
574 # advertise-map rmap1 non-exist-map nemap1
575 # advertisement-interval 60
576 # disable-peer-as-check
577 # template peer neighbor_tmplt_2
578 # description Test_BGP_PEER_TEMPLATE_2
579 # inherit peer-session psession1
580 # timers 45 100
581 # address-family ipv4 multicast
582 # advertise-map rmap1 exist-map emap1
583 # as-override
584 # filter-list flist1 in
585 # filter-list flist2 out
586
587 - name: Replace BGP templates configuration with provided configuration
588 cisco.nxos.nxos_bgp_templates:
589 config:
590 as_number: 65536
591 neighbor:
592 - name: neighbor_tmplt_1
593 address_family:
594 - afi: ipv4
595 safi: unicast
596 advertise_map:
597 route_map: rmap1
598 non_exist_map: nemap1
599 advertisement_interval: 60
600 disable_peer_as_check: true
601 inherit:
602 peer_session: psession1
603 description: Test_BGP_PEER_TEMPLATE_1
604 local_as: 65537
605 state: replaced
606
607 # Task output:
608 # ------------
609 #
610 # before:
611 # as_number: "65536"
612 # neighbor:
613 # - name: neighbor_tmplt_1
614 # address_family:
615 # - afi: ipv4
616 # safi: unicast
617 # advertise_map:
618 # non_exist_map: nemap1
619 # route_map: rmap1
620 # advertisement_interval: 60
621 # disable_peer_as_check: true
622 # bmp_activate_server: 2
623 # capability:
624 # suppress_4_byte_as: true
625 # description: Test_BGP_PEER_TEMPLATE_1
626 # local_as: "65536"
627 # remote_as: "65001"
628 #
629 # - name: neighbor_tmplt_2
630 # description: Test_BGP_PEER_TEMPLATE_2
631 # address_family:
632 # - afi: ipv4
633 # safi: multicast
634 # advertise_map:
635 # exist_map: emap1
636 # route_map: rmap1
637 # as_override: true
638 # filter_list:
639 # inbound: flist1
640 # outbound: flist2
641 # inherit:
642 # peer_session: psession1
643 # timers:
644 # holdtime: 100
645 # keepalive: 45
646 #
647 # commands:
648 # - router bgp 65536
649 # - template peer neighbor_tmplt_1
650 # - no bmp-activate-server 2
651 # - no capability suppress 4-byte-as
652 # - inherit peer-session psession1
653 # - local-as 65537
654 # - no remote-as 65001
655 #
656 # after:
657 # as_number: "65536"
658 # neighbor:
659 # - name: neighbor_tmplt_1
660 # address_family:
661 # - afi: ipv4
662 # safi: unicast
663 # advertise_map:
664 # non_exist_map: nemap1
665 # route_map: rmap1
666 # advertisement_interval: 60
667 # disable_peer_as_check: true
668 # description: Test_BGP_PEER_TEMPLATE_1
669 # inherit:
670 # peer_session: psession1
671 # local_as: "65537"
672 #
673 # - name: neighbor_tmplt_2
674 # description: Test_BGP_PEER_TEMPLATE_2
675 # address_family:
676 # - afi: ipv4
677 # safi: multicast
678 # advertise_map:
679 # exist_map: emap1
680 # route_map: rmap1
681 # as_override: true
682 # filter_list:
683 # inbound: flist1
684 # outbound: flist2
685 # inherit:
686 # peer_session: psession1
687 # timers:
688 # holdtime: 100
689 # keepalive: 45
690
691 # After state:
692 # ------------
693 #
694 # nxos9k# show running-config | section "^router bgp"
695 # router bgp 65536
696 # template peer neighbor_tmplt_1
697 # inherit peer-session psession1
698 # description Test_BGP_PEER_TEMPLATE_1
699 # local-as 65537
700 # address-family ipv4 unicast
701 # advertise-map rmap1 non-exist-map nemap1
702 # advertisement-interval 60
703 # disable-peer-as-check
704 # template peer neighbor_tmplt_2
705 # description Test_BGP_PEER_TEMPLATE_2
706 # inherit peer-session psession1
707 # bmp-activate-server 2
708 # timers 45 100
709 # address-family ipv4 multicast
710 # advertise-map rmap1 exist-map emap1
711 # as-override
712 # filter-list flist1 in
713 # filter-list flist2 out
714
715 # Using overridden
716 #
717 # Before state:
718 # -------------
719 #
720 # nxos9k# show running-config | section "^router bgp"
721 # router bgp 65536
722 # template peer neighbor_tmplt_1
723 # capability suppress 4-byte-as
724 # description Test_BGP_PEER_TEMPLATE_1
725 # bmp-activate-server 2
726 # local-as 65536
727 # remote-as 65001
728 # address-family ipv4 unicast
729 # advertise-map rmap1 non-exist-map nemap1
730 # advertisement-interval 60
731 # disable-peer-as-check
732 # template peer neighbor_tmplt_2
733 # description Test_BGP_PEER_TEMPLATE_2
734 # inherit peer-session psession1
735 # timers 45 100
736 # address-family ipv4 multicast
737 # advertise-map rmap1 exist-map emap1
738 # as-override
739 # filter-list flist1 in
740 # filter-list flist2 out
741
742 - name: Override BGP templates configuration with provided configuration
743 cisco.nxos.nxos_bgp_templates:
744 config:
745 as_number: 65536
746 neighbor:
747 - name: neighbor_tmplt_1
748 address_family:
749 - afi: ipv4
750 safi: unicast
751 advertise_map:
752 route_map: rmap1
753 non_exist_map: nemap1
754 advertisement_interval: 60
755 disable_peer_as_check: true
756 inherit:
757 peer_session: psession1
758 description: Test_BGP_PEER_TEMPLATE_1
759 local_as: 65537
760 state: overridden
761
762 # Task output:
763 # ------------
764 #
765 # before:
766 # as_number: "65536"
767 # neighbor:
768 # - name: neighbor_tmplt_1
769 # address_family:
770 # - afi: ipv4
771 # safi: unicast
772 # advertise_map:
773 # non_exist_map: nemap1
774 # route_map: rmap1
775 # advertisement_interval: 60
776 # disable_peer_as_check: true
777 # bmp_activate_server: 2
778 # capability:
779 # suppress_4_byte_as: true
780 # description: Test_BGP_PEER_TEMPLATE_1
781 # local_as: "65536"
782 # remote_as: "65001"
783 #
784 # - name: neighbor_tmplt_2
785 # description: Test_BGP_PEER_TEMPLATE_2
786 # address_family:
787 # - afi: ipv4
788 # safi: multicast
789 # advertise_map:
790 # exist_map: emap1
791 # route_map: rmap1
792 # as_override: true
793 # filter_list:
794 # inbound: flist1
795 # outbound: flist2
796 # inherit:
797 # peer_session: psession1
798 # timers:
799 # holdtime: 100
800 # keepalive: 45
801 #
802 # commands:
803 # - router bgp 65536
804 # - template peer neighbor_tmplt_1
805 # - no bmp-activate-server 2
806 # - no capability suppress 4-byte-as
807 # - inherit peer-session psession1
808 # - local-as 65537
809 # - no remote-as 65001
810 # - no template peer neighbor_tmplt_2
811 #
812 # after:
813 # as_number: "65536"
814 # neighbor:
815 # - name: neighbor_tmplt_1
816 # address_family:
817 # - afi: ipv4
818 # safi: unicast
819 # advertise_map:
820 # non_exist_map: nemap1
821 # route_map: rmap1
822 # advertisement_interval: 60
823 # disable_peer_as_check: true
824 # description: Test_BGP_PEER_TEMPLATE_1
825 # inherit:
826 # peer_session: psession1
827 # local_as: "65537"
828
829 # After state:
830 # ------------
831 #
832 # nxos9k# show running-config | section "^router bgp"
833 # router bgp 65536
834 # template peer neighbor_tmplt_1
835 # inherit peer-session psession1
836 # description Test_BGP_PEER_TEMPLATE_1
837 # local-as 65537
838 # address-family ipv4 unicast
839 # advertise-map rmap1 non-exist-map nemap1
840 # advertisement-interval 60
841 # disable-peer-as-check
842
843 # Using deleted
844
845 # Before state:
846 # --------------
847 #
848 # nxos9k# show running-config | section "^router bgp"
849 # router bgp 65536
850 # template peer neighbor_tmplt_1
851 # capability suppress 4-byte-as
852 # description Test_BGP_PEER_TEMPLATE_1
853 # bmp-activate-server 2
854 # local-as 65536
855 # remote-as 65001
856 # address-family ipv4 unicast
857 # advertise-map rmap1 non-exist-map nemap1
858 # advertisement-interval 60
859 # disable-peer-as-check
860 # template peer neighbor_tmplt_2
861 # description Test_BGP_PEER_TEMPLATE_2
862 # inherit peer-session psession1
863 # timers 45 100
864 # address-family ipv4 multicast
865 # advertise-map rmap1 exist-map emap1
866 # as-override
867 # filter-list flist1 in
868 # filter-list flist2 out
869
870 - name: Delete BGP configs handled by this module
871 cisco.nxos.nxos_bgp_templates:
872 state: deleted
873
874 # Task output:
875 # ------------
876 #
877 # before:
878 # as_number: "65536"
879 # neighbor:
880 # - name: neighbor_tmplt_1
881 # address_family:
882 # - afi: ipv4
883 # safi: unicast
884 # advertise_map:
885 # non_exist_map: nemap1
886 # route_map: rmap1
887 # advertisement_interval: 60
888 # disable_peer_as_check: true
889 # bmp_activate_server: 2
890 # capability:
891 # suppress_4_byte_as: true
892 # description: Test_BGP_PEER_TEMPLATE_1
893 # local_as: "65536"
894 # remote_as: "65001"
895 #
896 # - name: neighbor_tmplt_2
897 # description: Test_BGP_PEER_TEMPLATE_2
898 # address_family:
899 # - afi: ipv4
900 # safi: multicast
901 # advertise_map:
902 # exist_map: emap1
903 # route_map: rmap1
904 # as_override: true
905 # filter_list:
906 # inbound: flist1
907 # outbound: flist2
908 # inherit:
909 # peer_session: psession1
910 # timers:
911 # holdtime: 100
912 # keepalive: 45
913 #
914 # commands:
915 # - router bgp 65536
916 # - no template peer neighbor_tmplt_1
917 # - no template peer neighbor_tmplt_2
918 #
919 # after: {}
920
921 # After state:
922 # -------------
923 # nxos9k# show running-config | section "^router bgp"
924 # nxos9k#
925 """
926
927 RETURN = """
928 before:
929 description: The configuration prior to the module execution.
930 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
931 type: dict
932 sample: >
933 This output will always be in the same format as the
934 module argspec.
935 after:
936 description: The resulting configuration after module execution.
937 returned: when changed
938 type: dict
939 sample: >
940 This output will always be in the same format as the
941 module argspec.
942 commands:
943 description: The set of commands pushed to the remote device.
944 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
945 type: list
946 sample:
947 - router bgp 65536
948 - template peer neighbor_tmplt_1
949 - no bmp-activate-server 2
950 - no capability suppress 4-byte-as
951 - inherit peer-session psession1
952 - local-as 65537
953 - no remote-as 65001
954 - no template peer neighbor_tmplt_2
955 rendered:
956 description: The provided configuration in the task rendered in device-native format (offline).
957 returned: when I(state) is C(rendered)
958 type: list
959 sample:
960 - router bgp 65536
961 - template peer neighbor_tmplt_1
962 - bmp-activate-server 2
963 - no capability suppress 4-byte-as
964 - no template peer neighbor_tmplt_2
965 gathered:
966 description: Facts about the network resource gathered from the remote device as structured data.
967 returned: when I(state) is C(gathered)
968 type: dict
969 sample: >
970 This output will always be in the same format as the
971 module argspec.
972 parsed:
973 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
974 returned: when I(state) is C(parsed)
975 type: dict
976 sample: >
977 This output will always be in the same format as the
978 module argspec.
979 """
980
981 from ansible.module_utils.basic import AnsibleModule
982
983 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.bgp_templates.bgp_templates import (
984 Bgp_templatesArgs,
985 )
986 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.bgp_templates.bgp_templates import (
987 Bgp_templates,
988 )
989
990
991 def main():
992 """
993 Main entry point for module execution
994
995 :returns: the result form module invocation
996 """
997 module = AnsibleModule(
998 argument_spec=Bgp_templatesArgs.argument_spec,
999 mutually_exclusive=[["config", "running_config"]],
1000 required_if=[
1001 ["state", "merged", ["config"]],
1002 ["state", "replaced", ["config"]],
1003 ["state", "overridden", ["config"]],
1004 ["state", "rendered", ["config"]],
1005 ["state", "parsed", ["running_config"]],
1006 ],
1007 supports_check_mode=True,
1008 )
1009
1010 result = Bgp_templates(module).execute_module()
1011 module.exit_json(**result)
1012
1013
1014 if __name__ == "__main__":
1015 main()