Debian Codegraph @

ansible_collections/cisco/ios/docs/cisco.ios.ios_vrf_interfaces_module.rst

raw
1 .. _cisco.ios.ios_vrf_interfaces_module:
2
3
4 ****************************
5 cisco.ios.ios_vrf_interfaces
6 ****************************
7
8 **Manages VRF configuration on interfaces.**
9
10
11 Version added: 1.0.0
12
13 .. contents::
14 :local:
15 :depth: 1
16
17
18 Synopsis
19 --------
20 - Manages Virtual Routing and Forwarding (VRF) configuration on interfaces of Cisco IOS devices.
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="2">Parameter</th>
33 <th>Choices/<font color="blue">Defaults</font></th>
34 <th width="100%">Comments</th>
35 </tr>
36 <tr>
37 <td colspan="2">
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 interface VRF configurations.</div>
50 </td>
51 </tr>
52 <tr>
53 <td class="elbow-placeholder"></td>
54 <td colspan="1">
55 <div class="ansibleOptionAnchor" id="parameter-"></div>
56 <b>name</b>
57 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
58 <div style="font-size: small">
59 <span style="color: purple">string</span>
60 / <span style="color: red">required</span>
61 </div>
62 </td>
63 <td>
64 </td>
65 <td>
66 <div>Full name of the interface to be configured.</div>
67 <div>Example - GigabitEthernet1, Loopback24</div>
68 </td>
69 </tr>
70 <tr>
71 <td class="elbow-placeholder"></td>
72 <td colspan="1">
73 <div class="ansibleOptionAnchor" id="parameter-"></div>
74 <b>vrf_name</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 </div>
79 </td>
80 <td>
81 </td>
82 <td>
83 <div>Name of the VRF to be configured on the interface.</div>
84 <div>When configured, applies &#x27;vrf forwarding &lt;vrf_name&gt;&#x27; under the interface.</div>
85 </td>
86 </tr>
87
88 <tr>
89 <td colspan="2">
90 <div class="ansibleOptionAnchor" id="parameter-"></div>
91 <b>running_config</b>
92 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
93 <div style="font-size: small">
94 <span style="color: purple">string</span>
95 </div>
96 </td>
97 <td>
98 </td>
99 <td>
100 <div>This option is used only with state <em>parsed</em>.</div>
101 <div>The value of this option should be the output received from the IOS device by executing the command <b>show running-config | section ^interface</b>.</div>
102 <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>
103 </td>
104 </tr>
105 <tr>
106 <td colspan="2">
107 <div class="ansibleOptionAnchor" id="parameter-"></div>
108 <b>state</b>
109 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
110 <div style="font-size: small">
111 <span style="color: purple">string</span>
112 </div>
113 </td>
114 <td>
115 <ul style="margin: 0; padding: 0"><b>Choices:</b>
116 <li><div style="color: blue"><b>merged</b>&nbsp;&larr;</div></li>
117 <li>replaced</li>
118 <li>overridden</li>
119 <li>deleted</li>
120 <li>gathered</li>
121 <li>rendered</li>
122 <li>parsed</li>
123 </ul>
124 </td>
125 <td>
126 <div>The state the configuration should be left in.</div>
127 </td>
128 </tr>
129 </table>
130 <br/>
131
132
133 Notes
134 -----
135
136 .. note::
137 - Tested against Cisco IOS XE Version 17.13.01a
138 - VRF must exist before assigning to an interface
139 - When removing VRF from interface, associated IP addresses will be removed
140 - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>`
141 - For more information on using Ansible to manage Cisco devices see the `Cisco integration page <https://www.ansible.com/integrations/networks/cisco>`_.
142
143
144
145 Examples
146 --------
147
148 .. code-block:: yaml
149
150 # Using merged
151
152 # Before state:
153 # -------------
154 #
155 # vios#show running-config | section ^interface
156 # interface Loopback24
157 # no ip address
158 # interface GigabitEthernet1
159 # ip address dhcp
160 # negotiation auto
161 # interface GigabitEthernet2
162 # no ip address
163 # shutdown
164 # negotiation auto
165 # interface GigabitEthernet3
166 # no ip address
167 # negotiation auto
168 # interface GigabitEthernet4
169 # no ip address
170 # shutdown
171 # negotiation auto
172
173 - name: Merge provided configuration with device configuration
174 cisco.ios.ios_vrf_interfaces:
175 config:
176 - name: GigabitEthernet1
177 - name: GigabitEthernet2
178 vrf_name: vrf_D
179 - name: GigabitEthernet3
180 - name: GigabitEthernet4
181 state: merged
182
183 # Task Output:
184 # ------------
185 #
186 # before:
187 # - name: "Loopback24"
188 # - name: "GigabitEthernet1"
189 # - name: "GigabitEthernet2"
190 # - name: "GigabitEthernet3"
191 # - name: "GigabitEthernet4"
192 #
193 # commands:
194 # - interface GigabitEthernet2
195 # - vrf forwarding vrf_D
196 #
197 # after:
198 # - name: "Loopback24"
199 # - name: "GigabitEthernet1"
200 # - name: "GigabitEthernet2"
201 # vrf_name: "vrf_D"
202 # - name: "GigabitEthernet3"
203 # - name: "GigabitEthernet4"
204
205 # After state:
206 # ------------
207 #
208 # vios#show running-config | section ^interface
209 # interface Loopback24
210 # no ip address
211 # interface GigabitEthernet1
212 # ip address dhcp
213 # negotiation auto
214 # interface GigabitEthernet2
215 # vrf forwarding vrf_D
216 # no ip address
217 # shutdown
218 # negotiation auto
219 # interface GigabitEthernet3
220 # no ip address
221 # negotiation auto
222 # interface GigabitEthernet4
223 # no ip address
224 # shutdown
225 # negotiation auto
226
227 # Using overridden
228
229 # Before state:
230 # -------------
231 #
232 # vios#show running-config | section ^interface
233 # interface Loopback24
234 # no ip address
235 # interface GigabitEthernet1
236 # ip address dhcp
237 # negotiation auto
238 # interface GigabitEthernet2
239 # vrf forwarding vrf_B
240 # no ip address
241 # shutdown
242 # negotiation auto
243 # interface GigabitEthernet3
244 # no ip address
245 # negotiation auto
246 # interface GigabitEthernet4
247 # no ip address
248 # shutdown
249 # negotiation auto
250
251 - name: Override device configuration with provided configuration
252 cisco.ios.ios_vrf_interfaces:
253 config:
254 - name: GigabitEthernet1
255 - name: GigabitEthernet2
256 - name: GigabitEthernet3
257 - name: GigabitEthernet4
258 state: overridden
259
260 # Task Output:
261 # ------------
262 #
263 # before:
264 # - name: "Loopback24"
265 # - name: "GigabitEthernet1"
266 # - name: "GigabitEthernet2"
267 # vrf_name: "vrf_B"
268 # - name: "GigabitEthernet3"
269 # - name: "GigabitEthernet4"
270 #
271 # commands:
272 # - interface GigabitEthernet2
273 # - no vrf forwarding vrf_B
274 #
275 # after:
276 # - name: "Loopback24"
277 # - name: "GigabitEthernet1"
278 # - name: "GigabitEthernet2"
279 # - name: "GigabitEthernet3"
280 # - name: "GigabitEthernet4"
281
282 # After state:
283 # ------------
284 #
285 # vios#show running-config | section ^interface
286 # interface Loopback24
287 # no ip address
288 # interface GigabitEthernet1
289 # ip address dhcp
290 # negotiation auto
291 # interface GigabitEthernet2
292 # no ip address
293 # shutdown
294 # negotiation auto
295 # interface GigabitEthernet3
296 # no ip address
297 # negotiation auto
298 # interface GigabitEthernet4
299 # no ip address
300 # shutdown
301 # negotiation auto
302
303 # Using gathered
304
305 # Before state:
306 # -------------
307 #
308 # vios#show running-config | section ^interface
309 # interface Loopback24
310 # no ip address
311 # interface GigabitEthernet1
312 # ip address dhcp
313 # negotiation auto
314 # interface GigabitEthernet2
315 # vrf forwarding vrf_B
316 # no ip address
317 # shutdown
318 # negotiation auto
319 # interface GigabitEthernet3
320 # no ip address
321 # negotiation auto
322 # interface GigabitEthernet4
323 # no ip address
324 # shutdown
325 # negotiation auto
326
327 - name: Gather listed VRF interfaces
328 cisco.ios.ios_vrf_interfaces:
329 state: gathered
330
331 # Task Output:
332 # ------------
333 #
334 # gathered:
335 # - name: "Loopback24"
336 # - name: "GigabitEthernet1"
337 # - name: "GigabitEthernet2"
338 # vrf_name: "vrf_B"
339 # - name: "GigabitEthernet3"
340 # - name: "GigabitEthernet4"
341
342 # Using rendered
343
344 - name: Render VRF configuration
345 cisco.ios.ios_vrf_interfaces:
346 config:
347 - name: GigabitEthernet1
348 - name: GigabitEthernet2
349 vrf_name: vrf_D
350 - name: GigabitEthernet3
351 - name: GigabitEthernet4
352 state: rendered
353
354 # Task Output:
355 # ------------
356 #
357 # rendered:
358 # - interface GigabitEthernet2
359 # - vrf forwarding vrf_D
360
361 # Using parsed
362
363 # File: parsed.cfg
364 # ---------------
365 #
366 # interface GigabitEthernet1
367 # vrf vrf_C
368 # shutdown
369 # !
370 # interface GigabitEthernet2
371 # vrf vrf_D
372 # shutdown
373 # !
374 # interface GigabitEthernet3
375 # shutdown
376 # !
377 # interface GigabitEthernet4
378 # shutdown
379 # !
380
381 - name: Parse configuration from device running config
382 cisco.ios.ios_vrf_interfaces:
383 running_config: "{{ lookup('file', 'parsed.cfg') }}"
384 state: parsed
385
386 # Task Output:
387 # ------------
388 #
389 # parsed:
390 # - name: "GigabitEthernet1"
391 # vrf_name: "vrf_C"
392 # - name: "GigabitEthernet2"
393 # vrf_name: "vrf_D"
394 # - name: "GigabitEthernet3"
395 # - name: "GigabitEthernet4"
396
397 # Using replaced
398
399 # Before state:
400 # -------------
401 #
402 # vios#show running-config | section ^interface
403 # interface Loopback24
404 # no ip address
405 # interface GigabitEthernet1
406 # vrf forwarding vrf_A
407 # ip address dhcp
408 # negotiation auto
409 # interface GigabitEthernet2
410 # vrf forwarding vrf_B
411 # no ip address
412 # shutdown
413 # negotiation auto
414 # interface GigabitEthernet3
415 # no ip address
416 # negotiation auto
417 # interface GigabitEthernet4
418 # vrf forwarding vrf_C
419 # no ip address
420 # shutdown
421 # negotiation auto
422
423 - name: Replace device configuration of listed VRF interfaces with provided configuration
424 cisco.ios.ios_vrf_interfaces:
425 config:
426 - name: GigabitEthernet1
427 vrf_name: vrf_D
428 - name: GigabitEthernet2
429 vrf_name: vrf_E
430 state: replaced
431
432 # Task Output:
433 # ------------
434 #
435 # before:
436 # - name: "Loopback24"
437 # - name: "GigabitEthernet1"
438 # vrf_name: "vrf_A"
439 # - name: "GigabitEthernet2"
440 # vrf_name: "vrf_B"
441 # - name: "GigabitEthernet3"
442 # - name: "GigabitEthernet4"
443 # vrf_name: "vrf_C"
444 #
445 # commands:
446 # - interface GigabitEthernet1
447 # - no vrf forwarding vrf_A
448 # - vrf forwarding vrf_D
449 # - interface GigabitEthernet2
450 # - no vrf forwarding vrf_B
451 # - vrf forwarding vrf_E
452 #
453 # after:
454 # - name: "Loopback24"
455 # - name: "GigabitEthernet1"
456 # vrf_name: "vrf_D"
457 # - name: "GigabitEthernet2"
458 # vrf_name: "vrf_E"
459 # - name: "GigabitEthernet3"
460 # - name: "GigabitEthernet4"
461 # vrf_name: "vrf_C"
462
463 # Using deleted
464
465 # Before state:
466 # -------------
467 #
468 # vios#show running-config | section ^interface
469 # interface Loopback24
470 # no ip address
471 # interface GigabitEthernet1
472 # vrf forwarding vrf_A
473 # ip address dhcp
474 # negotiation auto
475 # interface GigabitEthernet2
476 # vrf forwarding vrf_B
477 # no ip address
478 # shutdown
479 # negotiation auto
480 # interface GigabitEthernet3
481 # no ip address
482 # negotiation auto
483 # interface GigabitEthernet4
484 # vrf forwarding vrf_C
485 # no ip address
486 # shutdown
487 # negotiation auto
488
489 - name: Delete VRF configuration of specified interfaces
490 cisco.ios.ios_vrf_interfaces:
491 config:
492 - name: GigabitEthernet1
493 - name: GigabitEthernet2
494 state: deleted
495
496 # Task Output:
497 # ------------
498 #
499 # before:
500 # - name: "Loopback24"
501 # - name: "GigabitEthernet1"
502 # vrf_name: "vrf_A"
503 # - name: "GigabitEthernet2"
504 # vrf_name: "vrf_B"
505 # - name: "GigabitEthernet3"
506 # - name: "GigabitEthernet4"
507 # vrf_name: "vrf_C"
508 #
509 # commands:
510 # - interface GigabitEthernet1
511 # - no vrf forwarding vrf_A
512 # - interface GigabitEthernet2
513 # - no vrf forwarding vrf_B
514 #
515 # after:
516 # - name: "Loopback24"
517 # - name: "GigabitEthernet1"
518 # - name: "GigabitEthernet2"
519 # - name: "GigabitEthernet3"
520 # - name: "GigabitEthernet4"
521 # vrf_name: "vrf_C"
522
523 # After state:
524 # ------------
525 #
526 # vios#show running-config | section ^interface
527 # interface Loopback24
528 # no ip address
529 # interface GigabitEthernet1
530 # ip address dhcp
531 # negotiation auto
532 # interface GigabitEthernet2
533 # no ip address
534 # shutdown
535 # negotiation auto
536 # interface GigabitEthernet3
537 # no ip address
538 # negotiation auto
539 # interface GigabitEthernet4
540 # vrf forwarding vrf_C
541 # no ip address
542 # shutdown
543 # negotiation auto
544
545
546
547 Return Values
548 -------------
549 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:
550
551 .. raw:: html
552
553 <table border=0 cellpadding=0 class="documentation-table">
554 <tr>
555 <th colspan="1">Key</th>
556 <th>Returned</th>
557 <th width="100%">Description</th>
558 </tr>
559 <tr>
560 <td colspan="1">
561 <div class="ansibleOptionAnchor" id="return-"></div>
562 <b>after</b>
563 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
564 <div style="font-size: small">
565 <span style="color: purple">list</span>
566 </div>
567 </td>
568 <td>when changed</td>
569 <td>
570 <div>The resulting configuration after module execution.</div>
571 <br/>
572 <div style="font-size: smaller"><b>Sample:</b></div>
573 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[
574 {
575 &quot;name&quot;: &quot;Loopback24&quot;
576 },
577 {
578 &quot;name&quot;: &quot;GigabitEthernet1&quot;
579 },
580 {
581 &quot;name&quot;: &quot;GigabitEthernet2&quot;,
582 &quot;vrf_name&quot;: &quot;vrf_D&quot;
583 },
584 {
585 &quot;name&quot;: &quot;GigabitEthernet3&quot;
586 },
587 {
588 &quot;name&quot;: &quot;GigabitEthernet4&quot;
589 }
590 ]</div>
591 </td>
592 </tr>
593 <tr>
594 <td colspan="1">
595 <div class="ansibleOptionAnchor" id="return-"></div>
596 <b>before</b>
597 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
598 <div style="font-size: small">
599 <span style="color: purple">list</span>
600 </div>
601 </td>
602 <td>when <em>state</em> is <code>merged</code>, <code>replaced</code>, <code>overridden</code>, <code>deleted</code></td>
603 <td>
604 <div>The configuration prior to the module execution.</div>
605 <br/>
606 <div style="font-size: smaller"><b>Sample:</b></div>
607 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[
608 {
609 &quot;name&quot;: &quot;Loopback24&quot;
610 },
611 {
612 &quot;name&quot;: &quot;GigabitEthernet1&quot;
613 },
614 {
615 &quot;name&quot;: &quot;GigabitEthernet2&quot;,
616 &quot;vrf_name&quot;: &quot;vrf_B&quot;
617 },
618 {
619 &quot;name&quot;: &quot;GigabitEthernet3&quot;
620 },
621 {
622 &quot;name&quot;: &quot;GigabitEthernet4&quot;
623 }
624 ]</div>
625 </td>
626 </tr>
627 <tr>
628 <td colspan="1">
629 <div class="ansibleOptionAnchor" id="return-"></div>
630 <b>commands</b>
631 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
632 <div style="font-size: small">
633 <span style="color: purple">list</span>
634 </div>
635 </td>
636 <td>when <em>state</em> is <code>merged</code>, <code>replaced</code>, <code>overridden</code>, <code>deleted</code></td>
637 <td>
638 <div>The set of commands pushed to the remote device.</div>
639 <br/>
640 <div style="font-size: smaller"><b>Sample:</b></div>
641 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;interface GigabitEthernet2&#x27;, &#x27;vrf forwarding vrf_D&#x27;, &#x27;no vrf forwarding vrf_B&#x27;]</div>
642 </td>
643 </tr>
644 <tr>
645 <td colspan="1">
646 <div class="ansibleOptionAnchor" id="return-"></div>
647 <b>gathered</b>
648 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
649 <div style="font-size: small">
650 <span style="color: purple">list</span>
651 </div>
652 </td>
653 <td>when <em>state</em> is <code>gathered</code></td>
654 <td>
655 <div>Facts about the network resource gathered from the remote device as structured data.</div>
656 <br/>
657 <div style="font-size: smaller"><b>Sample:</b></div>
658 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[
659 {
660 &quot;name&quot;: &quot;Loopback24&quot;
661 },
662 {
663 &quot;name&quot;: &quot;GigabitEthernet1&quot;
664 },
665 {
666 &quot;name&quot;: &quot;GigabitEthernet2&quot;,
667 &quot;vrf_name&quot;: &quot;vrf_B&quot;
668 },
669 {
670 &quot;name&quot;: &quot;GigabitEthernet3&quot;
671 },
672 {
673 &quot;name&quot;: &quot;GigabitEthernet4&quot;
674 }
675 ]</div>
676 </td>
677 </tr>
678 <tr>
679 <td colspan="1">
680 <div class="ansibleOptionAnchor" id="return-"></div>
681 <b>parsed</b>
682 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
683 <div style="font-size: small">
684 <span style="color: purple">list</span>
685 </div>
686 </td>
687 <td>when <em>state</em> is <code>parsed</code></td>
688 <td>
689 <div>The device native config provided in <em>running_config</em> option parsed into structured data as per module argspec.</div>
690 <br/>
691 <div style="font-size: smaller"><b>Sample:</b></div>
692 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[
693 {
694 &quot;name&quot;: &quot;GigabitEthernet1&quot;,
695 &quot;vrf_name&quot;: &quot;vrf_C&quot;
696 },
697 {
698 &quot;name&quot;: &quot;GigabitEthernet2&quot;,
699 &quot;vrf_name&quot;: &quot;vrf_D&quot;
700 },
701 {
702 &quot;name&quot;: &quot;GigabitEthernet3&quot;
703 },
704 {
705 &quot;name&quot;: &quot;GigabitEthernet4&quot;
706 }
707 ]</div>
708 </td>
709 </tr>
710 <tr>
711 <td colspan="1">
712 <div class="ansibleOptionAnchor" id="return-"></div>
713 <b>rendered</b>
714 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
715 <div style="font-size: small">
716 <span style="color: purple">list</span>
717 </div>
718 </td>
719 <td>when <em>state</em> is <code>rendered</code></td>
720 <td>
721 <div>The provided configuration in the task rendered in device-native format (offline).</div>
722 <br/>
723 <div style="font-size: smaller"><b>Sample:</b></div>
724 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;interface GigabitEthernet1&#x27;, &#x27;vrf forwarding vrf_C&#x27;, &#x27;interface GigabitEthernet2&#x27;, &#x27;vrf forwarding vrf_D&#x27;]</div>
725 </td>
726 </tr>
727 </table>
728 <br/><br/>
729
730
731 Status
732 ------
733
734
735 Authors
736 ~~~~~~~
737
738 - AAYUSH ANAND (@AAYUSH2091)