Debian Codegraph @

ansible_collections/cisco/iosxr/docs/cisco.iosxr.iosxr_interfaces_module.rst

raw
1 .. _cisco.iosxr.iosxr_interfaces_module:
2
3
4 ****************************
5 cisco.iosxr.iosxr_interfaces
6 ****************************
7
8 **Resource module to configure interfaces.**
9
10
11 Version added: 1.0.0
12
13 .. contents::
14 :local:
15 :depth: 1
16
17
18 Synopsis
19 --------
20 - This module manages the interface attributes on Cisco IOS-XR network 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 dictionary of interface options</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>description</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 </div>
61 </td>
62 <td>
63 </td>
64 <td>
65 <div>Interface description.</div>
66 </td>
67 </tr>
68 <tr>
69 <td class="elbow-placeholder"></td>
70 <td colspan="1">
71 <div class="ansibleOptionAnchor" id="parameter-"></div>
72 <b>duplex</b>
73 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
74 <div style="font-size: small">
75 <span style="color: purple">string</span>
76 </div>
77 </td>
78 <td>
79 <ul style="margin: 0; padding: 0"><b>Choices:</b>
80 <li>full</li>
81 <li>half</li>
82 </ul>
83 </td>
84 <td>
85 <div>Configures the interface duplex mode. Default is auto-negotiation when not configured.</div>
86 </td>
87 </tr>
88 <tr>
89 <td class="elbow-placeholder"></td>
90 <td colspan="1">
91 <div class="ansibleOptionAnchor" id="parameter-"></div>
92 <b>enabled</b>
93 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
94 <div style="font-size: small">
95 <span style="color: purple">boolean</span>
96 </div>
97 </td>
98 <td>
99 <ul style="margin: 0; padding: 0"><b>Choices:</b>
100 <li>no</li>
101 <li>yes</li>
102 </ul>
103 </td>
104 <td>
105 <div>Administrative state of the interface.</div>
106 <div>Set the value to <code>True</code> to administratively enable the interface or <code>False</code> to disable it.</div>
107 </td>
108 </tr>
109 <tr>
110 <td class="elbow-placeholder"></td>
111 <td colspan="1">
112 <div class="ansibleOptionAnchor" id="parameter-"></div>
113 <b>mtu</b>
114 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
115 <div style="font-size: small">
116 <span style="color: purple">integer</span>
117 </div>
118 </td>
119 <td>
120 </td>
121 <td>
122 <div>Sets the MTU value for the interface. Applicable for Ethernet interfaces only.</div>
123 <div>Refer to vendor documentation for valid values.</div>
124 </td>
125 </tr>
126 <tr>
127 <td class="elbow-placeholder"></td>
128 <td colspan="1">
129 <div class="ansibleOptionAnchor" id="parameter-"></div>
130 <b>name</b>
131 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
132 <div style="font-size: small">
133 <span style="color: purple">string</span>
134 / <span style="color: red">required</span>
135 </div>
136 </td>
137 <td>
138 </td>
139 <td>
140 <div>Full name of the interface to configure in <code>type + path</code> format. e.g. <code>GigabitEthernet0/0/0/0</code></div>
141 </td>
142 </tr>
143 <tr>
144 <td class="elbow-placeholder"></td>
145 <td colspan="1">
146 <div class="ansibleOptionAnchor" id="parameter-"></div>
147 <b>speed</b>
148 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
149 <div style="font-size: small">
150 <span style="color: purple">integer</span>
151 </div>
152 </td>
153 <td>
154 </td>
155 <td>
156 <div>Configure the speed for an interface. Default is auto-negotiation when not configured.</div>
157 </td>
158 </tr>
159
160 <tr>
161 <td colspan="2">
162 <div class="ansibleOptionAnchor" id="parameter-"></div>
163 <b>running_config</b>
164 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
165 <div style="font-size: small">
166 <span style="color: purple">string</span>
167 </div>
168 </td>
169 <td>
170 </td>
171 <td>
172 <div>This option is used only with state <em>parsed</em>.</div>
173 <div>The value of this option should be the output received from the IOS-XR device by executing the command <b>show running-config interface</b>.</div>
174 <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>
175 </td>
176 </tr>
177 <tr>
178 <td colspan="2">
179 <div class="ansibleOptionAnchor" id="parameter-"></div>
180 <b>state</b>
181 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
182 <div style="font-size: small">
183 <span style="color: purple">string</span>
184 </div>
185 </td>
186 <td>
187 <ul style="margin: 0; padding: 0"><b>Choices:</b>
188 <li><div style="color: blue"><b>merged</b>&nbsp;&larr;</div></li>
189 <li>parsed</li>
190 <li>deleted</li>
191 <li>replaced</li>
192 <li>rendered</li>
193 <li>gathered</li>
194 <li>overridden</li>
195 </ul>
196 </td>
197 <td>
198 <div>The state of the configuration after module completion</div>
199 </td>
200 </tr>
201 </table>
202 <br/>
203
204
205 Notes
206 -----
207
208 .. note::
209 - This module works with connection ``network_cli``. See https://docs.ansible.com/ansible/latest/network/user_guide/platform_iosxr.html
210 - The module examples uses callback plugin (stdout_callback = yaml) to generate task output in yaml format.
211
212
213
214 Examples
215 --------
216
217 .. code-block:: yaml
218
219 # Using merged
220
221 # Before state:
222 # -------------
223 #
224 # viosxr#show running-config interface
225 # interface Loopback888
226 # !
227 # interface Loopback999
228 # !
229 # interface MgmtEth0/RP0/CPU0/0
230 # ipv4 address dhcp
231 # !
232
233 - name: Configure Ethernet interfaces
234 cisco.iosxr.iosxr_interfaces:
235 config:
236 - name: GigabitEthernet0/0/0/2
237 description: Configured by Ansible
238 enabled: true
239 - name: GigabitEthernet0/0/0/3
240 description: Configured by Ansible Network
241 enabled: false
242 duplex: full
243 state: merged
244
245 # Task Output
246 # -----------
247 #
248 # before:
249 # - enabled: true
250 # name: Loopback888
251 # - enabled: true
252 # name: Loopback999
253 # commands:
254 # - interface GigabitEthernet0/0/0/2
255 # - description Configured by Ansible
256 # - no shutdown
257 # - interface GigabitEthernet0/0/0/3
258 # - description Configured by Ansible Network
259 # - duplex full
260 # - shutdown
261 # after:
262 # - enabled: true
263 # name: Loopback888
264 # - enabled: true
265 # name: Loopback999
266 # - description: Configured by Ansible
267 # enabled: true
268 # name: GigabitEthernet0/0/0/2
269 # - description: Configured by Ansible Network
270 # duplex: full
271 # enabled: false
272 # name: GigabitEthernet0/0/0/3
273
274 # After state:
275 # ------------
276 #
277 # viosxr#show running-config interface
278 # interface Loopback888
279 # !
280 # interface Loopback999
281 # !
282 # interface MgmtEth0/RP0/CPU0/0
283 # ipv4 address dhcp
284 # !
285 # interface preconfigure GigabitEthernet0/0/0/2
286 # description Configured by Ansible
287 # !
288 # interface preconfigure GigabitEthernet0/0/0/3
289 # description Configured by Ansible Network
290 # duplex full
291 # shutdown
292 # !
293
294 # Using replaced
295
296 # Before state:
297 # ------------
298 #
299 # viosxr#show running-config interface
300 # interface Loopback888
301 # !
302 # interface Loopback999
303 # !
304 # interface MgmtEth0/RP0/CPU0/0
305 # ipv4 address dhcp
306 # !
307 # interface preconfigure GigabitEthernet0/0/0/2
308 # description Configured by Ansible
309 # !
310 # interface preconfigure GigabitEthernet0/0/0/3
311 # description Configured by Ansible Network
312 # duplex full
313 # shutdown
314 # !
315
316 - name: Replace their existing configuration per interface
317 cisco.iosxr.iosxr_interfaces:
318 config:
319 - name: GigabitEthernet0/0/0/2
320 description: Configured by Ansible
321 enabled: true
322 mtu: 2000
323 - name: GigabitEthernet0/0/0/3
324 description: Configured by Ansible Network
325 enabled: false
326 duplex: auto
327 state: replaced
328
329 # Task Output
330 # -----------
331 #
332 # before:
333 # - enabled: true
334 # name: Loopback888
335 # - enabled: true
336 # name: Loopback999
337 # - description: Configured by Ansible
338 # enabled: true
339 # name: GigabitEthernet0/0/0/2
340 # - description: Configured by Ansible Network
341 # duplex: full
342 # enabled: false
343 # name: GigabitEthernet0/0/0/3
344 # commands:
345 # - interface GigabitEthernet0/0/0/2
346 # - mtu 2000
347 # - interface GigabitEthernet0/0/0/3
348 # - duplex half
349 # after:
350 # - enabled: true
351 # name: Loopback888
352 # - enabled: true
353 # name: Loopback999
354 # - description: Configured by Ansible
355 # enabled: true
356 # mtu: 2000
357 # name: GigabitEthernet0/0/0/2
358 # - description: Configured by Ansible Network
359 # duplex: half
360 # enabled: false
361 # name: GigabitEthernet0/0/0/3
362
363 # After state:
364 # ------------
365 #
366 # viosxr#show running-config interface
367 # interface Loopback888
368 # !
369 # interface Loopback999
370 # !
371 # interface MgmtEth0/RP0/CPU0/0
372 # ipv4 address dhcp
373 # !
374 # interface preconfigure GigabitEthernet0/0/0/2
375 # description Configured by Ansible
376 # mtu 2000
377 # !
378 # interface preconfigure GigabitEthernet0/0/0/3
379 # description Configured by Ansible Network
380 # duplex half
381 # shutdown
382 # !
383
384 # Using overridden
385
386 # Before state:
387 # ------------
388 #
389 # viosxr#show running-config interface
390 # interface Loopback888
391 # !
392 # interface Loopback999
393 # !
394 # interface MgmtEth0/RP0/CPU0/0
395 # ipv4 address dhcp
396 # !
397 # interface preconfigure GigabitEthernet0/0/0/2
398 # description Configured by Ansible
399 # mtu 2000
400 # !
401 # interface preconfigure GigabitEthernet0/0/0/3
402 # description Configured by Ansible Network
403 # duplex half
404 # shutdown
405 # !
406
407 - name: Override interfaces configuration
408 cisco.iosxr.iosxr_interfaces:
409 config:
410 - name: GigabitEthernet0/0/0/2
411 description: Configured by Ansible
412 enabled: true
413 duplex: auto
414 - name: GigabitEthernet0/0/0/3
415 description: Configured by Ansible Network
416 enabled: false
417 speed: 1000
418 state: overridden
419
420 # Task Output
421 # -----------
422 #
423 # before:
424 # - enabled: true
425 # name: Loopback888
426 # - enabled: true
427 # name: Loopback999
428 # - description: Configured by Ansible
429 # enabled: true
430 # mtu: 2000
431 # name: GigabitEthernet0/0/0/2
432 # - description: Configured by Ansible Network
433 # duplex: half
434 # enabled: false
435 # name: GigabitEthernet0/0/0/3
436 # commands:
437 # - interface GigabitEthernet0/0/0/2
438 # - no mtu
439 # - duplex half
440 # - interface GigabitEthernet0/0/0/3
441 # - no description
442 # - no shutdown
443 # - no duplex
444 # after:
445 # - enabled: true
446 # name: Loopback888
447 # - enabled: true
448 # name: Loopback999
449 # - description: Configured by Ansible
450 # duplex: half
451 # enabled: true
452 # name: GigabitEthernet0/0/0/2
453 # - enabled: true
454 # name: GigabitEthernet0/0/0/3
455
456 # After state:
457 # ------------
458 #
459 # viosxr#show running-config interface
460 # interface Loopback888
461 # !
462 # interface Loopback999
463 # !
464 # interface MgmtEth0/RP0/CPU0/0
465 # ipv4 address dhcp
466 # !
467 # interface preconfigure GigabitEthernet0/0/0/2
468 # description Configured by Ansible
469 # duplex half
470 # !
471 # interface preconfigure GigabitEthernet0/0/0/3
472 # !
473
474 # Using deleted
475
476 # Before state:
477 # ------------
478 #
479 # viosxr#show running-config interface
480 # interface Loopback888
481 # !
482 # interface Loopback999
483 # !
484 # interface MgmtEth0/RP0/CPU0/0
485 # ipv4 address dhcp
486 # !
487 # interface preconfigure GigabitEthernet0/0/0/2
488 # description Configured by Ansible
489 # duplex half
490 # !
491 # interface preconfigure GigabitEthernet0/0/0/3
492 # !
493
494 - name: Delete interfaces arguments
495 cisco.iosxr.iosxr_interfaces:
496 config:
497 - name: GigabitEthernet0/0/0/2
498 - name: GigabitEthernet0/0/0/3
499 state: deleted
500
501 # Task Output
502 # -----------
503 #
504 # before:
505 # - enabled: true
506 # name: Loopback888
507 # - enabled: true
508 # name: Loopback999
509 # - description: Configured by Ansible
510 # duplex: half
511 # enabled: true
512 # name: GigabitEthernet0/0/0/2
513 # - enabled: true
514 # name: GigabitEthernet0/0/0/3
515 # commands:
516 # - interface GigabitEthernet0/0/0/2
517 # - no description
518 # - no duplex
519 # after:
520 # - enabled: true
521 # name: Loopback888
522 # - enabled: true
523 # name: Loopback999
524 # - enabled: true
525 # name: GigabitEthernet0/0/0/2
526 # - enabled: true
527 # name: GigabitEthernet0/0/0/3
528
529 # After state:
530 # ------------
531 #
532 # viosxr#show running-config interface
533 # interface Loopback888
534 # !
535 # interface Loopback999
536 # !
537 # interface MgmtEth0/RP0/CPU0/0
538 # ipv4 address dhcp
539 # !
540 # interface preconfigure GigabitEthernet0/0/0/2
541 # !
542 # interface preconfigure GigabitEthernet0/0/0/3
543 # !
544
545 # Using parsed
546
547 # File: parsed.cfg
548 # ----------------
549 #
550 # interface Loopback888
551 # description test for ansible
552 # shutdown
553 # !
554 # interface MgmtEth0/0/CPU0/0
555 # ipv4 address 10.8.38.70 255.255.255.0
556 # !
557 # interface GigabitEthernet0/0/0/0
558 # description Configured and Merged by Ansible-Network
559 # mtu 110
560 # ipv4 address 172.31.1.1 255.255.255.0
561 # duplex half
562 # !
563 # interface GigabitEthernet0/0/0/3
564 # shutdown
565 # !
566 # interface GigabitEthernet0/0/0/4
567 # shutdown
568 # !
569
570 # - name: Parse provided configuration
571 # cisco.iosxr.iosxr_interfaces:
572 # running_config: "{{ lookup('file', './parsed.cfg') }}"
573 # state: parsed
574
575 # Task Output
576 # -----------
577 #
578 # parsed:
579 # - name: MgmtEth0/RP0/CPU0/0
580 # - access_groups:
581 # - acls:
582 # - direction: in
583 # name: acl_1
584 # - direction: out
585 # name: acl_2
586 # afi: ipv4
587 # - acls:
588 # - direction: in
589 # name: acl6_1
590 # - direction: out
591 # name: acl6_2
592 # afi: ipv6
593 # name: GigabitEthernet0/0/0/0
594 # - access_groups:
595 # - acls:
596 # - direction: out
597 # name: acl_1
598 # afi: ipv4
599 # name: GigabitEthernet0/0/0/1
600
601
602 # Using rendered
603
604 - name: Render platform specific commands from task input using rendered state
605 cisco.iosxr.iosxr_interfaces:
606 config:
607 - name: GigabitEthernet0/0/0/0
608 description: Configured and Merged by Ansible-Network
609 mtu: 110
610 enabled: true
611 duplex: half
612 - name: GigabitEthernet0/0/0/1
613 description: Configured and Merged by Ansible-Network
614 mtu: 2800
615 enabled: false
616 speed: 100
617 duplex: full
618 state: rendered
619
620 # Task Output
621 # -----------
622 #
623 # rendered:
624 # - interface GigabitEthernet0/0/0/0
625 # - description Configured and Merged by Ansible-Network
626 # - mtu 110
627 # - duplex half
628 # - no shutdown
629 # - interface GigabitEthernet0/0/0/1
630 # - description Configured and Merged by Ansible-Network
631 # - mtu 2800
632 # - speed 100
633 # - duplex full
634 # - shutdown
635
636
637 # Using gathered
638
639 # Before state:
640 # ------------
641 #
642 # RP/0/0/CPU0:an-iosxr-02#show running-config interface
643 # interface Loopback888
644 # description test for ansible
645 # shutdown
646 # !
647 # interface MgmtEth0/0/CPU0/0
648 # ipv4 address 10.8.38.70 255.255.255.0
649 # !
650 # interface GigabitEthernet0/0/0/0
651 # description Configured and Merged by Ansible-Network
652 # mtu 110
653 # ipv4 address 172.31.1.1 255.255.255.0
654 # duplex half
655 # !
656 # interface GigabitEthernet0/0/0/3
657 # shutdown
658 # !
659 # interface GigabitEthernet0/0/0/4
660 # shutdown
661 # !
662
663 - name: Gather facts for interfaces
664 cisco.iosxr.iosxr_interfaces:
665 config:
666 state: gathered
667
668 # Task Output
669 # -----------
670 #
671 # gathered:
672 # - description: test for ansible
673 # enabled: false
674 # name: Loopback888
675 # - description: Configured and Merged by Ansible-Network
676 # duplex: half
677 # enabled: true
678 # mtu: 110
679 # name: GigabitEthernet0/0/0/0
680 # - enabled: false
681 # name: GigabitEthernet0/0/0/3
682 # - enabled: false
683 # name: GigabitEthernet0/0/0/4
684
685
686
687 Return Values
688 -------------
689 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:
690
691 .. raw:: html
692
693 <table border=0 cellpadding=0 class="documentation-table">
694 <tr>
695 <th colspan="1">Key</th>
696 <th>Returned</th>
697 <th width="100%">Description</th>
698 </tr>
699 <tr>
700 <td colspan="1">
701 <div class="ansibleOptionAnchor" id="return-"></div>
702 <b>after</b>
703 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
704 <div style="font-size: small">
705 <span style="color: purple">list</span>
706 </div>
707 </td>
708 <td>when changed</td>
709 <td>
710 <div>The configuration as structured data after module completion.</div>
711 <br/>
712 <div style="font-size: smaller"><b>Sample:</b></div>
713 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format of the parameters above.</div>
714 </td>
715 </tr>
716 <tr>
717 <td colspan="1">
718 <div class="ansibleOptionAnchor" id="return-"></div>
719 <b>before</b>
720 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
721 <div style="font-size: small">
722 <span style="color: purple">list</span>
723 </div>
724 </td>
725 <td>always</td>
726 <td>
727 <div>The configuration as structured data prior to module invocation.</div>
728 <br/>
729 <div style="font-size: smaller"><b>Sample:</b></div>
730 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format of the parameters above.</div>
731 </td>
732 </tr>
733 <tr>
734 <td colspan="1">
735 <div class="ansibleOptionAnchor" id="return-"></div>
736 <b>commands</b>
737 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
738 <div style="font-size: small">
739 <span style="color: purple">list</span>
740 </div>
741 </td>
742 <td>always</td>
743 <td>
744 <div>The set of commands pushed to the remote device</div>
745 <br/>
746 <div style="font-size: smaller"><b>Sample:</b></div>
747 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;interface GigabitEthernet0/0/0/2&#x27;, &#x27;description: Configured by Ansible&#x27;, &#x27;shutdown&#x27;]</div>
748 </td>
749 </tr>
750 </table>
751 <br/><br/>
752
753
754 Status
755 ------
756
757
758 Authors
759 ~~~~~~~
760
761 - Sumit Jaiswal (@justjais)
762 - Rohit Thakur (@rohitthakur2590)