Debian Codegraph @

ansible_collections/cisco/nxos/docs/cisco.nxos.nxos_static_routes_module.rst

raw
1 .. _cisco.nxos.nxos_static_routes_module:
2
3
4 *****************************
5 cisco.nxos.nxos_static_routes
6 *****************************
7
8 **Static routes resource module**
9
10
11 Version added: 1.0.0
12
13 .. contents::
14 :local:
15 :depth: 1
16
17
18 Synopsis
19 --------
20 - This module configures and manages the attributes of static routes on Cisco NX-OS platforms.
21
22
23
24
25 Parameters
26 ----------
27
28 .. raw:: html
29
30 <table border=0 cellpadding=0 class="documentation-table">
31 <tr>
32 <th colspan="5">Parameter</th>
33 <th>Choices/<font color="blue">Defaults</font></th>
34 <th width="100%">Comments</th>
35 </tr>
36 <tr>
37 <td colspan="5">
38 <div class="ansibleOptionAnchor" id="parameter-"></div>
39 <b>config</b>
40 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
41 <div style="font-size: small">
42 <span style="color: purple">list</span>
43 / <span style="color: purple">elements=dictionary</span>
44 </div>
45 </td>
46 <td>
47 </td>
48 <td>
49 <div>A list of configurations for static routes</div>
50 </td>
51 </tr>
52 <tr>
53 <td class="elbow-placeholder"></td>
54 <td colspan="4">
55 <div class="ansibleOptionAnchor" id="parameter-"></div>
56 <b>address_families</b>
57 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
58 <div style="font-size: small">
59 <span style="color: purple">list</span>
60 / <span style="color: purple">elements=dictionary</span>
61 </div>
62 </td>
63 <td>
64 </td>
65 <td>
66 <div>A dictionary specifying the address family to which the static route(s) belong.</div>
67 </td>
68 </tr>
69 <tr>
70 <td class="elbow-placeholder"></td>
71 <td class="elbow-placeholder"></td>
72 <td colspan="3">
73 <div class="ansibleOptionAnchor" id="parameter-"></div>
74 <b>afi</b>
75 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
76 <div style="font-size: small">
77 <span style="color: purple">string</span>
78 / <span style="color: red">required</span>
79 </div>
80 </td>
81 <td>
82 <ul style="margin: 0; padding: 0"><b>Choices:</b>
83 <li>ipv4</li>
84 <li>ipv6</li>
85 </ul>
86 </td>
87 <td>
88 <div>Specifies the top level address family indicator.</div>
89 </td>
90 </tr>
91 <tr>
92 <td class="elbow-placeholder"></td>
93 <td class="elbow-placeholder"></td>
94 <td colspan="3">
95 <div class="ansibleOptionAnchor" id="parameter-"></div>
96 <b>routes</b>
97 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
98 <div style="font-size: small">
99 <span style="color: purple">list</span>
100 / <span style="color: purple">elements=dictionary</span>
101 </div>
102 </td>
103 <td>
104 </td>
105 <td>
106 <div>A dictionary that specifies the static route configurations</div>
107 </td>
108 </tr>
109 <tr>
110 <td class="elbow-placeholder"></td>
111 <td class="elbow-placeholder"></td>
112 <td class="elbow-placeholder"></td>
113 <td colspan="2">
114 <div class="ansibleOptionAnchor" id="parameter-"></div>
115 <b>dest</b>
116 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
117 <div style="font-size: small">
118 <span style="color: purple">string</span>
119 / <span style="color: red">required</span>
120 </div>
121 </td>
122 <td>
123 </td>
124 <td>
125 <div>Destination prefix of static route</div>
126 <div>The address format is &lt;ipv4/v6 address&gt;/&lt;mask&gt;</div>
127 <div>The mask is number in range 0-32 for IPv4 and in range 0-128 for IPv6</div>
128 </td>
129 </tr>
130 <tr>
131 <td class="elbow-placeholder"></td>
132 <td class="elbow-placeholder"></td>
133 <td class="elbow-placeholder"></td>
134 <td colspan="2">
135 <div class="ansibleOptionAnchor" id="parameter-"></div>
136 <b>next_hops</b>
137 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
138 <div style="font-size: small">
139 <span style="color: purple">list</span>
140 / <span style="color: purple">elements=dictionary</span>
141 </div>
142 </td>
143 <td>
144 </td>
145 <td>
146 <div>Details of route to be taken</div>
147 </td>
148 </tr>
149 <tr>
150 <td class="elbow-placeholder"></td>
151 <td class="elbow-placeholder"></td>
152 <td class="elbow-placeholder"></td>
153 <td class="elbow-placeholder"></td>
154 <td colspan="1">
155 <div class="ansibleOptionAnchor" id="parameter-"></div>
156 <b>admin_distance</b>
157 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
158 <div style="font-size: small">
159 <span style="color: purple">integer</span>
160 </div>
161 </td>
162 <td>
163 </td>
164 <td>
165 <div>Preference or administrative distance of route (range 1-255)</div>
166 </td>
167 </tr>
168 <tr>
169 <td class="elbow-placeholder"></td>
170 <td class="elbow-placeholder"></td>
171 <td class="elbow-placeholder"></td>
172 <td class="elbow-placeholder"></td>
173 <td colspan="1">
174 <div class="ansibleOptionAnchor" id="parameter-"></div>
175 <b>dest_vrf</b>
176 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
177 <div style="font-size: small">
178 <span style="color: purple">string</span>
179 </div>
180 </td>
181 <td>
182 </td>
183 <td>
184 <div>VRF of the destination</div>
185 </td>
186 </tr>
187 <tr>
188 <td class="elbow-placeholder"></td>
189 <td class="elbow-placeholder"></td>
190 <td class="elbow-placeholder"></td>
191 <td class="elbow-placeholder"></td>
192 <td colspan="1">
193 <div class="ansibleOptionAnchor" id="parameter-"></div>
194 <b>forward_router_address</b>
195 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
196 <div style="font-size: small">
197 <span style="color: purple">string</span>
198 </div>
199 </td>
200 <td>
201 </td>
202 <td>
203 <div>IP address of the next hop router</div>
204 </td>
205 </tr>
206 <tr>
207 <td class="elbow-placeholder"></td>
208 <td class="elbow-placeholder"></td>
209 <td class="elbow-placeholder"></td>
210 <td class="elbow-placeholder"></td>
211 <td colspan="1">
212 <div class="ansibleOptionAnchor" id="parameter-"></div>
213 <b>interface</b>
214 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
215 <div style="font-size: small">
216 <span style="color: purple">string</span>
217 </div>
218 </td>
219 <td>
220 </td>
221 <td>
222 <div>Outgoing interface to take. For anything except &#x27;Null0&#x27;, then next hop IP address should also be configured.</div>
223 </td>
224 </tr>
225 <tr>
226 <td class="elbow-placeholder"></td>
227 <td class="elbow-placeholder"></td>
228 <td class="elbow-placeholder"></td>
229 <td class="elbow-placeholder"></td>
230 <td colspan="1">
231 <div class="ansibleOptionAnchor" id="parameter-"></div>
232 <b>route_name</b>
233 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
234 <div style="font-size: small">
235 <span style="color: purple">string</span>
236 </div>
237 </td>
238 <td>
239 </td>
240 <td>
241 <div>Name of the static route</div>
242 </td>
243 </tr>
244 <tr>
245 <td class="elbow-placeholder"></td>
246 <td class="elbow-placeholder"></td>
247 <td class="elbow-placeholder"></td>
248 <td class="elbow-placeholder"></td>
249 <td colspan="1">
250 <div class="ansibleOptionAnchor" id="parameter-"></div>
251 <b>tag</b>
252 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
253 <div style="font-size: small">
254 <span style="color: purple">integer</span>
255 </div>
256 </td>
257 <td>
258 </td>
259 <td>
260 <div>Route tag value (numeric)</div>
261 </td>
262 </tr>
263 <tr>
264 <td class="elbow-placeholder"></td>
265 <td class="elbow-placeholder"></td>
266 <td class="elbow-placeholder"></td>
267 <td class="elbow-placeholder"></td>
268 <td colspan="1">
269 <div class="ansibleOptionAnchor" id="parameter-"></div>
270 <b>track</b>
271 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
272 <div style="font-size: small">
273 <span style="color: purple">integer</span>
274 </div>
275 </td>
276 <td>
277 </td>
278 <td>
279 <div>Track value (range 1 - 512). Track must already be configured on the device before adding the route.</div>
280 </td>
281 </tr>
282
283
284
285 <tr>
286 <td class="elbow-placeholder"></td>
287 <td colspan="4">
288 <div class="ansibleOptionAnchor" id="parameter-"></div>
289 <b>vrf</b>
290 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
291 <div style="font-size: small">
292 <span style="color: purple">string</span>
293 </div>
294 </td>
295 <td>
296 </td>
297 <td>
298 <div>The VRF to which the static route(s) belong</div>
299 </td>
300 </tr>
301
302 <tr>
303 <td colspan="5">
304 <div class="ansibleOptionAnchor" id="parameter-"></div>
305 <b>running_config</b>
306 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
307 <div style="font-size: small">
308 <span style="color: purple">string</span>
309 </div>
310 </td>
311 <td>
312 </td>
313 <td>
314 <div>This option is used only with state <em>parsed</em>.</div>
315 <div>The value of this option should be the output received from the NX-OS device by executing the following commands in order <b>show running-config | include &#x27;^ip(v6</b>* route&#x27;) and <b>show running-config | section &#x27;^vrf context&#x27;</b>.</div>
316 <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module&#x27;s argspec and the value is then returned in the <em>parsed</em> key within the result.</div>
317 </td>
318 </tr>
319 <tr>
320 <td colspan="5">
321 <div class="ansibleOptionAnchor" id="parameter-"></div>
322 <b>state</b>
323 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
324 <div style="font-size: small">
325 <span style="color: purple">string</span>
326 </div>
327 </td>
328 <td>
329 <ul style="margin: 0; padding: 0"><b>Choices:</b>
330 <li>deleted</li>
331 <li><div style="color: blue"><b>merged</b>&nbsp;&larr;</div></li>
332 <li>overridden</li>
333 <li>replaced</li>
334 <li>gathered</li>
335 <li>rendered</li>
336 <li>parsed</li>
337 </ul>
338 </td>
339 <td>
340 <div>The state the configuration should be left in</div>
341 <div>The states <em>rendered</em>, <em>gathered</em> and <em>parsed</em> does not perform any change on the device.</div>
342 <div>The state <em>rendered</em> will transform the configuration in <code>config</code> option to platform specific CLI commands which will be returned in the <em>rendered</em> key within the result. For state <em>rendered</em> active connection to remote host is not required.</div>
343 <div>The state <code>deleted</code> does not support or guarantee granular deletion of configuration the playbook should act as source of truth, and the desired state of the resouce is what the playbook should reflect. Use <code>overridden</code> or <code>replaced</code> to get extra configuration removed.</div>
344 <div>The state <em>gathered</em> will fetch the running configuration from device and transform it into structured data in the format as per the resource module argspec and the value is returned in the <em>gathered</em> key within the result.</div>
345 <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into JSON format as per the resource module parameters and the value is returned in the <em>parsed</em> key within the result. The value of <code>running_config</code> option should be the same format as the output of command <em>show running-config | section &#x27;^ip(v6</em>* route&#x27;) executed on device. For state <em>parsed</em> active connection to remote host is not required.</div>
346 </td>
347 </tr>
348 </table>
349 <br/>
350
351
352 Notes
353 -----
354
355 .. note::
356 - Tested against Nexus 9300v running NX-OS 9.3.6 on CML.
357 - Unsupported for Cisco MDS
358 - When a route is configured for a non-existent VRF, the VRF is created and the route is added to it.
359 - When deleting routes for a VRF, all routes inside the VRF are deleted, but the VRF is not deleted.
360
361
362
363 Examples
364 --------
365
366 .. code-block:: yaml
367
368 # Using deleted - delete all
369
370 # Before state:
371 # -------------
372 #
373 # switch# show running-config | include '^ip(v6)* route'
374 # ip route 192.0.2.32/28 192.0.2.12 name new_route
375 # ip route 192.0.2.26/24 192.0.2.13 tag 12
376 # switch# show running-config | section '^vrf context'
377
378 - name: Delete all routes
379 cisco.nxos.nxos_static_routes:
380 state: deleted
381
382 # Task Output
383 # -----------
384 #
385 # before:
386 # - address_families:
387 # - afi: ipv4
388 # routes:
389 # - dest: 192.0.2.0/24
390 # next_hops:
391 # - forward_router_address: 192.0.2.13
392 # tag: 12
393 # - dest: 192.0.2.32/28
394 # next_hops:
395 # - forward_router_address: 192.0.2.12
396 # route_name: new_route
397 # commands:
398 # - no ip route 192.0.2.0/24 192.0.2.13 tag 12
399 # - no ip route 192.0.2.32/28 192.0.2.12 name new_route
400 # after: []
401
402 # After state:
403 # ------------
404 # switch# show running-config | include '^ip(v6)* route'
405 # switch# show running-config | section '^vrf context'
406
407 # Using deleted - vrf based
408
409 # Before state:
410 # ------------
411 #
412 # switch# show running-config | include '^ip(v6)* route'
413 # ip route 192.0.2.16/28 192.0.2.24 name new_route
414 # ip route 192.0.2.80/28 192.0.2.26 tag 12
415 # switch# show running-config | section '^vrf context'
416 # vrf context trial_vrf
417 # ip route 192.0.2.64/28 192.0.2.22 tag 4
418 # ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
419 # ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5
420
421 - name: Delete routes based on VRF
422 cisco.nxos.nxos_static_routes:
423 config:
424 - vrf: trial_vrf
425 state: deleted
426
427 # Task Output
428 # -----------
429 #
430 # before:
431 # - address_families:
432 # - afi: ipv4
433 # routes:
434 # - dest: 192.0.2.64/28
435 # next_hops:
436 # - forward_router_address: 192.0.2.22
437 # tag: 4
438 # - admin_distance: 1
439 # forward_router_address: 192.0.2.23
440 # route_name: merged_route
441 # - afi: ipv6
442 # routes:
443 # - dest: '2200:10::/36'
444 # next_hops:
445 # - admin_distance: 5
446 # dest_vrf: dest
447 # forward_router_address: '2048:ae12::1'
448 # vrf: trial_vrf
449 # - address_families:
450 # - afi: ipv4
451 # routes:
452 # - dest: 192.0.2.16/28
453 # next_hops:
454 # - forward_router_address: 192.0.2.24
455 # route_name: new_route
456 # - dest: 192.0.2.80/28
457 # next_hops:
458 # - forward_router_address: 192.0.2.26
459 # tag: 12
460 # commands:
461 # - vrf context trial_vrf
462 # - no ip route 192.0.2.64/28 192.0.2.22 tag 4
463 # - no ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
464 # - no ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5
465 # after:
466 # - address_families:
467 # - afi: ipv4
468 # routes:
469 # - dest: 192.0.2.16/28
470 # next_hops:
471 # - forward_router_address: 192.0.2.24
472 # route_name: new_route
473 # - dest: 192.0.2.80/28
474 # next_hops:
475 # - forward_router_address: 192.0.2.26
476 # tag: 12
477
478 # After state:
479 # -----------
480 #
481 # switch# show running-config | include '^ip(v6)* route'
482 # ip route 192.0.2.16/28 192.0.2.24 name new_route
483 # ip route 192.0.2.80/28 192.0.2.26 tag 12
484 # switch# show running-config | section '^vrf context'
485 # vrf context trial_vrf
486
487 # Using deleted - afi based
488
489 # Before state:
490 # ------------
491 #
492 # switch# show running-config | include '^ip(v6)* route'
493 # ip route 192.0.2.16/28 192.0.2.24 name new_route
494 # ip route 192.0.2.80/28 192.0.2.26 tag 12
495 # switch# show running-config | section '^vrf context'
496 # vrf context trial_vrf
497 # ip route 192.0.2.64/28 192.0.2.22 tag 4
498 # ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
499 # ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5
500
501 - name: Delete routes based on AFI in a VRF
502 cisco.nxos.nxos_static_routes:
503 config:
504 - vrf: trial_vrf
505 address_families:
506 - afi: ipv4
507 state: deleted
508
509 # Task Output
510 # -----------
511 #
512 # before:
513 # - address_families:
514 # - afi: ipv4
515 # routes:
516 # - dest: 192.0.2.64/28
517 # next_hops:
518 # - forward_router_address: 192.0.2.22
519 # tag: 4
520 # - admin_distance: 1
521 # forward_router_address: 192.0.2.23
522 # route_name: merged_route
523 # - afi: ipv6
524 # routes:
525 # - dest: '2200:10::/36'
526 # next_hops:
527 # - admin_distance: 5
528 # dest_vrf: dest
529 # forward_router_address: '2048:ae12::1'
530 # vrf: trial_vrf
531 # - address_families:
532 # - afi: ipv4
533 # routes:
534 # - dest: 192.0.2.16/28
535 # next_hops:
536 # - forward_router_address: 192.0.2.24
537 # route_name: new_route
538 # - dest: 192.0.2.80/28
539 # next_hops:
540 # - forward_router_address: 192.0.2.26
541 # tag: 12
542 # commands:
543 # - vrf context trial_vrf
544 # - no ip route 192.0.2.64/28 192.0.2.22 tag 4
545 # - no ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
546 # after:
547 # - address_families:
548 # - afi: ipv6
549 # routes:
550 # - dest: '2200:10::/36'
551 # next_hops:
552 # - admin_distance: 5
553 # dest_vrf: dest
554 # forward_router_address: '2048:ae12::1'
555 # vrf: trial_vrf
556 # - address_families:
557 # - afi: ipv4
558 # routes:
559 # - dest: 192.0.2.16/28
560 # next_hops:
561 # - forward_router_address: 192.0.2.24
562 # route_name: new_route
563 # - dest: 192.0.2.80/28
564 # next_hops:
565 # - forward_router_address: 192.0.2.26
566 # tag: 12
567
568 # After state:
569 # -----------
570 #
571 # switch# show running-config | include '^ip(v6)* route'
572 # ip route 192.0.2.16/28 192.0.2.24 name new_route
573 # ip route 192.0.2.80/28 192.0.2.26 tag 12
574 # switch# show running-config | section '^vrf context'
575 # vrf context trial_vrf
576 # ipv6 route 2200:10::/36 2048:ae12::1 vrf dest 5
577
578 # Using merged
579
580 # Before state:
581 # -------------
582 # switch# show running-config | include '^ip(v6)* route'
583 # switch# show running-config | section '^vrf context'
584
585 - name: Merge new static route configuration
586 cisco.nxos.nxos_static_routes:
587 config:
588 - vrf: trial_vrf
589 address_families:
590 - afi: ipv4
591 routes:
592 - dest: 192.0.2.64/24
593 next_hops:
594 - forward_router_address: 192.0.2.22
595 tag: 4
596 admin_distance: 2
597 - address_families:
598 - afi: ipv4
599 routes:
600 - dest: 192.0.2.16/24
601 next_hops:
602 - forward_router_address: 192.0.2.24
603 route_name: new_route
604 - afi: ipv6
605 routes:
606 - dest: '2001:db8::/64'
607 next_hops:
608 - interface: eth1/3
609 forward_router_address: '2001:db8::12'
610 state: merged
611
612 # Task Output
613 # -----------
614 #
615 # before:[]
616 # commands:
617 # - vrf context trial_vrf
618 # - ip route 192.0.2.64/24 192.0.2.22 tag 4 2
619 # - ip route 192.0.2.16/24 192.0.2.24 name new_route
620 # - ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12
621 # after:
622 # - vrf: trial_vrf
623 # address_families:
624 # - afi: ipv4
625 # routes:
626 # - dest: 192.0.2.64/24
627 # next_hops:
628 # - forward_router_address: 192.0.2.22
629 # tag: 4
630 # admin_distance: 2
631 # - address_families:
632 # - afi: ipv4
633 # routes:
634 # - dest: 192.0.2.16/24
635 # next_hops:
636 # - forward_router_address: 192.0.2.24
637 # route_name: new_route
638 # - afi: ipv6
639 # routes:
640 # - dest: 2001:db8::/64
641 # next_hops:
642 # - interface: eth1/3
643 # forward_router_address: 2
644
645 # After state:
646 # ------------
647 #
648 # switch# show running-config | include '^ip(v6)* route'
649 # ip route 192.0.2.16/24 192.0.2.24 name new_route
650 # ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12
651 # switch# show running-config | section '^vrf context'
652 # vrf context trial_vrf
653 # ip route 192.0.2.0/24 192.0.2.22 tag 4 2
654
655 # Using overridden
656
657 # Before state:
658 # -------------
659 #
660 # switch# show running-config | include '^ip(v6)* route'
661 # ip route 192.0.2.16/28 192.0.2.24 name new_route
662 # ip route 192.0.2.80/28 192.0.2.26 tag 12
663 # switch# show running-config | section '^vrf context'
664 # vrf context trial_vrf
665 # ip route 192.0.2.64/28 192.0.2.22 tag 4
666 # ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
667
668 - name: Overridden existing static route configuration with new configuration
669 cisco.nxos.nxos_static_routes:
670 config:
671 - vrf: trial_vrf
672 address_families:
673 - afi: ipv4
674 routes:
675 - dest: 192.0.2.16/28
676 next_hops:
677 - forward_router_address: 192.0.2.23
678 route_name: overridden_route1
679 admin_distance: 3
680 - forward_router_address: 192.0.2.45
681 route_name: overridden_route2
682 dest_vrf: destinationVRF
683 interface: Ethernet1/2
684 state: overridden
685
686 # Task Output
687 # -----------
688 #
689 # before:
690 # - address_families:
691 # - afi: ipv4
692 # routes:
693 # - dest: 192.0.2.64/28
694 # next_hops:
695 # - forward_router_address: 192.0.2.22
696 # tag: 4
697 # - admin_distance: 1
698 # forward_router_address: 192.0.2.23
699 # route_name: merged_route
700 # vrf: trial_vrf
701 # - address_families:
702 # - afi: ipv4
703 # routes:
704 # - dest: 192.0.2.16/28
705 # next_hops:
706 # - forward_router_address: 192.0.2.24
707 # route_name: new_route
708 # - dest: 192.0.2.80/28
709 # next_hops:
710 # - forward_router_address: 192.0.2.26
711 # tag: 12
712 # commands:
713 # - no ip route 192.0.2.16/28 192.0.2.24 name new_route
714 # - no ip route 192.0.2.80/28 192.0.2.26 tag 12
715 # - vrf context trial_vrf
716 # - no ip route 192.0.2.64/28 192.0.2.22 tag 4
717 # - no ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
718 # - ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3
719 # - ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name overridden_route2
720 # after:
721 # - address_families:
722 # - afi: ipv4
723 # routes:
724 # - dest: 192.0.2.16/28
725 # next_hops:
726 # - admin_distance: 3
727 # forward_router_address: 192.0.2.23
728 # route_name: overridden_route1
729 # - dest_vrf: destinationVRF
730 # forward_router_address: 192.0.2.45
731 # interface: Ethernet1/2
732 # route_name: overridden_route2
733 # vrf: trial_vrf
734
735 # After state:
736 # ------------
737 #
738 # switch# show running-config | include '^ip(v6)* route'
739 # switch# show running-config | section '^vrf context'
740 # vrf context trial_vrf
741 # ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3
742 # ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name overridden_route2
743
744 # Using replaced
745
746 # Before state:
747 # ------------
748 #
749 # switch# show running-config | include '^ip(v6)* route'
750 # ip route 192.0.2.16/28 192.0.2.24 name new_route
751 # ip route 192.0.2.80/28 192.0.2.26 tag 12
752 # switch# show running-config | section '^vrf context'
753 # vrf context trial_vrf
754 # ip route 192.0.2.64/28 192.0.2.22 tag 4
755 # ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
756
757 - name: Replaced the existing static configuration of a prefix with new configuration
758 cisco.nxos.nxos_static_routes:
759 config:
760 - address_families:
761 - afi: ipv4
762 routes:
763 - dest: 192.0.2.16/28
764 next_hops:
765 - forward_router_address: 192.0.2.23
766 route_name: replaced_route1
767 admin_distance: 3
768 - forward_router_address: 192.0.2.45
769 route_name: replaced_route2
770 dest_vrf: destinationVRF
771 interface: Ethernet1/2
772 state: replaced
773
774 # Task Output
775 # -----------
776 #
777 # before:
778 # - address_families:
779 # - afi: ipv4
780 # routes:
781 # - dest: 192.0.2.64/28
782 # next_hops:
783 # - forward_router_address: 192.0.2.22
784 # tag: 4
785 # - admin_distance: 1
786 # forward_router_address: 192.0.2.23
787 # route_name: merged_route
788 # vrf: trial_vrf
789 # - address_families:
790 # - afi: ipv4
791 # routes:
792 # - dest: 192.0.2.16/28
793 # next_hops:
794 # - forward_router_address: 192.0.2.24
795 # route_name: new_route
796 # - dest: 192.0.2.80/28
797 # next_hops:
798 # - forward_router_address: 192.0.2.26
799 # tag: 12
800 # commands:
801 # - no ip route 192.0.2.16/28 192.0.2.24 name new_route
802 # - ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3
803 # - ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2
804 # after:
805 # - address_families:
806 # - afi: ipv4
807 # routes:
808 # - dest: 192.0.2.64/28
809 # next_hops:
810 # - forward_router_address: 192.0.2.22
811 # tag: 4
812 # - admin_distance: 1
813 # forward_router_address: 192.0.2.23
814 # route_name: merged_route
815 # vrf: trial_vrf
816 # - address_families:
817 # - afi: ipv4
818 # routes:
819 # - dest: 192.0.2.16/28
820 # next_hops:
821 # - admin_distance: 3
822 # forward_router_address: 192.0.2.23
823 # route_name: replaced_route1
824 # - dest_vrf: destinationVRF
825 # forward_router_address: 192.0.2.45
826 # interface: Ethernet1/2
827 # route_name: replaced_route2
828 # - dest: 192.0.2.80/28
829 # next_hops:
830 # - forward_router_address: 192.0.2.26
831 # tag: 12
832
833 # After state:
834 # ------------
835 #
836 # switch# show running-config | include '^ip(v6)* route'
837 # ip route 192.0.2.16/28 192.0.2.23 name replaced_route1 3
838 # ip route 192.0.2.16/28 Ethernet1/2 192.0.2.45 vrf destinationVRF name replaced_route2
839 # ip route 192.0.2.80/28 192.0.2.26 tag 12
840 # switch# show running-config | section '^vrf context'
841 # vrf context trial_vrf
842 # ip route 192.0.2.64/28 192.0.2.22 tag 4
843 # ip route 192.0.2.64/28 192.0.2.23 name merged_route 1
844
845
846 # Using gathered
847
848 # Before state:
849 # -------------
850 #
851 # switch# show running-config | include '^ip(v6)* route'
852 # ipv6 route 2001:db8:12::/32 2001:db8::12
853 # switch# show running-config | section '^vrf context'
854 # vrf context Test
855 # ip route 192.0.2.48/28 192.0.2.13
856 # ip route 192.0.2.48/28 192.0.2.14 5
857
858 - name: Gather the existing configuration
859 cisco.nxos.nxos_static_routes:
860 state: gathered
861
862 # Task Output
863 # -----------
864 #
865 # gathered:
866 # - vrf: Test
867 # address_families:
868 # - afi: ipv4
869 # routes:
870 # - dest: 192.0.2.48/28
871 # next_hops:
872 # - forward_router_address: 192.0.2.13
873 #
874 # - forward_router_address: 192.0.2.14
875 # admin_distance: 5
876 #
877 # - address_families:
878 # - afi: ipv6
879 # routes:
880 # - dest: 2001:db8:12::/32
881 # next_hops:
882 # - forward_router_address: 2001:db8::12
883
884
885 # Using rendered
886
887 - name: Render required configuration to be pushed to the device
888 cisco.nxos.nxos_static_routes:
889 config:
890 - address_families:
891 - afi: ipv4
892 routes:
893 - dest: 192.0.2.48/28
894 next_hops:
895 - forward_router_address: 192.0.2.13
896 - afi: ipv6
897 routes:
898 - dest: 2001:db8::/64
899 next_hops:
900 - interface: eth1/3
901 forward_router_address: 2001:db8::12
902 state: rendered
903
904 # Task Output
905 # -----------
906 #
907 # rendered:
908 # vrf context default
909 # ip route 192.0.2.48/28 192.0.2.13
910 # ipv6 route 2001:db8::/64 Ethernet1/3 2001:db8::12
911
912 # Using parsed
913
914 - name: Parse the config to structured data
915 cisco.nxos.nxos_static_routes:
916 state: parsed
917 running_config: |
918 ipv6 route 2002:db8:12::/32 2002:db8:12::1
919 vrf context Test
920 ip route 192.0.2.48/28 192.0.2.13
921 ip route 192.0.2.48/28 192.0.2.14 5
922
923 # Task Output
924 # -----------
925 #
926 # parsed:
927 # - vrf: Test
928 # address_families:
929 # - afi: ipv4
930 # routes:
931 # - dest: 192.0.2.48/28
932 # next_hops:
933 # - forward_router_address: 192.0.2.13
934 # - forward_router_address: 192.0.2.14
935 # admin_distance: 5
936 # - address_families:
937 # - afi: ipv6
938 # routes:
939 # - dest: 2002:db8:12::/32
940 # next_hops:
941 # - forward_router_address: 2002:db8:12::1
942
943
944
945 Return Values
946 -------------
947 Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
948
949 .. raw:: html
950
951 <table border=0 cellpadding=0 class="documentation-table">
952 <tr>
953 <th colspan="1">Key</th>
954 <th>Returned</th>
955 <th width="100%">Description</th>
956 </tr>
957 <tr>
958 <td colspan="1">
959 <div class="ansibleOptionAnchor" id="return-"></div>
960 <b>after</b>
961 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
962 <div style="font-size: small">
963 <span style="color: purple">list</span>
964 </div>
965 </td>
966 <td>when changed</td>
967 <td>
968 <div>The resulting configuration after module execution.</div>
969 <br/>
970 <div style="font-size: smaller"><b>Sample:</b></div>
971 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
972 </td>
973 </tr>
974 <tr>
975 <td colspan="1">
976 <div class="ansibleOptionAnchor" id="return-"></div>
977 <b>before</b>
978 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
979 <div style="font-size: small">
980 <span style="color: purple">list</span>
981 </div>
982 </td>
983 <td>when <em>state</em> is <code>merged</code>, <code>replaced</code>, <code>overridden</code>, <code>deleted</code> or <code>purged</code></td>
984 <td>
985 <div>The configuration prior to the module execution.</div>
986 <br/>
987 <div style="font-size: smaller"><b>Sample:</b></div>
988 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
989 </td>
990 </tr>
991 <tr>
992 <td colspan="1">
993 <div class="ansibleOptionAnchor" id="return-"></div>
994 <b>commands</b>
995 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
996 <div style="font-size: small">
997 <span style="color: purple">list</span>
998 </div>
999 </td>
1000 <td>when <em>state</em> is <code>merged</code>, <code>replaced</code>, <code>overridden</code>, <code>deleted</code> or <code>purged</code></td>
1001 <td>
1002 <div>The set of commands pushed to the remote device.</div>
1003 <br/>
1004 <div style="font-size: smaller"><b>Sample:</b></div>
1005 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;ip route 192.0.2.16/28 192.0.2.24 name new_route&#x27;, &#x27;vrf context trial_vrf&#x27;, &#x27;ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3&#x27;]</div>
1006 </td>
1007 </tr>
1008 <tr>
1009 <td colspan="1">
1010 <div class="ansibleOptionAnchor" id="return-"></div>
1011 <b>gathered</b>
1012 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
1013 <div style="font-size: small">
1014 <span style="color: purple">list</span>
1015 </div>
1016 </td>
1017 <td>when <em>state</em> is <code>gathered</code></td>
1018 <td>
1019 <div>Facts about the network resource gathered from the remote device as structured data.</div>
1020 <br/>
1021 <div style="font-size: smaller"><b>Sample:</b></div>
1022 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
1023 </td>
1024 </tr>
1025 <tr>
1026 <td colspan="1">
1027 <div class="ansibleOptionAnchor" id="return-"></div>
1028 <b>parsed</b>
1029 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
1030 <div style="font-size: small">
1031 <span style="color: purple">list</span>
1032 </div>
1033 </td>
1034 <td>when <em>state</em> is <code>parsed</code></td>
1035 <td>
1036 <div>The device native config provided in <em>running_config</em> option parsed into structured data as per module argspec.</div>
1037 <br/>
1038 <div style="font-size: smaller"><b>Sample:</b></div>
1039 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
1040 </td>
1041 </tr>
1042 <tr>
1043 <td colspan="1">
1044 <div class="ansibleOptionAnchor" id="return-"></div>
1045 <b>rendered</b>
1046 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
1047 <div style="font-size: small">
1048 <span style="color: purple">list</span>
1049 </div>
1050 </td>
1051 <td>when <em>state</em> is <code>rendered</code></td>
1052 <td>
1053 <div>The provided configuration in the task rendered in device-native format (offline).</div>
1054 <br/>
1055 <div style="font-size: smaller"><b>Sample:</b></div>
1056 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;ip route 192.0.2.16/28 192.0.2.24 name new_route&#x27;, &#x27;vrf context trial_vrf&#x27;, &#x27;ip route 192.0.2.16/28 192.0.2.23 name overridden_route1 3&#x27;]</div>
1057 </td>
1058 </tr>
1059 </table>
1060 <br/><br/>
1061
1062
1063 Status
1064 ------
1065
1066
1067 Authors
1068 ~~~~~~~
1069
1070 - Adharsh Srivats Rangarajan (@adharshsrivatsr)
1071 - Sagar Paul (@KB-perByte)