Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_static_routes.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_static_routes
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 module: nxos_static_routes
18 short_description: Static routes resource module
19 description: This module configures and manages the attributes of static routes on
20 Cisco NX-OS platforms.
21 version_added: 1.0.0
22 author:
23 - Adharsh Srivats Rangarajan (@adharshsrivatsr)
24 - Sagar Paul (@KB-perByte)
25 notes:
26 - Tested against Nexus 9300v running NX-OS 9.3.6 on CML.
27 - Unsupported for Cisco MDS
28 - When a route is configured for a non-existent VRF, the VRF is created and the route
29 is added to it.
30 - When deleting routes for a VRF, all routes inside the VRF are deleted, but the VRF
31 is not deleted.
32 options:
33 running_config:
34 description:
35 - This option is used only with state I(parsed).
36 - The value of this option should be the output received from the NX-OS device
37 by executing the following commands in order B(show running-config | include
38 '^ip(v6)* route') and B(show running-config | section '^vrf context').
39 - The state I(parsed) reads the configuration from C(running_config) option and
40 transforms it into Ansible structured data as per the resource module's argspec
41 and the value is then returned in the I(parsed) key within the result.
42 type: str
43 config:
44 description:
45 - A list of configurations for static routes
46 type: list
47 elements: dict
48 suboptions:
49 vrf:
50 description:
51 - The VRF to which the static route(s) belong
52 type: str
53 address_families:
54 description: A dictionary specifying the address family to which the static
55 route(s) belong.
56 type: list
57 elements: dict
58 suboptions:
59 afi:
60 description:
61 - Specifies the top level address family indicator.
62 type: str
63 choices: [ipv4, ipv6]
64 required: true
65 routes:
66 description: A dictionary that specifies the static route configurations
67 elements: dict
68 type: list
69 suboptions:
70 dest:
71 description:
72 - Destination prefix of static route
73 - The address format is <ipv4/v6 address>/<mask>
74 - The mask is number in range 0-32 for IPv4 and in range 0-128 for
75 IPv6
76 type: str
77 required: true
78 next_hops:
79 description:
80 - Details of route to be taken
81 type: list
82 elements: dict
83 suboptions:
84 forward_router_address:
85 description:
86 - IP address of the next hop router
87 type: str
88 # required: True
89 interface:
90 description:
91 - Outgoing interface to take. For anything except 'Null0', then
92 next hop IP address should also be configured.
93 type: str
94 admin_distance:
95 description:
96 - Preference or administrative distance of route (range 1-255)
97 type: int
98 route_name:
99 description:
100 - Name of the static route
101 type: str
102 tag:
103 description:
104 - Route tag value (numeric)
105 type: int
106 track:
107 description:
108 - Track value (range 1 - 512). Track must already be configured
109 on the device before adding the route.
110 type: int
111 dest_vrf:
112 description:
113 - VRF of the destination
114 type: str
115 state:
116 description:
117 - The state the configuration should be left in
118 - The states I(rendered), I(gathered) and I(parsed) does not perform any change
119 on the device.
120 - The state I(rendered) will transform the configuration in C(config) option to
121 platform specific CLI commands which will be returned in the I(rendered) key
122 within the result. For state I(rendered) active connection to remote host is
123 not required.
124 - The state C(deleted) does not support or guarantee granular deletion of configuration
125 the playbook should act as source of truth, and the desired state of the resouce is what
126 the playbook should reflect. Use C(overridden) or C(replaced) to get extra configuration
127 removed.
128 - The state I(gathered) will fetch the running configuration from device and transform
129 it into structured data in the format as per the resource module argspec and
130 the value is returned in the I(gathered) key within the result.
131 - The state I(parsed) reads the configuration from C(running_config) option and
132 transforms it into JSON format as per the resource module parameters and the
133 value is returned in the I(parsed) key within the result. The value of C(running_config)
134 option should be the same format as the output of command
135 I(show running-config | section '^ip(v6)* route') executed on device. For state I(parsed) active
136 connection to remote host is not required.
137 type: str
138 choices:
139 - deleted
140 - merged
141 - overridden
142 - replaced
143 - gathered
144 - rendered
145 - parsed
146 default: merged
147 """
148
149 EXAMPLES = """
150 # Using deleted - delete all
151
152 # Before state:
153 # -------------
154 #
155 # switch# show running-config | include '^ip(v6)* route'
156 # ip route 192.0.2.32/28 192.0.2.12 name new_route
157 # ip route 192.0.2.26/24 192.0.2.13 tag 12
158 # switch# show running-config | section '^vrf context'
159
160 - name: Delete all routes
161 cisco.nxos.nxos_static_routes:
162 state: deleted
163
164 # Task Output
165 # -----------
166 #
167 # before:
168 # - address_families:
169 # - afi: ipv4
170 # routes:
171 # - dest: 192.0.2.0/24
172 # next_hops:
173 # - forward_router_address: 192.0.2.13
174 # tag: 12
175 # - dest: 192.0.2.32/28
176 # next_hops:
177 # - forward_router_address: 192.0.2.12
178 # route_name: new_route
179 # commands:
180 # - no ip route 192.0.2.0/24 192.0.2.13 tag 12
181 # - no ip route 192.0.2.32/28 192.0.2.12 name new_route
182 # after: []
183
184 # After state:
185 # ------------
186 # switch# show running-config | include '^ip(v6)* route'
187 # switch# show running-config | section '^vrf context'
188
189 # Using deleted - vrf based
190
191 # Before state:
192 # ------------
193 #
194 # switch# show running-config | include '^ip(v6)* route'
195 # ip route 192.0.2.16/28 192.0.2.24 name new_route
196 # ip route 192.0.2.80/28 192.0.2.26 tag 12
197 # switch# show running-config | section '^vrf context'
198 # vrf context trial_vrf
199 # ip route 192.0.2.64/28 192.0.2.22 tag 4
200 # ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
201 # ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5
202
203 - name: Delete routes based on VRF
204 cisco.nxos.nxos_static_routes:
205 config:
206 - vrf: trial_vrf
207 state: deleted
208
209 # Task Output
210 # -----------
211 #
212 # before:
213 # - address_families:
214 # - afi: ipv4
215 # routes:
216 # - dest: 192.0.2.64/28
217 # next_hops:
218 # - forward_router_address: 192.0.2.22
219 # tag: 4
220 # - admin_distance: 1
221 # forward_router_address: 192.0.2.23
222 # route_name: merged_route
223 # - afi: ipv6
224 # routes:
225 # - dest: '2200:10::/36'
226 # next_hops:
227 # - admin_distance: 5
228 # dest_vrf: dest
229 # forward_router_address: '2048:ae12::1'
230 # vrf: trial_vrf
231 # - address_families:
232 # - afi: ipv4
233 # routes:
234 # - dest: 192.0.2.16/28
235 # next_hops:
236 # - forward_router_address: 192.0.2.24
237 # route_name: new_route
238 # - dest: 192.0.2.80/28
239 # next_hops:
240 # - forward_router_address: 192.0.2.26
241 # tag: 12
242 # commands:
243 # - vrf context trial_vrf
244 # - no ip route 192.0.2.64/28 192.0.2.22 tag 4
245 # - no ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
246 # - no ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5
247 # after:
248 # - address_families:
249 # - afi: ipv4
250 # routes:
251 # - dest: 192.0.2.16/28
252 # next_hops:
253 # - forward_router_address: 192.0.2.24
254 # route_name: new_route
255 # - dest: 192.0.2.80/28
256 # next_hops:
257 # - forward_router_address: 192.0.2.26
258 # tag: 12
259
260 # After state:
261 # -----------
262 #
263 # switch# show running-config | include '^ip(v6)* route'
264 # ip route 192.0.2.16/28 192.0.2.24 name new_route
265 # ip route 192.0.2.80/28 192.0.2.26 tag 12
266 # switch# show running-config | section '^vrf context'
267 # vrf context trial_vrf
268
269 # Using deleted - afi based
270
271 # Before state:
272 # ------------
273 #
274 # switch# show running-config | include '^ip(v6)* route'
275 # ip route 192.0.2.16/28 192.0.2.24 name new_route
276 # ip route 192.0.2.80/28 192.0.2.26 tag 12
277 # switch# show running-config | section '^vrf context'
278 # vrf context trial_vrf
279 # ip route 192.0.2.64/28 192.0.2.22 tag 4
280 # ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
281 # ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5
282
283 - name: Delete routes based on AFI in a VRF
284 cisco.nxos.nxos_static_routes:
285 config:
286 - vrf: trial_vrf
287 address_families:
288 - afi: ipv4
289 state: deleted
290
291 # Task Output
292 # -----------
293 #
294 # before:
295 # - address_families:
296 # - afi: ipv4
297 # routes:
298 # - dest: 192.0.2.64/28
299 # next_hops:
300 # - forward_router_address: 192.0.2.22
301 # tag: 4
302 # - admin_distance: 1
303 # forward_router_address: 192.0.2.23
304 # route_name: merged_route
305 # - afi: ipv6
306 # routes:
307 # - dest: '2200:10::/36'
308 # next_hops:
309 # - admin_distance: 5
310 # dest_vrf: dest
311 # forward_router_address: '2048:ae12::1'
312 # vrf: trial_vrf
313 # - address_families:
314 # - afi: ipv4
315 # routes:
316 # - dest: 192.0.2.16/28
317 # next_hops:
318 # - forward_router_address: 192.0.2.24
319 # route_name: new_route
320 # - dest: 192.0.2.80/28
321 # next_hops:
322 # - forward_router_address: 192.0.2.26
323 # tag: 12
324 # commands:
325 # - vrf context trial_vrf
326 # - no ip route 192.0.2.64/28 192.0.2.22 tag 4
327 # - no ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
328 # after:
329 # - address_families:
330 # - afi: ipv6
331 # routes:
332 # - dest: '2200:10::/36'
333 # next_hops:
334 # - admin_distance: 5
335 # dest_vrf: dest
336 # forward_router_address: '2048:ae12::1'
337 # vrf: trial_vrf
338 # - address_families:
339 # - afi: ipv4
340 # routes:
341 # - dest: 192.0.2.16/28
342 # next_hops:
343 # - forward_router_address: 192.0.2.24
344 # route_name: new_route
345 # - dest: 192.0.2.80/28
346 # next_hops:
347 # - forward_router_address: 192.0.2.26
348 # tag: 12
349
350 # After state:
351 # -----------
352 #
353 # switch# show running-config | include '^ip(v6)* route'
354 # ip route 192.0.2.16/28 192.0.2.24 name new_route
355 # ip route 192.0.2.80/28 192.0.2.26 tag 12
356 # switch# show running-config | section '^vrf context'
357 # vrf context trial_vrf
358 # ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5
359
360 # Using merged
361
362 # Before state:
363 # -------------
364 # switch# show running-config | include '^ip(v6)* route'
365 # switch# show running-config | section '^vrf context'
366
367 - name: Merge new static route configuration
368 cisco.nxos.nxos_static_routes:
369 config:
370 - vrf: trial_vrf
371 address_families:
372 - afi: ipv4
373 routes:
374 - dest: 192.0.2.64/24
375 next_hops:
376 - forward_router_address: 192.0.2.22
377 tag: 4
378 admin_distance: 2
379 - address_families:
380 - afi: ipv4
381 routes:
382 - dest: 192.0.2.16/24
383 next_hops:
384 - forward_router_address: 192.0.2.24
385 route_name: new_route
386 - afi: ipv6
387 routes:
388 - dest: '2001:db8::/64'
389 next_hops:
390 - interface: eth1/3
391 forward_router_address: '2001:db8::12'
392 state: merged
393
394 # Task Output
395 # -----------
396 #
397 # before:[]
398 # commands:
399 # - vrf context trial_vrf
400 # - ip route 192.0.2.64/24 192.0.2.22 tag 4 2
401 # - ip route 192.0.2.16/24 192.0.2.24 name new_route
402 # - ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12
403 # after:
404 # - vrf: trial_vrf
405 # address_families:
406 # - afi: ipv4
407 # routes:
408 # - dest: 192.0.2.64/24
409 # next_hops:
410 # - forward_router_address: 192.0.2.22
411 # tag: 4
412 # admin_distance: 2
413 # - address_families:
414 # - afi: ipv4
415 # routes:
416 # - dest: 192.0.2.16/24
417 # next_hops:
418 # - forward_router_address: 192.0.2.24
419 # route_name: new_route
420 # - afi: ipv6
421 # routes:
422 # - dest: 2001:db8::/64
423 # next_hops:
424 # - interface: eth1/3
425 # forward_router_address: 2
426
427 # After state:
428 # ------------
429 #
430 # switch# show running-config | include '^ip(v6)* route'
431 # ip route 192.0.2.16/24 192.0.2.24 name new_route
432 # ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12
433 # switch# show running-config | section '^vrf context'
434 # vrf context trial_vrf
435 # ip route 192.0.2.0/24 192.0.2.22 tag 4 2
436
437 # Using overridden
438
439 # Before state:
440 # -------------
441 #
442 # switch# show running-config | include '^ip(v6)* route'
443 # ip route 192.0.2.16/28 192.0.2.24 name new_route
444 # ip route 192.0.2.80/28 192.0.2.26 tag 12
445 # switch# show running-config | section '^vrf context'
446 # vrf context trial_vrf
447 # ip route 192.0.2.64/28 192.0.2.22 tag 4
448 # ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
449
450 - name: Overridden existing static route configuration with new configuration
451 cisco.nxos.nxos_static_routes:
452 config:
453 - vrf: trial_vrf
454 address_families:
455 - afi: ipv4
456 routes:
457 - dest: 192.0.2.16/28
458 next_hops:
459 - forward_router_address: 192.0.2.23
460 route_name: overridden_route1
461 admin_distance: 3
462 - forward_router_address: 192.0.2.45
463 route_name: overridden_route2
464 dest_vrf: destinationVRF
465 interface: Ethernet1/2
466 state: overridden
467
468 # Task Output
469 # -----------
470 #
471 # before:
472 # - address_families:
473 # - afi: ipv4
474 # routes:
475 # - dest: 192.0.2.64/28
476 # next_hops:
477 # - forward_router_address: 192.0.2.22
478 # tag: 4
479 # - admin_distance: 1
480 # forward_router_address: 192.0.2.23
481 # route_name: merged_route
482 # vrf: trial_vrf
483 # - address_families:
484 # - afi: ipv4
485 # routes:
486 # - dest: 192.0.2.16/28
487 # next_hops:
488 # - forward_router_address: 192.0.2.24
489 # route_name: new_route
490 # - dest: 192.0.2.80/28
491 # next_hops:
492 # - forward_router_address: 192.0.2.26
493 # tag: 12
494 # commands:
495 # - no ip route 192.0.2.16/28 192.0.2.24 name new_route
496 # - no ip route 192.0.2.80/28 192.0.2.26 tag 12
497 # - vrf context trial_vrf
498 # - no ip route 192.0.2.64/28 192.0.2.22 tag 4
499 # - no ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
500 # - ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3
501 # - ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name overridden_route2
502 # after:
503 # - address_families:
504 # - afi: ipv4
505 # routes:
506 # - dest: 192.0.2.16/28
507 # next_hops:
508 # - admin_distance: 3
509 # forward_router_address: 192.0.2.23
510 # route_name: overridden_route1
511 # - dest_vrf: destinationVRF
512 # forward_router_address: 192.0.2.45
513 # interface: Ethernet1/2
514 # route_name: overridden_route2
515 # vrf: trial_vrf
516
517 # After state:
518 # ------------
519 #
520 # switch# show running-config | include '^ip(v6)* route'
521 # switch# show running-config | section '^vrf context'
522 # vrf context trial_vrf
523 # ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3
524 # ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name overridden_route2
525
526 # Using replaced
527
528 # Before state:
529 # ------------
530 #
531 # switch# show running-config | include '^ip(v6)* route'
532 # ip route 192.0.2.16/28 192.0.2.24 name new_route
533 # ip route 192.0.2.80/28 192.0.2.26 tag 12
534 # switch# show running-config | section '^vrf context'
535 # vrf context trial_vrf
536 # ip route 192.0.2.64/28 192.0.2.22 tag 4
537 # ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
538
539 - name: Replaced the existing static configuration of a prefix with new configuration
540 cisco.nxos.nxos_static_routes:
541 config:
542 - address_families:
543 - afi: ipv4
544 routes:
545 - dest: 192.0.2.16/28
546 next_hops:
547 - forward_router_address: 192.0.2.23
548 route_name: replaced_route1
549 admin_distance: 3
550 - forward_router_address: 192.0.2.45
551 route_name: replaced_route2
552 dest_vrf: destinationVRF
553 interface: Ethernet1/2
554 state: replaced
555
556 # Task Output
557 # -----------
558 #
559 # before:
560 # - address_families:
561 # - afi: ipv4
562 # routes:
563 # - dest: 192.0.2.64/28
564 # next_hops:
565 # - forward_router_address: 192.0.2.22
566 # tag: 4
567 # - admin_distance: 1
568 # forward_router_address: 192.0.2.23
569 # route_name: merged_route
570 # vrf: trial_vrf
571 # - address_families:
572 # - afi: ipv4
573 # routes:
574 # - dest: 192.0.2.16/28
575 # next_hops:
576 # - forward_router_address: 192.0.2.24
577 # route_name: new_route
578 # - dest: 192.0.2.80/28
579 # next_hops:
580 # - forward_router_address: 192.0.2.26
581 # tag: 12
582 # commands:
583 # - no ip route 192.0.2.16/28 192.0.2.24 name new_route
584 # - ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3
585 # - ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2
586 # after:
587 # - address_families:
588 # - afi: ipv4
589 # routes:
590 # - dest: 192.0.2.64/28
591 # next_hops:
592 # - forward_router_address: 192.0.2.22
593 # tag: 4
594 # - admin_distance: 1
595 # forward_router_address: 192.0.2.23
596 # route_name: merged_route
597 # vrf: trial_vrf
598 # - address_families:
599 # - afi: ipv4
600 # routes:
601 # - dest: 192.0.2.16/28
602 # next_hops:
603 # - admin_distance: 3
604 # forward_router_address: 192.0.2.23
605 # route_name: replaced_route1
606 # - dest_vrf: destinationVRF
607 # forward_router_address: 192.0.2.45
608 # interface: Ethernet1/2
609 # route_name: replaced_route2
610 # - dest: 192.0.2.80/28
611 # next_hops:
612 # - forward_router_address: 192.0.2.26
613 # tag: 12
614
615 # After state:
616 # ------------
617 #
618 # switch# show running-config | include '^ip(v6)* route'
619 # ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3
620 # ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2
621 # ip route 192.0.2.80/28 192.0.2.26 tag 12
622 # switch# show running-config | section '^vrf context'
623 # vrf context trial_vrf
624 # ip route 192.0.2.64/28 192.0.2.22 tag 4
625 # ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
626
627
628 # Using gathered
629
630 # Before state:
631 # -------------
632 #
633 # switch# show running-config | include '^ip(v6)* route'
634 # ipv6 route 2001:db8:12::/32 2001:db8::12
635 # switch# show running-config | section '^vrf context'
636 # vrf context Test
637 # ip route 192.0.2.48/28 192.0.2.13
638 # ip route 192.0.2.48/28 192.0.2.14 5
639
640 - name: Gather the existing configuration
641 cisco.nxos.nxos_static_routes:
642 state: gathered
643
644 # Task Output
645 # -----------
646 #
647 # gathered:
648 # - vrf: Test
649 # address_families:
650 # - afi: ipv4
651 # routes:
652 # - dest: 192.0.2.48/28
653 # next_hops:
654 # - forward_router_address: 192.0.2.13
655 #
656 # - forward_router_address: 192.0.2.14
657 # admin_distance: 5
658 #
659 # - address_families:
660 # - afi: ipv6
661 # routes:
662 # - dest: 2001:db8:12::/32
663 # next_hops:
664 # - forward_router_address: 2001:db8::12
665
666
667 # Using rendered
668
669 - name: Render required configuration to be pushed to the device
670 cisco.nxos.nxos_static_routes:
671 config:
672 - address_families:
673 - afi: ipv4
674 routes:
675 - dest: 192.0.2.48/28
676 next_hops:
677 - forward_router_address: 192.0.2.13
678 - afi: ipv6
679 routes:
680 - dest: 2001:db8::/64
681 next_hops:
682 - interface: eth1/3
683 forward_router_address: 2001:db8::12
684 state: rendered
685
686 # Task Output
687 # -----------
688 #
689 # rendered:
690 # vrf context default
691 # ip route 192.0.2.48/28 192.0.2.13
692 # ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12
693
694 # Using parsed
695
696 - name: Parse the config to structured data
697 cisco.nxos.nxos_static_routes:
698 state: parsed
699 running_config: |
700 ipv6 route 2002:db8:12::/32 2002:db8:12::1
701 vrf context Test
702 ip route 192.0.2.48/28 192.0.2.13
703 ip route 192.0.2.48/28 192.0.2.14 5
704
705 # Task Output
706 # -----------
707 #
708 # parsed:
709 # - vrf: Test
710 # address_families:
711 # - afi: ipv4
712 # routes:
713 # - dest: 192.0.2.48/28
714 # next_hops:
715 # - forward_router_address: 192.0.2.13
716 # - forward_router_address: 192.0.2.14
717 # admin_distance: 5
718 # - address_families:
719 # - afi: ipv6
720 # routes:
721 # - dest: 2002:db8:12::/32
722 # next_hops:
723 # - forward_router_address: 2002:db8:12::1
724 """
725
726 RETURN = """
727 before:
728 description: The configuration prior to the module execution.
729 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
730 type: list
731 sample: >
732 This output will always be in the same format as the
733 module argspec.
734 after:
735 description: The resulting configuration after module execution.
736 returned: when changed
737 type: list
738 sample: >
739 This output will always be in the same format as the
740 module argspec.
741 commands:
742 description: The set of commands pushed to the remote device.
743 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
744 type: list
745 sample:
746 - ip route 192.0.2.16/28 192.0.2.24 name new_route
747 - vrf context trial_vrf
748 - ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3
749 rendered:
750 description: The provided configuration in the task rendered in device-native format (offline).
751 returned: when I(state) is C(rendered)
752 type: list
753 sample:
754 - ip route 192.0.2.16/28 192.0.2.24 name new_route
755 - vrf context trial_vrf
756 - ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3
757 gathered:
758 description: Facts about the network resource gathered from the remote device as structured data.
759 returned: when I(state) is C(gathered)
760 type: list
761 sample: >
762 This output will always be in the same format as the
763 module argspec.
764 parsed:
765 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
766 returned: when I(state) is C(parsed)
767 type: list
768 sample: >
769 This output will always be in the same format as the
770 module argspec.
771 """
772
773
774 from ansible.module_utils.basic import AnsibleModule
775
776 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.static_routes.static_routes import (
777 Static_routesArgs,
778 )
779 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.static_routes.static_routes import (
780 Static_routes,
781 )
782
783
784 def main():
785 """
786 Main entry point for module execution
787
788 :returns: the result form module invocation
789 """
790
791 module = AnsibleModule(
792 argument_spec=Static_routesArgs.argument_spec,
793 mutually_exclusive=[["config", "running_config"]],
794 required_if=[
795 ["state", "merged", ["config"]],
796 ["state", "replaced", ["config"]],
797 ["state", "overridden", ["config"]],
798 ["state", "rendered", ["config"]],
799 ["state", "parsed", ["running_config"]],
800 ],
801 supports_check_mode=True,
802 )
803
804 result = Static_routes(module).execute_module()
805 module.exit_json(**result)
806
807
808 if __name__ == "__main__":
809 main()