Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2024 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_vrf_global
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 module: nxos_vrf_global
18 short_description: Resource module to configure VRF definitions.
19 description: This module provides declarative management of VRF definitions on Cisco NXOS.
20 version_added: 8.1.0
21 author: Vinay Mulugund (@roverflow)
22 notes:
23 - Tested against NX-OS 9.3.6.
24 - This module works with connection C(network_cli) and C(httpapi).
25 See U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_nxos.html)
26 options:
27 config:
28 description: A list containing device configurations for VRF.
29 type: dict
30 suboptions:
31 vrfs:
32 description: List of VRF definitions.
33 type: list
34 elements: dict
35 suboptions:
36 name:
37 description: Name of the VRF..
38 required: true
39 type: str
40 description:
41 description: Description of the VRF.
42 type: str
43 rd:
44 description: VPN Route Distinguisher
45 type: str
46 ip:
47 description: Configure IP features for the specified vrf.
48 type: dict
49 suboptions:
50 auto_discard:
51 description: Auto 0.0.0.0/0 discard route.
52 type: bool
53 domain_list:
54 description: Add list domain names.
55 type: list
56 elements: str
57 domain_name:
58 description: Specify default domain name.
59 type: str
60 icmp_err:
61 description: Enable ICMP error message.
62 type: dict
63 suboptions:
64 source_interface:
65 description: Configure source-address for applications.
66 type: dict
67 suboptions:
68 interface:
69 description: Source interface for ICMP error messages.
70 type: str
71 choices:
72 - loopback
73 - ethernet
74 - port-channel
75 interface_value:
76 description: Source interface value for ICMP error messages.
77 type: str
78 igmp:
79 description: IGMP global configuration commands
80 type: dict
81 suboptions:
82 ssm_translate:
83 description: Translate IGMPv1/v2 reports to (S,G) route entries.
84 type: list
85 elements: dict
86 suboptions:
87 group:
88 description: Source address.
89 type: str
90 source:
91 description: Group address.
92 type: str
93 mroutes:
94 description: Configure multicast routes.
95 type: list
96 elements: dict
97 suboptions:
98 group:
99 description: Multicast group address.
100 type: str
101 source:
102 description: Source address.
103 type: str
104 preference:
105 description: Preference value.
106 type: int
107 vrf:
108 description: VRF name.
109 type: str
110 multicast:
111 description: Configure IP multicast global parameters.
112 type: dict
113 suboptions:
114 group_range_prefix_list:
115 description: Group range prefix-list policy for multicast boundary.
116 type: str
117 multipath:
118 description: Configure ECMP multicast load splitting.
119 type: dict
120 suboptions:
121 resilient:
122 description: Configure resilient RPF interface.
123 type: bool
124 splitting_type:
125 description: Configure multicast load splitting type.
126 type: dict
127 suboptions:
128 none:
129 description: Disable multicast load splitting.
130 type: bool
131 legacy:
132 description: Configure hash based on source and group.
133 type: bool
134 nbm:
135 description: Configure NBM controlled RPF interface.
136 type: bool
137 sg_hash:
138 description: Configure hash based on source and group address.
139 type: bool
140 sg_hash_next_hop:
141 description: Configure hash based on source and group address and next-hop.
142 type: bool
143 rpf:
144 description: Configure RPF check.
145 type: list
146 elements: dict
147 suboptions:
148 vrf_name:
149 description: VRF for RPF lookup.
150 type: str
151 group_list_range:
152 description: Group range for RPF select.
153 type: str
154 name_server:
155 description: Specify nameserver address.
156 type: dict
157 suboptions:
158 address_list:
159 description: Configure multicast name server address.
160 type: list
161 elements: str
162 use_vrf:
163 description: Display per-VRF information.
164 type: dict
165 suboptions:
166 vrf:
167 description: VRF name.
168 type: str
169 source_address:
170 description: source address for configuring name server.
171 type: str
172 route:
173 description: Configure static routes.
174 type: list
175 elements: dict
176 suboptions:
177 source:
178 description: Destination prefix.
179 type: str
180 destination:
181 description: Next-hop address.
182 type: str
183 tags:
184 description: Route tag.
185 type: dict
186 suboptions:
187 tag_value:
188 description: Route tag value.
189 type: int
190 route_pref:
191 description: Route preference.
192 type: int
193 vrf:
194 description: add vrf to the route.
195 type: str
196 track:
197 description: Configure track object.
198 type: str
199 vni:
200 description: Virtual Network Identifier.
201 type: dict
202 suboptions:
203 vni_number:
204 description: VNI number.
205 type: int
206 layer_3:
207 description: Configure Layer 3 VNI.
208 type: bool
209 multicast:
210 description: Configure IP multicast options.
211 type: dict
212 suboptions:
213 service_reflect:
214 description: Configure service reflect option.
215 type: list
216 elements: dict
217 suboptions:
218 service_interface:
219 description: configure service interface.
220 type: str
221 map_to:
222 description: Map to interface.
223 type: str
224 ipv6:
225 description: Configure IPv6 features for the specified vrf.
226 type: dict
227 suboptions:
228 mld_ssm_translate:
229 description: Translate MLDv1/v2 reports to (S,G) route entries.
230 type: list
231 elements: dict
232 suboptions:
233 icmp:
234 description: Configure ICMP parameters with mld.
235 type: bool
236 group:
237 description: Source address.
238 type: str
239 source:
240 description: Group address.
241 type: str
242 multicast:
243 description: Configure IP multicast global parameters for ipv6.
244 type: dict
245 suboptions:
246 group_range_prefix_list:
247 description: Group range prefix-list policy for multicast boundary.
248 type: str
249 multipath:
250 description: Configure ECMP multicast load splitting.
251 type: dict
252 suboptions:
253 resilient:
254 description: Configure resilient RPF interface.
255 type: bool
256 splitting_type:
257 description: Configure multicast load splitting type.
258 type: dict
259 suboptions:
260 none:
261 description: Disable multicast load splitting.
262 type: bool
263 sg_hash:
264 description: Configure hash based on source and group address.
265 type: bool
266 sg_hash_next_hop:
267 description: Configure hash based on source and group address and next-hop.
268 type: bool
269 running_config:
270 description:
271 - This option is used only with state I(parsed).
272 - The value of this option should be the output received from the NX-OS device
273 by executing the command B(show running-config | section ^vrf).
274 - The state I(parsed) reads the configuration from C(running_config) option and
275 transforms it into Ansible structured data as per the resource module's argspec
276 and the value is then returned in the I(parsed) key within the result.
277 type: str
278 state:
279 choices:
280 [
281 parsed,
282 gathered,
283 deleted,
284 merged,
285 replaced,
286 rendered,
287 overridden,
288 purged,
289 ]
290 default: merged
291 description:
292 - The state the configuration should be left in
293 - The states I(rendered), I(gathered) and I(parsed) does not perform any change
294 on the device.
295 - The state I(rendered) will transform the configuration in C(config) option to
296 platform specific CLI commands which will be returned in the I(rendered) key
297 within the result. For state I(rendered) active connection to remote host is
298 not required.
299 - The state I(gathered) will fetch the running configuration from device and transform
300 it into structured data in the format as per the resource module argspec and
301 the value is returned in the I(gathered) key within the result.
302 - The state I(parsed) reads the configuration from C(running_config) option and
303 transforms it into JSON format as per the resource module parameters and the
304 value is returned in the I(parsed) key within the result. The value of C(running_config)
305 option should be the same format as the output of command I(show running-config | section ^vrf).
306 connection to remote host is not required.
307 type: str
308 """
309
310 EXAMPLES = """
311 # Using merged
312
313 # Before state:
314 # -------------
315 #
316 # nxos#show running-config | section ^vrf
317
318 - name: Merge provided VRF configuration
319 cisco.nxos.vrf_global:
320 config:
321 vrfs:
322 - name: testvrf
323 description: this is description
324 ip:
325 auto_discard: true
326 domain_list:
327 - example.net
328 - example.com
329 domain_name: test.com
330 icmp_err:
331 source_interface:
332 interface: port-channel
333 interface_value: '1'
334 igmp:
335 ssm_translate:
336 - group: 232.0.0.0/8
337 source: 10.1.1.1
338 - group: 239.1.2.3/24
339 source: 192.168.1.1
340 mroutes:
341 - group: 192.168.1.0/24
342 source: 192.168.1.1
343 - group: 192.168.1.0/24
344 preference: 2
345 source: 192.168.1.2
346 vrf: temp1
347 multicast:
348 multipath:
349 resilient: true
350 splitting_type:
351 legacy: true
352 rpf:
353 - group_list_range: 238.1.0.0/24
354 vrf_name: temp1
355 - group_list_range: 239.1.0.0/24
356 vrf_name: temp1
357 name_server:
358 address_list:
359 - 192.168.0.1
360 - 192.168.0.2
361 - 192.168.1.1
362 - 192.169.1.3
363 use_vrf:
364 source_address: 192.168.0.1
365 vrf: temp1
366 route:
367 - destination: 192.0.2.22
368 source: 192.0.0.0/24
369 - destination: 192.0.2.22
370 source: 192.0.0.0/24
371 vrf: temp1
372 - destination: 192.0.2.22
373 source: 192.0.2.0/24
374 tags:
375 route_pref: 4
376 tag_value: 2
377 ipv6:
378 mld_ssm_translate:
379 - group: 'ff28::/16'
380 source: '2001:db8:0:abcd::2'
381 - group: 'ff30::/16'
382 source: '2001:db8:0:abcd::5'
383 multicast:
384 group_range_prefix_list: temp2
385 multipath:
386 resilient: true
387 splitting_type:
388 none: true
389 multicast:
390 service_reflect:
391 - map_to: Ethernet2/2
392 service_interface: Ethernet1/1
393 - map_to: Ethernet4/2
394 service_interface: Ethernet2/1
395 vni:
396 vni_number: 5
397 state: merged
398
399 # Task Output:
400 # ------------
401
402 # before: {}
403 # commands:
404 # - vrf context test1
405 # - description this is description
406 # - ip auto-discard
407 # - ip domain-name test.net
408 # - ip name-server 192.168.0.1 192.168.0.2 192.168.1.1 192.169.1.3
409 # - ip icmp-errors source-interface port-channel 1
410 # - ip multicast multipath resilient
411 # - ip multicast multipath legacy
412 # - ip name-server 192.168.0.1 use-vrf temp1
413 # - vni 5
414 # - ipv6 multicast group-range prefix-list temp2
415 # - ipv6 multicast multipath resilient
416 # - ipv6 multicast multipath none
417 # - ip domain-list test.org
418 # - ip domain-list example.com
419 # - ip domain-list example.net
420 # - ip igmp ssm-translate 232.0.0.0/8 10.1.1.1
421 # - ip igmp ssm-translate 239.1.2.3/24 192.168.1.1
422 # - ip mroute 192.168.1.0/24 192.168.1.1
423 # - ip mroute 192.168.1.0/24 192.168.1.2 2 vrf temp1
424 # - ip multicast rpf select vrf temp1 group-list 238.1.0.0/24
425 # - ip multicast rpf select vrf temp1 group-list 239.1.0.0/24
426 # - ip route 192.0.0.0/24 192.0.2.22
427 # - ip route 192.0.0.0/24 192.0.2.22 vrf temp1
428 # - ip route 192.0.2.0/24 192.0.2.22 tag 2 4
429 # - multicast service-reflect interface Ethernet1/1 map interface Ethernet2/2
430 # - multicast service-reflect interface Ethernet2/1 map interface Ethernet4/2
431 # - ipv6 mld ssm-translate ff28::/16 2001:db8:0:abcd::2
432 # - ipv6 mld ssm-translate ff30::/16 2001:db8:0:abcd::5
433
434 # after:
435 # vrfs:
436 # - name: testvrf
437 # description: this is description
438 # ip:
439 # auto_discard: true
440 # domain_list:
441 # - example.net
442 # - example.com
443 # domain_name: test.com
444 # icmp_err:
445 # source_interface:
446 # interface: port-channel
447 # interface_value: '1'
448 # igmp:
449 # ssm_translate:
450 # - group: 232.0.0.0/8
451 # source: 10.1.1.1
452 # - group: 239.1.2.3/24
453 # source: 192.168.1.1
454 # mroutes:
455 # - group: 192.168.1.0/24
456 # source: 192.168.1.1
457 # - group: 192.168.1.0/24
458 # preference: 2
459 # source: 192.168.1.2
460 # vrf: temp1
461 # multicast:
462 # multipath:
463 # resilient: true
464 # splitting_type:
465 # legacy: true
466 # rpf:
467 # - group_list_range: 238.1.0.0/24
468 # vrf_name: temp1
469 # - group_list_range: 239.1.0.0/24
470 # vrf_name: temp1
471 # name_server:
472 # address_list:
473 # - 192.168.0.1
474 # - 192.168.0.2
475 # - 192.168.1.1
476 # - 192.169.1.3
477 # use_vrf:
478 # source_address: 192.168.0.1
479 # vrf: temp1
480 # route:
481 # - destination: 192.0.2.22
482 # source: 192.0.0.0/24
483 # - destination: 192.0.2.22
484 # source: 192.0.0.0/24
485 # vrf: temp1
486 # - destination: 192.0.2.22
487 # source: 192.0.2.0/24
488 # tags:
489 # route_pref: 4
490 # tag_value: 2
491 # ipv6:
492 # mld_ssm_translate:
493 # - group: ff28::/16
494 # source: 2001:db8:0:abcd::2
495 # - group: ff30::/16
496 # source: 2001:db8:0:abcd::5
497 # multicast:
498 # group_range_prefix_list: temp2
499 # multipath:
500 # resilient: true
501 # splitting_type:
502 # none: true
503 # multicast:
504 # service_reflect:
505 # - map_to: Ethernet2/2
506 # service_interface: Ethernet1/1
507 # - map_to: Ethernet4/2
508 # service_interface: Ethernet2/1
509 # vni:
510 # vni_number: 5
511
512 # After state:
513 # ------------
514 #
515 # nxos#show running-config | section ^vrf
516 # vrf context testvrf
517 # description this is description
518 # ip auto-discard
519 # ip domain-name test.net
520 # ip name-server 192.168.0.1 192.168.0.2 192.168.1.1 192.169.1.3
521 # ip icmp-errors source-interface port-channel 1
522 # ip multicast multipath resilient
523 # ip multicast multipath legacy
524 # ip name-server 192.168.0.1 use-vrf temp1
525 # vni 5
526 # ipv6 multicast group-range prefix-list temp2
527 # ipv6 multicast multipath resilient
528 # ipv6 multicast multipath none
529 # ip domain-list test.org
530 # ip domain-list example.com
531 # ip domain-list example.net
532 # ip igmp ssm-translate 232.0.0.0/8 10.1.1.1
533 # ip igmp ssm-translate 239.1.2.3/24 192.168.1.1
534 # ip mroute 192.168.1.0/24 192.168.1.1
535 # ip mroute 192.168.1.0/24 192.168.1.2 2 vrf temp1
536 # ip multicast rpf select vrf temp1 group-list 238.1.0.0/24
537 # ip multicast rpf select vrf temp1 group-list 239.1.0.0/24
538 # ip route 192.0.0.0/24 192.0.2.22
539 # ip route 192.0.0.0/24 192.0.2.22 vrf temp1
540 # ip route 192.0.2.0/24 192.0.2.22 tag 2 4
541 # multicast service-reflect interface Ethernet1/1 map interface Ethernet2/2
542 # multicast service-reflect interface Ethernet2/1 map interface Ethernet4/2
543 # ipv6 mld ssm-translate ff28::/16 2001:db8:0:abcd::2
544 # ipv6 mld ssm-translate ff30::/16 2001:db8:0:abcd::5
545
546 # Using deleted
547
548 # Before state:
549 # -------------
550 #
551 # nxos#show running-config | section ^vrf
552 # vrf context management
553 # ip name-server 192.168.255.1
554 # ip route 0.0.0.0/0 192.168.255.1
555 # vrf context test1
556 # description this is description
557 # ip domain-name test.net
558 # ip domain-list example.net
559 # ip domain-list example.com
560 # ip domain-list test.org
561 # vni 5
562 # ip auto-discard
563 # ip route 192.0.0.0/24 192.0.2.22
564 # ip route 192.0.0.0/24 192.0.2.22 vrf temp1
565 # ip route 192.0.2.0/24 192.0.2.22 tag 2 4
566 # ip mroute 192.168.1.0/24 192.168.1.1
567 # ip mroute 192.168.1.0/24 192.168.1.2 2 vrf temp1
568 # ip icmp-errors source-interface po1
569 # ip igmp ssm-translate 232.0.0.0/8 10.1.1.1
570 # ip igmp ssm-translate 239.1.2.3/24 192.168.1.1
571 # ip multicast multipath legacy
572 # ip multicast multipath resilient
573 # ip multicast rpf select vrf temp1 group-list 238.1.0.0/24
574 # ip multicast rpf select vrf temp1 group-list 239.1.0.0/24
575 # ip multicast group-range prefix-list temp2
576
577 - name: Delete VRF configuration
578 cisco.nxos.vrf_global:
579 config:
580 vrfs:
581 - name: test1
582 state: deleted
583
584 # Task Output:
585 # ------------
586 #
587 # before:
588 # vrfs:
589 # - name: management
590 # ip:
591 # name_server:
592 # address_list:
593 # - 192.168.255.1
594 # route:
595 # - source: 0.0.0.0/0
596 # destination: 192.168.255.1
597 # - name: test1
598 # description: this is description
599 # ip:
600 # domain_name: test.net
601 # domain_list:
602 # - test.org
603 # - example.net
604 # - example.com
605 # auto_discard: true
606 # route:
607 # - source: 192.0.0.0/24
608 # destination: 192.0.2.22
609 # - source: 192.0.0.0/24
610 # destination: 192.0.2.22
611 # vrf: temp1
612 # - source: 192.0.2.0/24
613 # destination: 192.0.2.22
614 # tags:
615 # tag_value: 2
616 # route_pref: 4
617 # mroutes:
618 # - group: 192.168.1.0/24
619 # source: 192.168.1.1
620 # - group: 192.168.1.0/24
621 # source: 192.168.1.2
622 # preference: 2
623 # vrf: temp1
624 # icmp_err:
625 # source_interface:
626 # interface: port-channel
627 # interface_value: '1'
628 # igmp:
629 # ssm_translate:
630 # - group: 232.0.0.0/8
631 # source: 10.1.1.1
632 # - group: 239.1.2.3/24
633 # source: 192.168.1.1
634 # multicast:
635 # multipath:
636 # splitting_type:
637 # legacy: true
638 # resilient: true
639 # rpf:
640 # - vrf_name: temp1
641 # group_list_range: 238.1.0.0/24
642 # - vrf_name: temp1
643 # group_list_range: 239.1.0.0/24
644 # vni:
645 # vni_number: 5
646
647 # commands:
648 # - vrf context test1
649 # - no description this is description
650 # - no ip auto-discard
651 # - no ip domain-name test.net
652 # - no ip icmp-errors source-interface port-channel 1
653 # - no ip multicast multipath resilient
654 # - no ip multicast multipath legacy
655 # - no vni 5
656 # - no ip domain-list example.net
657 # - no ip domain-list test.org
658 # - no ip domain-list example.com
659 # - no ip igmp ssm-translate 232.0.0.0/8 10.1.1.1
660 # - no ip igmp ssm-translate 239.1.2.3/24 192.168.1.1
661 # - no ip mroute 192.168.1.0/24 192.168.1.1
662 # - no ip mroute 192.168.1.0/24 192.168.1.2 2 vrf temp1
663 # - no ip multicast rpf select vrf temp1 group-list 238.1.0.0/24
664 # - no ip multicast rpf select vrf temp1 group-list 239.1.0.0/24
665 # - no ip route 192.0.0.0/24 192.0.2.22
666 # - no ip route 192.0.0.0/24 192.0.2.22 vrf temp1
667 # - no ip route 192.0.2.0/24 192.0.2.22 tag 2 4
668 #
669 # after:
670 # vrfs:
671 # - name: management
672 # ip:
673 # name_server:
674 # address_list:
675 # - 192.168.255.1
676 # route:
677 # - source: 0.0.0.0/0
678 # destination: 192.168.255.1
679 # - name: test1
680
681 # Using deleted with empty config
682
683 # Before state:
684 # -------------
685 #
686 # nxos#show running-config | section ^vrf
687 # vrf context management
688 # ip name-server 192.168.255.1
689 # ip route 0.0.0.0/0 192.168.255.1
690 # vrf context test1
691 # description this is description
692 # ip domain-name test.net
693 # ip domain-list example.net
694 # ip domain-list example.com
695 # ip domain-list test.org
696 # vni 5
697
698 - name: Delete VRF configuration
699 cisco.nxos.vrf_global:
700 config:
701 vrfs:
702 - name: test1
703 state: deleted
704
705 # Task Output:
706 # ------------
707 #
708 # before:
709 # vrfs:
710 # - name: management
711 # ip:
712 # name_server:
713 # address_list:
714 # - 192.168.255.1
715 # route:
716 # - source: 0.0.0.0/0
717 # destination: 192.168.255.1
718 # - name: test1
719 # description: this is description
720 # ip:
721 # domain_name: test.net
722 # domain_list:
723 # - test.org
724 # - example.net
725 # - example.com
726 # vni:
727 # vni_number: 5
728
729 # commands:
730 # - vrf context management
731 # - no ip name-server 192.168.255.1
732 # - no ip route 0.0.0.0/0 192.168.255.1
733 # - vrf context test1
734 # - no description this is description
735 # - no ip domain-name test.net
736 # - no vni 5
737 # - no ip domain-list example.net
738 # - no ip domain-list test.org
739 # - no ip domain-list example.com
740
741 # after:
742 # vrfs:
743 # - name: management
744 # - name: test1
745
746 # Using purged
747
748 # Before state:
749 # -------------
750 #
751 # nxos#show running-config | section ^vrf
752 # vrf context management
753 # ip name-server 192.168.255.1
754 # ip route 0.0.0.0/0 192.168.255.1
755 # vrf context test1
756 # description this is description
757 # ip domain-name example.com
758 # ip domain-list example.net
759 # ip domain-list example.org
760 # vni 5
761 # ip auto-discard
762 # ip route 192.0.0.0/24 192.0.2.22
763 # ip route 192.0.0.0/24 192.0.2.22 vrf temp1
764 # ip route 192.0.2.0/24 192.0.2.22 tag 2 4
765 # vrf context test2
766 # description test description
767 # ip auto-discard
768 # ip domain-name test.com
769
770 - name: Override VRF configuration
771 cisco.nxos.vrf_global:
772 config:
773 vrfs:
774 - name: test1
775 - name: test2
776 state: purged
777
778 # Task Output:
779 # ------------
780 #
781 # before:
782 # vrfs:
783 # - name: management
784 # ip:
785 # name_server:
786 # address_list:
787 # - 192.168.255.1
788 # route:
789 # - source: 0.0.0.0/0
790 # destination: 192.168.255.1
791 # - name: test1
792 # description: this is description
793 # ip:
794 # domain_name: example.com
795 # domain_list:
796 # - example.net
797 # - example.org
798 # auto_discard: true
799 # route:
800 # - source: 192.0.0.0/24
801 # destination: 192.0.2.22
802 # - source: 192.0.0.0/24
803 # destination: 192.0.2.22
804 # vrf: temp1
805 # - source: 192.0.2.0/24
806 # destination: 192.0.2.22
807 # tags:
808 # tag_value: 2
809 # route_pref: 4
810 # vni:
811 # vni_number: 5
812 # - name: test2
813 # description: test description
814 # ip:
815 # auto_discard: true
816 # domain_name: test.com
817 #
818 # commands:
819 # - no vrf context test1
820 # - no vrf context test2
821 #
822 # after:
823 # vrfs:
824 # - name: management
825 # ip:
826 # name_server:
827 # address_list:
828 # - 192.168.255.1
829 # route:
830 # - source: 0.0.0.0/0
831 # destination: 192.168.255.1
832
833 # Using overridden
834
835 # Before state:
836 # -------------
837 #
838 # nxos#show running-config | section ^vrf
839 # vrf context management
840 # ip name-server 192.168.255.1
841 # ip route 0.0.0.0/0 192.168.255.1
842 # vrf context test1
843 # description this is description
844 # ip domain-name example.com
845 # ip domain-list example.net
846 # ip domain-list example.org
847 # vni 5
848 # ip auto-discard
849 # ip route 192.0.0.0/24 192.0.2.22
850 # ip route 192.0.0.0/24 192.0.2.22 vrf temp1
851 # ip route 192.0.2.0/24 192.0.2.22 tag 2 4
852 # vrf context test2
853 # description test description
854 # ip auto-discard
855 # ip domain-name test.com
856
857 - name: Override VRF configuration
858 cisco.nxos.vrf_global:
859 config:
860 vrfs:
861 - name: management
862 ip:
863 name_server:
864 address_list:
865 - 192.168.255.1
866 route:
867 - source: 0.0.0.0/0
868 destination: 192.168.255.1
869 - name: test1
870 ip:
871 auto_discard: false
872 name_server:
873 address_list:
874 - 192.168.255.1
875 route:
876 - source: 192.0.0.0/24
877 destination: 192.0.2.22
878 state: overridden
879
880 # Task Output:
881 # ------------
882 #
883 # before:
884 # vrfs:
885 # - name: management
886 # ip:
887 # name_server:
888 # address_list:
889 # - 192.168.255.1
890 # route:
891 # - source: 0.0.0.0/0
892 # destination: 192.168.255.1
893 # - name: test1
894 # description: this is description
895 # ip:
896 # domain_name: example.com
897 # domain_list:
898 # - example.net
899 # - example.org
900 # auto_discard: true
901 # route:
902 # - source: 192.0.0.0/24
903 # destination: 192.0.2.22
904 # - source: 192.0.0.0/24
905 # destination: 192.0.2.22
906 # vrf: temp1
907 # - source: 192.0.2.0/24
908 # destination: 192.0.2.22
909 # tags:
910 # tag_value: 2
911 # route_pref: 4
912 # vni:
913 # vni_number: 5
914 # - name: test2
915 # description: test description
916 # ip:
917 # auto_discard: true
918 # domain_name: test.com
919 #
920 # commands:
921 # - vrf context test1
922 # - no description this is description
923 # - no ip domain-name example.com
924 # - no ip domain-list example.net
925 # - no ip domain-list example.org
926 # - ip name-server 192.168.255.1
927 # - no ip auto-discard
928 # - no vni 5
929 # - no ip route 192.0.0.0/24 192.0.2.22 vrf temp1
930 # - no ip route 192.0.2.0/24 192.0.2.22 tag 2 4
931 # - vrf context test2
932 # - no description test description
933 # - no ip auto-discard
934 # - no ip domain-name test.com
935 #
936 # after:
937 # vrfs:
938 # - name: management
939 # ip:
940 # name_server:
941 # address_list:
942 # - 192.168.255.1
943 # route:
944 # - source: 0.0.0.0/0
945 # destination: 192.168.255.1
946 # - name: test1
947 # ip:
948 # auto_discard: false
949 # name_server:
950 # address_list:
951 # - 192.168.255.1
952 # route:
953 # - source: 192.0.0.0/24
954 # destination: 192.0.2.22
955
956 # Using replaced
957
958 # Before state:
959 # -------------
960 #
961 # nxos# show running-config | section ^vrf
962 # vrf context management
963 # ip name-server 192.168.255.1
964 # ip route 0.0.0.0/0 192.168.255.1
965 # vrf context temp
966 # ip domain-name test.org
967 # ip domain-list example.net
968 # ip domain-list example.com
969 # ip domain-list test.org
970 # ip name-server 192.168.0.1 192.169.1.3
971 # ip name-server 192.168.0.1 use-vrf temp1
972 # multicast service-reflect interface Ethernet1/1 map interface Ethernet2/2
973 # multicast service-reflect interface Ethernet2/1 map interface Ethernet4/2
974 # description this is descrition
975 # vni 5
976 # ip auto-discard
977 # ip route 192.0.0.0/24 192.0.2.22
978 # ip route 192.0.0.0/24 192.0.2.22 vrf temp1
979 # ip route 192.0.2.0/24 192.0.2.22 tag 2 4
980 # ip mroute 192.168.1.0/24 192.168.1.1
981 # ip mroute 192.168.1.0/24 192.168.1.2 2 vrf temp1
982 # ip icmp-errors source-interface po1
983 # ip igmp ssm-translate 232.0.0.0/8 10.1.1.1
984 # ip igmp ssm-translate 239.1.2.3/24 192.168.1.1
985 # ip multicast multipath legacy
986 # ip multicast multipath resilient
987 # ip multicast rpf select vrf temp1 group-list 238.1.0.0/24
988 # ip multicast rpf select vrf temp1 group-list 239.1.0.0/24
989 # ip multicast group-range prefix-list temp2
990 # ipv6 multicast multipath none
991 # ipv6 multicast multipath resilient
992 # ipv6 multicast group-range prefix-list temp2
993 # ipv6 mld ssm-translate ff28::/16 2001:db8:0:abcd::2
994 # ipv6 mld ssm-translate ff30::/16 2001:db8:0:abcd::1
995 # ipv6 mld ssm-translate ff32::/16 2001:db8:0:abcd::2
996 # ipv6 mld ssm-translate ff32::/16 2001:db8:0:abcd::3
997
998 - name: Replaced state for VRF configuration
999 cisco.nxos.nxos_vrf_global:
1000 config:
1001 vrfs:
1002 - ip:
1003 name_server:
1004 address_list:
1005 - 192.168.255.1
1006 route:
1007 - destination: 192.168.255.1
1008 source: 0.0.0.0/0
1009 name: management
1010 - name: temp
1011 description: Test
1012 ip:
1013 auto_discard: true
1014 domain_list:
1015 - invalid.com
1016 - example.com
1017 domain_name: test.org
1018 state: replaced
1019
1020 # Task Output:
1021 # ------------
1022 #
1023 # before:
1024 # vrfs:
1025 # - ip:
1026 # name_server:
1027 # address_list:
1028 # - 192.168.255.1
1029 # route:
1030 # - destination: 192.168.255.1
1031 # source: 0.0.0.0/0
1032 # name: management
1033 # - description: this is descrition
1034 # ip:
1035 # auto_discard: true
1036 # domain_list:
1037 # - example.net
1038 # - test.org
1039 # - example.com
1040 # domain_name: test.org
1041 # icmp_err:
1042 # source_interface:
1043 # interface: port-channel
1044 # interface_value: '1'
1045 # igmp:
1046 # ssm_translate:
1047 # - group: 232.0.0.0/8
1048 # source: 10.1.1.1
1049 # - group: 239.1.2.3/24
1050 # source: 192.168.1.1
1051 # mroutes:
1052 # - group: 192.168.1.0/24
1053 # source: 192.168.1.1
1054 # - group: 192.168.1.0/24
1055 # preference: 2
1056 # source: 192.168.1.2
1057 # vrf: temp1
1058 # multicast:
1059 # multipath:
1060 # resilient: true
1061 # splitting_type:
1062 # legacy: true
1063 # rpf:
1064 # - group_list_range: 238.1.0.0/24
1065 # vrf_name: temp1
1066 # - group_list_range: 239.1.0.0/24
1067 # vrf_name: temp1
1068 # name_server:
1069 # address_list:
1070 # - 192.168.0.1
1071 # - 192.169.1.3
1072 # use_vrf:
1073 # source_address: 192.168.0.1
1074 # vrf: temp1
1075 # route:
1076 # - destination: 192.0.2.22
1077 # source: 192.0.0.0/24
1078 # - destination: 192.0.2.22
1079 # source: 192.0.0.0/24
1080 # vrf: temp1
1081 # - destination: 192.0.2.22
1082 # source: 192.0.2.0/24
1083 # tags:
1084 # route_pref: 4
1085 # tag_value: 2
1086 # ipv6:
1087 # mld_ssm_translate:
1088 # - group: ff28::/16
1089 # source: 2001:db8:0:abcd::2
1090 # - group: ff30::/16
1091 # source: 2001:db8:0:abcd::1
1092 # - group: ff32::/16
1093 # source: 2001:db8:0:abcd::2
1094 # - group: ff32::/16
1095 # source: 2001:db8:0:abcd::3
1096 # multicast:
1097 # group_range_prefix_list: temp2
1098 # multipath:
1099 # resilient: true
1100 # splitting_type:
1101 # none: true
1102 # multicast:
1103 # service_reflect:
1104 # - map_to: Ethernet2/2
1105 # service_interface: Ethernet1/1
1106 # - map_to: Ethernet4/2
1107 # service_interface: Ethernet2/1
1108 # name: temp
1109 # vni:
1110 # vni_number: 5
1111 #
1112 # commands:
1113 # - vrf context temp
1114 # - description Test
1115 # - no ip name-server 192.168.0.1 192.169.1.3
1116 # - no ip icmp-errors source-interface port-channel 1
1117 # - no ip multicast multipath resilient
1118 # - no ip multicast multipath legacy
1119 # - no ip name-server 192.168.0.1 use-vrf temp1
1120 # - no vni 5
1121 # - no ipv6 multicast group-range prefix-list temp2
1122 # - no ipv6 multicast multipath resilient
1123 # - no ipv6 multicast multipath none
1124 # - ip domain-list invalid.com
1125 # - no ip domain-list example.net
1126 # - no ip domain-list test.org
1127 # - no ip igmp ssm-translate 232.0.0.0/8 10.1.1.1
1128 # - no ip igmp ssm-translate 239.1.2.3/24 192.168.1.1
1129 # - no ip mroute 192.168.1.0/24 192.168.1.1
1130 # - no ip mroute 192.168.1.0/24 192.168.1.2 2 vrf temp1
1131 # - no ip multicast rpf select vrf temp1 group-list 238.1.0.0/24
1132 # - no ip multicast rpf select vrf temp1 group-list 239.1.0.0/24
1133 # - no ip route 192.0.0.0/24 192.0.2.22
1134 # - no ip route 192.0.0.0/24 192.0.2.22 vrf temp1
1135 # - no ip route 192.0.2.0/24 192.0.2.22 tag 2 4
1136 # - no multicast service-reflect interface Ethernet1/1 map interface Ethernet2/2
1137 # - no multicast service-reflect interface Ethernet2/1 map interface Ethernet4/2
1138 # - no ipv6 mld ssm-translate ff28::/16 2001:db8:0:abcd::2
1139 # - no ipv6 mld ssm-translate ff30::/16 2001:db8:0:abcd::1
1140 # - no ipv6 mld ssm-translate ff32::/16 2001:db8:0:abcd::2
1141 # - no ipv6 mld ssm-translate ff32::/16 2001:db8:0:abcd::3
1142 #
1143 # after:
1144 # vrfs:
1145 # - ip:
1146 # name_server:
1147 # address_list:
1148 # - 192.168.255.1
1149 # route:
1150 # - destination: 192.168.255.1
1151 # source: 0.0.0.0/0
1152 # name: management
1153 # - description: Test
1154 # ip:
1155 # auto_discard: true
1156 # domain_list:
1157 # - invalid.com
1158 # - example.com
1159 # domain_name: test.org
1160 # multicast:
1161 # rpf:
1162 # - group_list_range: 238.1.0.0/24
1163 # vrf_name: temp1
1164 # - group_list_range: 239.1.0.0/24
1165 # vrf_name: temp1
1166 #
1167 # After state:
1168 # ------------
1169 # router-ios#show running-config | section ^vrf
1170 # vrf context management
1171 # ip name-server 192.168.255.1
1172 # ip route 0.0.0.0/0 192.168.255.1
1173 # vrf context temp
1174 # ip domain-name test.org
1175 # ip domain-list example.com
1176 # ip domain-list invalid.com
1177 # description Test
1178 # ip auto-discard
1179 # ip multicast rpf select vrf temp1 group-list 238.1.0.0/24
1180 # ip multicast rpf select vrf temp1 group-list 239.1.0.0/24
1181 # ip multicast group-range prefix-list temp2
1182 """
1183
1184 RETURN = """
1185 before:
1186 description: The configuration prior to the module execution.
1187 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
1188 type: dict
1189 sample: >
1190 This output will always be in the same format as the
1191 module argspec.
1192 after:
1193 description: The resulting configuration after module execution.
1194 returned: when changed
1195 type: dict
1196 sample: >
1197 This output will always be in the same format as the
1198 module argspec.
1199 commands:
1200 description: The set of commands pushed to the remote device.
1201 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
1202 type: list
1203 sample:
1204 - vrf context management
1205 - description this is management vrf
1206 - ip domain-name example.com
1207 rendered:
1208 description: The provided configuration in the task rendered in device-native format (offline).
1209 returned: when I(state) is C(rendered)
1210 type: list
1211 sample:
1212 - vrf context test1
1213 - description This is a test VRF
1214 - ip route 192.0.0.0/24 192.0.2.22
1215 gathered:
1216 description: Facts about the network resource gathered from the remote device as structured data.
1217 returned: when I(state) is C(gathered)
1218 type: dict
1219 sample: >
1220 This output will always be in the same format as the
1221 module argspec.
1222 parsed:
1223 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
1224 returned: when I(state) is C(parsed)
1225 type: dict
1226 sample: >
1227 This output will always be in the same format as the
1228 module argspec.
1229 """
1230
1231 from ansible.module_utils.basic import AnsibleModule
1232
1233 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.vrf_global.vrf_global import (
1234 Vrf_globalArgs,
1235 )
1236 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.vrf_global.vrf_global import (
1237 Vrf_global,
1238 )
1239
1240
1241 def main():
1242 """
1243 Main entry point for module execution
1244
1245 :returns: the result form module invocation
1246 """
1247 module = AnsibleModule(
1248 argument_spec=Vrf_globalArgs.argument_spec,
1249 mutually_exclusive=[["config", "running_config"]],
1250 required_if=[
1251 ["state", "merged", ["config"]],
1252 ["state", "replaced", ["config"]],
1253 ["state", "overridden", ["config"]],
1254 ["state", "rendered", ["config"]],
1255 ["state", "parsed", ["running_config"]],
1256 ],
1257 supports_check_mode=True,
1258 )
1259
1260 result = Vrf_global(module).execute_module()
1261 module.exit_json(**result)
1262
1263
1264 if __name__ == "__main__":
1265 main()