Debian Codegraph @

ansible_collections/cisco/nxos/docs/cisco.nxos.nxos_vlans_module.rst

raw
1 .. _cisco.nxos.nxos_vlans_module:
2
3
4 *********************
5 cisco.nxos.nxos_vlans
6 *********************
7
8 **VLANs 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 creates and manages VLAN configurations on Cisco NX-OS.
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 Vlan 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>enabled</b>
57 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
58 <div style="font-size: small">
59 <span style="color: purple">boolean</span>
60 </div>
61 </td>
62 <td>
63 <ul style="margin: 0; padding: 0"><b>Choices:</b>
64 <li>no</li>
65 <li>yes</li>
66 </ul>
67 </td>
68 <td>
69 <div>Manage administrative state of the vlan.</div>
70 </td>
71 </tr>
72 <tr>
73 <td class="elbow-placeholder"></td>
74 <td colspan="1">
75 <div class="ansibleOptionAnchor" id="parameter-"></div>
76 <b>mapped_vni</b>
77 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
78 <div style="font-size: small">
79 <span style="color: purple">integer</span>
80 </div>
81 </td>
82 <td>
83 </td>
84 <td>
85 <div>The Virtual Network Identifier (VNI) ID that is mapped to the VLAN.</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>mode</b>
93 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
94 <div style="font-size: small">
95 <span style="color: purple">string</span>
96 </div>
97 </td>
98 <td>
99 <ul style="margin: 0; padding: 0"><b>Choices:</b>
100 <li>ce</li>
101 <li>fabricpath</li>
102 </ul>
103 </td>
104 <td>
105 <div>Set vlan mode to classical ethernet or fabricpath. This is a valid option for Nexus 5000, 6000 and 7000 series.</div>
106 </td>
107 </tr>
108 <tr>
109 <td class="elbow-placeholder"></td>
110 <td colspan="1">
111 <div class="ansibleOptionAnchor" id="parameter-"></div>
112 <b>name</b>
113 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
114 <div style="font-size: small">
115 <span style="color: purple">string</span>
116 </div>
117 </td>
118 <td>
119 </td>
120 <td>
121 <div>Name of VLAN.</div>
122 </td>
123 </tr>
124 <tr>
125 <td class="elbow-placeholder"></td>
126 <td colspan="1">
127 <div class="ansibleOptionAnchor" id="parameter-"></div>
128 <b>state</b>
129 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
130 <div style="font-size: small">
131 <span style="color: purple">string</span>
132 </div>
133 </td>
134 <td>
135 <ul style="margin: 0; padding: 0"><b>Choices:</b>
136 <li>active</li>
137 <li>suspend</li>
138 </ul>
139 </td>
140 <td>
141 <div>Manage operational state of the vlan.</div>
142 </td>
143 </tr>
144 <tr>
145 <td class="elbow-placeholder"></td>
146 <td colspan="1">
147 <div class="ansibleOptionAnchor" id="parameter-"></div>
148 <b>vlan_id</b>
149 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
150 <div style="font-size: small">
151 <span style="color: purple">integer</span>
152 / <span style="color: red">required</span>
153 </div>
154 </td>
155 <td>
156 </td>
157 <td>
158 <div>Vlan ID.</div>
159 </td>
160 </tr>
161
162 <tr>
163 <td colspan="2">
164 <div class="ansibleOptionAnchor" id="parameter-"></div>
165 <b>running_config</b>
166 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
167 <div style="font-size: small">
168 <span style="color: purple">string</span>
169 </div>
170 </td>
171 <td>
172 </td>
173 <td>
174 <div>This option is used only with state <em>parsed</em>.</div>
175 <div>The value of this option should be the output received from the NX-OS device by executing the commands <b>show vlans | json-pretty</b> and <b>show running-config | section ^vlan</b> in order and delimited by a line.</div>
176 <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>
177 </td>
178 </tr>
179 <tr>
180 <td colspan="2">
181 <div class="ansibleOptionAnchor" id="parameter-"></div>
182 <b>state</b>
183 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
184 <div style="font-size: small">
185 <span style="color: purple">string</span>
186 </div>
187 </td>
188 <td>
189 <ul style="margin: 0; padding: 0"><b>Choices:</b>
190 <li><div style="color: blue"><b>merged</b>&nbsp;&larr;</div></li>
191 <li>replaced</li>
192 <li>overridden</li>
193 <li>deleted</li>
194 <li>gathered</li>
195 <li>rendered</li>
196 <li>parsed</li>
197 </ul>
198 </td>
199 <td>
200 <div>The state of the configuration after module completion.</div>
201 <div>The state <em>overridden</em> would override the configuration of all the VLANs on the device (including VLAN 1) with the provided configuration in the task. Use caution with this state.</div>
202 </td>
203 </tr>
204 </table>
205 <br/>
206
207
208 Notes
209 -----
210
211 .. note::
212 - Tested against NXOS 7.3.(0)D1(1) on VIRL
213 - Unsupported for Cisco MDS
214
215
216
217 Examples
218 --------
219
220 .. code-block:: yaml
221
222 # Using merged
223
224 # Before state:
225 # -------------
226 # vlan 1
227
228 - name: Merge provided configuration with device configuration.
229 cisco.nxos.nxos_vlans:
230 config:
231 - vlan_id: 5
232 name: test-vlan5
233 - vlan_id: 10
234 enabled: false
235 state: merged
236
237 # After state:
238 # ------------
239 # vlan 5
240 # name test-vlan5
241 # state active
242 # no shutdown
243 # vlan 10
244 # state active
245 # shutdown
246
247
248 # Using replaced
249
250 # Before state:
251 # -------------
252 # vlan 1
253 # vlan 5
254 # name test-vlan5
255 # vlan 10
256 # shutdown
257
258 - name: Replace device configuration of specified vlan with provided configuration.
259 cisco.nxos.nxos_vlans:
260 config:
261 - vlan_id: 5
262 name: test-vlan
263 enabled: false
264 - vlan_id: 10
265 enabled: false
266 state: replaced
267
268 # After state:
269 # ------------
270 # vlan 1
271 # vlan 5
272 # name test-vlan
273 # state active
274 # shutdown
275 # vlan 10
276 # state active
277 # shutdown
278
279
280 # Using overridden
281
282 # Before state:
283 # -------------
284 # vlan 1
285 # vlan 3
286 # name testing
287 # vlan 5
288 # name test-vlan5
289 # shutdown
290 # vlan 10
291 # shutdown
292
293 - name: Override device configuration of all vlans with provided configuration.
294 cisco.nxos.nxos_vlans:
295 config:
296 - vlan_id: 5
297 name: test-vlan
298 - vlan_id: 10
299 state: active
300 state: overridden
301
302 # After state:
303 # ------------
304 # vlan 5
305 # name test-vlan
306 # state active
307 # no shutdown
308 # vlan 10
309 # state active
310 # no shutdown
311
312
313 # Using deleted
314
315 # Before state:
316 # -------------
317 # vlan 1
318 # vlan 5
319 # vlan 10
320
321 - name: Delete vlans.
322 cisco.nxos.nxos_vlans:
323 config:
324 - vlan_id: 5
325 - vlan_id: 10
326 state: deleted
327
328 # After state:
329 # ------------
330 #
331
332 # Using rendered
333
334 - name: Use rendered state to convert task input to device specific commands
335 cisco.nxos.nxos_vlans:
336 config:
337 - vlan_id: 5
338 name: vlan5
339 mapped_vni: 100
340
341 - vlan_id: 6
342 name: vlan6
343 state: suspend
344 state: rendered
345
346 # Task Output (redacted)
347 # -----------------------
348
349 # rendered:
350 # - vlan 5
351 # - name vlan5
352 # - vn-segment 100
353 # - vlan 6
354 # - name vlan6
355 # - state suspend
356
357 # Using parsed
358
359 # parsed.cfg
360 # ------------
361 # {
362 # "TABLE_vlanbrief": {
363 # "ROW_vlanbrief": [
364 # {
365 # "vlanshowbr-vlanid": "1",
366 # "vlanshowbr-vlanid-utf": "1",
367 # "vlanshowbr-vlanname": "default",
368 # "vlanshowbr-vlanstate": "active",
369 # "vlanshowbr-shutstate": "noshutdown"
370 # },
371 # {
372 # "vlanshowbr-vlanid": "5",
373 # "vlanshowbr-vlanid-utf": "5",
374 # "vlanshowbr-vlanname": "vlan5",
375 # "vlanshowbr-vlanstate": "suspend",
376 # "vlanshowbr-shutstate": "noshutdown"
377 # },
378 # {
379 # "vlanshowbr-vlanid": "6",
380 # "vlanshowbr-vlanid-utf": "6",
381 # "vlanshowbr-vlanname": "VLAN0006",
382 # "vlanshowbr-vlanstate": "active",
383 # "vlanshowbr-shutstate": "noshutdown"
384 # },
385 # {
386 # "vlanshowbr-vlanid": "7",
387 # "vlanshowbr-vlanid-utf": "7",
388 # "vlanshowbr-vlanname": "vlan7",
389 # "vlanshowbr-vlanstate": "active",
390 # "vlanshowbr-shutstate": "noshutdown"
391 # }
392 # ]
393 # },
394 # "TABLE_mtuinfo": {
395 # "ROW_mtuinfo": [
396 # {
397 # "vlanshowinfo-vlanid": "1",
398 # "vlanshowinfo-media-type": "enet",
399 # "vlanshowinfo-vlanmode": "ce-vlan"
400 # },
401 # {
402 # "vlanshowinfo-vlanid": "5",
403 # "vlanshowinfo-media-type": "enet",
404 # "vlanshowinfo-vlanmode": "ce-vlan"
405 # },
406 # {
407 # "vlanshowinfo-vlanid": "6",
408 # "vlanshowinfo-media-type": "enet",
409 # "vlanshowinfo-vlanmode": "ce-vlan"
410 # },
411 # {
412 # "vlanshowinfo-vlanid": "7",
413 # "vlanshowinfo-media-type": "enet",
414 # "vlanshowinfo-vlanmode": "ce-vlan"
415 # }
416 # ]
417 # }
418 # }
419 #
420 # vlan 1,5-7
421 # vlan 5
422 # state suspend
423 # name vlan5
424 # vlan 7
425 # name vlan7
426 # vn-segment 100
427
428 - name: Use parsed state to convert externally supplied config to structured format
429 cisco.nxos.nxos_vlans:
430 running_config: "{{ lookup('file', 'parsed.cfg') }}"
431 state: parsed
432
433 # Task output (redacted)
434 # -----------------------
435
436 # parsed:
437 # - vlan_id: 5
438 # enabled: True
439 # mode: "ce"
440 # name: "vlan5"
441 # state: suspend
442 #
443 # - vlan_id: 6
444 # enabled: True
445 # mode: "ce"
446 # state: active
447 #
448 # - vlan_id: 7
449 # enabled: True
450 # mode: "ce"
451 # name: "vlan7"
452 # state: active
453 # mapped_vni: 100
454
455 # Using gathered
456
457 # Existing device config state
458 # -------------------------------
459 # nxos-9k# show vlan | json
460 # {"TABLE_vlanbrief": {"ROW_vlanbrief": [{"vlanshowbr-vlanid": "1", "vlanshowbr-vlanid-utf": "1", "vlanshowbr-vlanname": "default", "vlanshowbr-vlanstate
461 # ": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "5", "vlanshowbr-vlanid-utf": "5", "vlanshowbr-vlanname": "vlan5", "vlanshowb
462 # r-vlanstate": "suspend", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "6", "vlanshowbr-vlanid-utf": "6", "vlanshowbr-vlanname": "VLAN00
463 # 06", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "noshutdown"}, {"vlanshowbr-vlanid": "7", "vlanshowbr-vlanid-utf": "7", "vlanshowbr-vlan
464 # name": "vlan7", "vlanshowbr-vlanstate": "active", "vlanshowbr-shutstate": "shutdown"}]}, "TABLE_mtuinfo": {"ROW_mtuinfo": [{"vlanshowinfo-vlanid": "1",
465 # "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "5", "vlanshowinfo-media-type": "enet", "vlanshowinfo-
466 # vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "6", "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}, {"vlanshowinfo-vlanid": "7"
467 # , "vlanshowinfo-media-type": "enet", "vlanshowinfo-vlanmode": "ce-vlan"}]}}
468 #
469 # nxos-9k# show running-config | section ^vlan
470 # vlan 1,5-7
471 # vlan 5
472 # state suspend
473 # name vlan5
474 # vlan 7
475 # shutdown
476 # name vlan7
477 # vn-segment 190
478
479 - name: Gather vlans facts from the device using nxos_vlans
480 cisco.nxos.nxos_vlans:
481 state: gathered
482
483 # Task output (redacted)
484 # -----------------------
485 # gathered:
486 # - vlan_id: 5
487 # enabled: True
488 # mode: "ce"
489 # name: "vlan5"
490 # state: suspend
491 #
492 # - vlan_id: 6
493 # enabled: True
494 # mode: "ce"
495 # state: active
496 #
497 # - vlan_id: 7
498 # enabled: False
499 # mode: "ce"
500 # name: "vlan7"
501 # state: active
502 # mapped_vni: 190
503
504
505
506 Return Values
507 -------------
508 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:
509
510 .. raw:: html
511
512 <table border=0 cellpadding=0 class="documentation-table">
513 <tr>
514 <th colspan="1">Key</th>
515 <th>Returned</th>
516 <th width="100%">Description</th>
517 </tr>
518 <tr>
519 <td colspan="1">
520 <div class="ansibleOptionAnchor" id="return-"></div>
521 <b>after</b>
522 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
523 <div style="font-size: small">
524 <span style="color: purple">list</span>
525 </div>
526 </td>
527 <td>when changed</td>
528 <td>
529 <div>The configuration as structured data after module completion.</div>
530 <br/>
531 <div style="font-size: smaller"><b>Sample:</b></div>
532 <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
533 of the parameters above.</div>
534 </td>
535 </tr>
536 <tr>
537 <td colspan="1">
538 <div class="ansibleOptionAnchor" id="return-"></div>
539 <b>before</b>
540 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
541 <div style="font-size: small">
542 <span style="color: purple">list</span>
543 </div>
544 </td>
545 <td>always</td>
546 <td>
547 <div>The configuration as structured data prior to module invocation.</div>
548 <br/>
549 <div style="font-size: smaller"><b>Sample:</b></div>
550 <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
551 of the parameters above.</div>
552 </td>
553 </tr>
554 <tr>
555 <td colspan="1">
556 <div class="ansibleOptionAnchor" id="return-"></div>
557 <b>commands</b>
558 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
559 <div style="font-size: small">
560 <span style="color: purple">list</span>
561 </div>
562 </td>
563 <td>always</td>
564 <td>
565 <div>The set of commands pushed to the remote device.</div>
566 <br/>
567 <div style="font-size: smaller"><b>Sample:</b></div>
568 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;vlan 5&#x27;, &#x27;name test-vlan5&#x27;, &#x27;state suspend&#x27;]</div>
569 </td>
570 </tr>
571 </table>
572 <br/><br/>
573
574
575 Status
576 ------
577
578
579 Authors
580 ~~~~~~~
581
582 - Trishna Guha (@trishnaguha)