| 1 |
.. _cisco.nxos.nxos_l2_interfaces_module: |
| 2 |
|
| 3 |
|
| 4 |
***************************** |
| 5 |
cisco.nxos.nxos_l2_interfaces |
| 6 |
***************************** |
| 7 |
|
| 8 |
**L2 interfaces 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 manages Layer-2 interfaces attributes of NX-OS Interfaces. |
| 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="4">Parameter</th> |
| 33 |
<th>Choices/<font color="blue">Defaults</font></th> |
| 34 |
<th width="100%">Comments</th> |
| 35 |
</tr> |
| 36 |
<tr> |
| 37 |
<td colspan="4"> |
| 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 Layer-2 interface options</div> |
| 50 |
</td> |
| 51 |
</tr> |
| 52 |
<tr> |
| 53 |
<td class="elbow-placeholder"></td> |
| 54 |
<td colspan="3"> |
| 55 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 56 |
<b>access</b> |
| 57 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 58 |
<div style="font-size: small"> |
| 59 |
<span style="color: purple">dictionary</span> |
| 60 |
</div> |
| 61 |
</td> |
| 62 |
<td> |
| 63 |
</td> |
| 64 |
<td> |
| 65 |
<div>Switchport mode access command to configure the interface as a Layer-2 access.</div> |
| 66 |
</td> |
| 67 |
</tr> |
| 68 |
<tr> |
| 69 |
<td class="elbow-placeholder"></td> |
| 70 |
<td class="elbow-placeholder"></td> |
| 71 |
<td colspan="2"> |
| 72 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 73 |
<b>vlan</b> |
| 74 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 75 |
<div style="font-size: small"> |
| 76 |
<span style="color: purple">integer</span> |
| 77 |
</div> |
| 78 |
</td> |
| 79 |
<td> |
| 80 |
</td> |
| 81 |
<td> |
| 82 |
<div>Configure given VLAN in access port. It's used as the access VLAN ID.</div> |
| 83 |
</td> |
| 84 |
</tr> |
| 85 |
|
| 86 |
<tr> |
| 87 |
<td class="elbow-placeholder"></td> |
| 88 |
<td colspan="3"> |
| 89 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 90 |
<b>beacon</b> |
| 91 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 92 |
<div style="font-size: small"> |
| 93 |
<span style="color: purple">boolean</span> |
| 94 |
</div> |
| 95 |
</td> |
| 96 |
<td> |
| 97 |
<ul style="margin: 0; padding: 0"><b>Choices:</b> |
| 98 |
<li>no</li> |
| 99 |
<li>yes</li> |
| 100 |
</ul> |
| 101 |
</td> |
| 102 |
<td> |
| 103 |
<div>Disable/enable the beacon for an interface</div> |
| 104 |
</td> |
| 105 |
</tr> |
| 106 |
<tr> |
| 107 |
<td class="elbow-placeholder"></td> |
| 108 |
<td colspan="3"> |
| 109 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 110 |
<b>cdp_enable</b> |
| 111 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 112 |
<div style="font-size: small"> |
| 113 |
<span style="color: purple">boolean</span> |
| 114 |
</div> |
| 115 |
</td> |
| 116 |
<td> |
| 117 |
<ul style="margin: 0; padding: 0"><b>Choices:</b> |
| 118 |
<li>no</li> |
| 119 |
<li>yes</li> |
| 120 |
</ul> |
| 121 |
</td> |
| 122 |
<td> |
| 123 |
<div>Enable/disable CDP on the interface</div> |
| 124 |
</td> |
| 125 |
</tr> |
| 126 |
<tr> |
| 127 |
<td class="elbow-placeholder"></td> |
| 128 |
<td colspan="3"> |
| 129 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 130 |
<b>link_flap</b> |
| 131 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 132 |
<div style="font-size: small"> |
| 133 |
<span style="color: purple">dictionary</span> |
| 134 |
</div> |
| 135 |
</td> |
| 136 |
<td> |
| 137 |
</td> |
| 138 |
<td> |
| 139 |
<div>Configure actions on link-flap</div> |
| 140 |
</td> |
| 141 |
</tr> |
| 142 |
<tr> |
| 143 |
<td class="elbow-placeholder"></td> |
| 144 |
<td class="elbow-placeholder"></td> |
| 145 |
<td colspan="2"> |
| 146 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 147 |
<b>error_disable</b> |
| 148 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 149 |
<div style="font-size: small"> |
| 150 |
<span style="color: purple">dictionary</span> |
| 151 |
</div> |
| 152 |
</td> |
| 153 |
<td> |
| 154 |
</td> |
| 155 |
<td> |
| 156 |
<div>Configure the port to error-disable on link-flap</div> |
| 157 |
</td> |
| 158 |
</tr> |
| 159 |
<tr> |
| 160 |
<td class="elbow-placeholder"></td> |
| 161 |
<td class="elbow-placeholder"></td> |
| 162 |
<td class="elbow-placeholder"></td> |
| 163 |
<td colspan="1"> |
| 164 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 165 |
<b>count</b> |
| 166 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 167 |
<div style="font-size: small"> |
| 168 |
<span style="color: purple">integer</span> |
| 169 |
</div> |
| 170 |
</td> |
| 171 |
<td> |
| 172 |
</td> |
| 173 |
<td> |
| 174 |
<div>Configure the number of link-flaps to trigger the action</div> |
| 175 |
</td> |
| 176 |
</tr> |
| 177 |
<tr> |
| 178 |
<td class="elbow-placeholder"></td> |
| 179 |
<td class="elbow-placeholder"></td> |
| 180 |
<td class="elbow-placeholder"></td> |
| 181 |
<td colspan="1"> |
| 182 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 183 |
<b>interval</b> |
| 184 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 185 |
<div style="font-size: small"> |
| 186 |
<span style="color: purple">integer</span> |
| 187 |
</div> |
| 188 |
</td> |
| 189 |
<td> |
| 190 |
</td> |
| 191 |
<td> |
| 192 |
<div>Configure the interval to trigger the action</div> |
| 193 |
</td> |
| 194 |
</tr> |
| 195 |
|
| 196 |
|
| 197 |
<tr> |
| 198 |
<td class="elbow-placeholder"></td> |
| 199 |
<td colspan="3"> |
| 200 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 201 |
<b>mode</b> |
| 202 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 203 |
<div style="font-size: small"> |
| 204 |
<span style="color: purple">string</span> |
| 205 |
</div> |
| 206 |
</td> |
| 207 |
<td> |
| 208 |
<ul style="margin: 0; padding: 0"><b>Choices:</b> |
| 209 |
<li>dot1q-tunnel</li> |
| 210 |
<li>access</li> |
| 211 |
<li>trunk</li> |
| 212 |
<li>fex-fabric</li> |
| 213 |
<li>fabricpath</li> |
| 214 |
</ul> |
| 215 |
</td> |
| 216 |
<td> |
| 217 |
<div>Mode in which interface needs to be configured.</div> |
| 218 |
<div>Access mode is not shown in interface facts, so idempotency will not be maintained for switchport mode access and every time the output will come as changed=True.</div> |
| 219 |
<div style="font-size: small; color: darkgreen"><br/>aliases: switchport_mode</div> |
| 220 |
</td> |
| 221 |
</tr> |
| 222 |
<tr> |
| 223 |
<td class="elbow-placeholder"></td> |
| 224 |
<td colspan="3"> |
| 225 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 226 |
<b>name</b> |
| 227 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 228 |
<div style="font-size: small"> |
| 229 |
<span style="color: purple">string</span> |
| 230 |
/ <span style="color: red">required</span> |
| 231 |
</div> |
| 232 |
</td> |
| 233 |
<td> |
| 234 |
</td> |
| 235 |
<td> |
| 236 |
<div>Full name of interface, i.e. Ethernet1/1.</div> |
| 237 |
</td> |
| 238 |
</tr> |
| 239 |
<tr> |
| 240 |
<td class="elbow-placeholder"></td> |
| 241 |
<td colspan="3"> |
| 242 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 243 |
<b>trunk</b> |
| 244 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 245 |
<div style="font-size: small"> |
| 246 |
<span style="color: purple">dictionary</span> |
| 247 |
</div> |
| 248 |
</td> |
| 249 |
<td> |
| 250 |
</td> |
| 251 |
<td> |
| 252 |
<div>Switchport mode trunk command to configure the interface as a Layer-2 trunk.</div> |
| 253 |
</td> |
| 254 |
</tr> |
| 255 |
<tr> |
| 256 |
<td class="elbow-placeholder"></td> |
| 257 |
<td class="elbow-placeholder"></td> |
| 258 |
<td colspan="2"> |
| 259 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 260 |
<b>allowed_vlans</b> |
| 261 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 262 |
<div style="font-size: small"> |
| 263 |
<span style="color: purple">string</span> |
| 264 |
</div> |
| 265 |
</td> |
| 266 |
<td> |
| 267 |
</td> |
| 268 |
<td> |
| 269 |
<div>List of allowed VLANs in a given trunk port. These are the only VLANs that will be configured on the trunk.</div> |
| 270 |
<div>The module would consider 1-4093 as the default range enabled if switchport mode is trunk.</div> |
| 271 |
</td> |
| 272 |
</tr> |
| 273 |
<tr> |
| 274 |
<td class="elbow-placeholder"></td> |
| 275 |
<td class="elbow-placeholder"></td> |
| 276 |
<td colspan="2"> |
| 277 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 278 |
<b>allowed_vlans_none</b> |
| 279 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 280 |
<div style="font-size: small"> |
| 281 |
<span style="color: purple">boolean</span> |
| 282 |
</div> |
| 283 |
</td> |
| 284 |
<td> |
| 285 |
<ul style="margin: 0; padding: 0"><b>Choices:</b> |
| 286 |
<li>no</li> |
| 287 |
<li>yes</li> |
| 288 |
</ul> |
| 289 |
</td> |
| 290 |
<td> |
| 291 |
<div>This option governs the `switchport trunk allowed vlan none` configuration</div> |
| 292 |
<div>negation of this command would consider 1-4093 as the default.</div> |
| 293 |
<div>This attribute does not ensure idempotency.</div> |
| 294 |
</td> |
| 295 |
</tr> |
| 296 |
<tr> |
| 297 |
<td class="elbow-placeholder"></td> |
| 298 |
<td class="elbow-placeholder"></td> |
| 299 |
<td colspan="2"> |
| 300 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 301 |
<b>native_vlan</b> |
| 302 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 303 |
<div style="font-size: small"> |
| 304 |
<span style="color: purple">integer</span> |
| 305 |
</div> |
| 306 |
</td> |
| 307 |
<td> |
| 308 |
</td> |
| 309 |
<td> |
| 310 |
<div>Native VLAN to be configured in trunk port. It is used as the trunk native VLAN ID.</div> |
| 311 |
</td> |
| 312 |
</tr> |
| 313 |
|
| 314 |
|
| 315 |
<tr> |
| 316 |
<td colspan="4"> |
| 317 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 318 |
<b>running_config</b> |
| 319 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 320 |
<div style="font-size: small"> |
| 321 |
<span style="color: purple">string</span> |
| 322 |
</div> |
| 323 |
</td> |
| 324 |
<td> |
| 325 |
</td> |
| 326 |
<td> |
| 327 |
<div>This option is used only with state <em>parsed</em>.</div> |
| 328 |
<div>The value of this option should be the output received from the NX-OS device by executing the command <b>show running-config | section ^interface</b>.</div> |
| 329 |
<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's argspec and the value is then returned in the <em>parsed</em> key within the result.</div> |
| 330 |
</td> |
| 331 |
</tr> |
| 332 |
<tr> |
| 333 |
<td colspan="4"> |
| 334 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 335 |
<b>state</b> |
| 336 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 337 |
<div style="font-size: small"> |
| 338 |
<span style="color: purple">string</span> |
| 339 |
</div> |
| 340 |
</td> |
| 341 |
<td> |
| 342 |
<ul style="margin: 0; padding: 0"><b>Choices:</b> |
| 343 |
<li><div style="color: blue"><b>merged</b> ←</div></li> |
| 344 |
<li>replaced</li> |
| 345 |
<li>overridden</li> |
| 346 |
<li>deleted</li> |
| 347 |
<li>gathered</li> |
| 348 |
<li>rendered</li> |
| 349 |
<li>parsed</li> |
| 350 |
</ul> |
| 351 |
</td> |
| 352 |
<td> |
| 353 |
<div>The state of the configuration after module completion.</div> |
| 354 |
</td> |
| 355 |
</tr> |
| 356 |
</table> |
| 357 |
<br/> |
| 358 |
|
| 359 |
|
| 360 |
Notes |
| 361 |
----- |
| 362 |
|
| 363 |
.. note:: |
| 364 |
- Tested against NXOS 10.3(2) on CML |
| 365 |
- Unsupported for Cisco MDS |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
Examples |
| 370 |
-------- |
| 371 |
|
| 372 |
.. code-block:: yaml |
| 373 |
|
| 374 |
# Using merged |
| 375 |
|
| 376 |
# Before state: |
| 377 |
# ------------- |
| 378 |
# |
| 379 |
# switch# show running-config | section interface |
| 380 |
# interface Ethernet1/1 |
| 381 |
# interface Ethernet1/2 |
| 382 |
# switchport trunk native vlan 20 |
| 383 |
# interface mgmt0 |
| 384 |
# ip address dhcp |
| 385 |
# ipv6 address auto-config |
| 386 |
|
| 387 |
- name: Merge provided configuration with device configuration |
| 388 |
cisco.nxos.nxos_l2_interfaces: |
| 389 |
config: |
| 390 |
- name: Ethernet1/1 |
| 391 |
trunk: |
| 392 |
native_vlan: 10 |
| 393 |
allowed_vlans: 2,4,15 |
| 394 |
- name: Ethernet1/2 |
| 395 |
access: |
| 396 |
vlan: 30 |
| 397 |
state: merged |
| 398 |
|
| 399 |
# Task Output |
| 400 |
# ----------- |
| 401 |
# |
| 402 |
# before: |
| 403 |
# - name: Loopback999 |
| 404 |
# - name: Ethernet1/2 |
| 405 |
# - name: mgmt0 |
| 406 |
# - name: Ethernet1/1 |
| 407 |
# commands: |
| 408 |
# - interface Ethernet1/1 |
| 409 |
# - switchport trunk allowed vlan 2,4,15 |
| 410 |
# - switchport trunk native vlan 10 |
| 411 |
# - interface Ethernet1/2 |
| 412 |
# - switchport access vlan 30 |
| 413 |
# after: |
| 414 |
# - name: Ethernet1/1 |
| 415 |
# trunk: |
| 416 |
# allowed_vlans: 2,4,15 |
| 417 |
# native_vlan: 10 |
| 418 |
# - access: |
| 419 |
# vlan: 30 |
| 420 |
# name: Ethernet1/2 |
| 421 |
# - name: mgmt0 |
| 422 |
# - name: Loopback999 |
| 423 |
|
| 424 |
# After state: |
| 425 |
# ------------ |
| 426 |
# |
| 427 |
# switch# show running-config | section interface |
| 428 |
# interface Ethernet1/1 |
| 429 |
# switchport trunk native vlan 10 |
| 430 |
# switchport trunk allowed vlans 2,4,15 |
| 431 |
# interface Ethernet1/2 |
| 432 |
# switchport access vlan 30 |
| 433 |
# interface mgmt0 |
| 434 |
# ip address dhcp |
| 435 |
# ipv6 address auto-config |
| 436 |
|
| 437 |
# Using replaced |
| 438 |
|
| 439 |
# Before state: |
| 440 |
# ------------- |
| 441 |
# |
| 442 |
# switch# show running-config | section interface |
| 443 |
# interface Ethernet1/1 |
| 444 |
# switchport trunk native vlan 10 |
| 445 |
# switchport trunk allowed vlans 2,4,15 |
| 446 |
# interface Ethernet1/2 |
| 447 |
# switchport access vlan 30 |
| 448 |
# interface mgmt0 |
| 449 |
# ip address dhcp |
| 450 |
# ipv6 address auto-config |
| 451 |
|
| 452 |
- name: Replace device configuration of specified L2 interfaces with provided configuration. |
| 453 |
cisco.nxos.nxos_l2_interfaces: |
| 454 |
config: |
| 455 |
- name: Ethernet1/1 |
| 456 |
trunk: |
| 457 |
native_vlan: 20 |
| 458 |
allowed_vlans: 5-10, 15 |
| 459 |
state: replaced |
| 460 |
|
| 461 |
# Task Output |
| 462 |
# ----------- |
| 463 |
# |
| 464 |
# before: |
| 465 |
# - name: Ethernet1/1 |
| 466 |
# trunk: |
| 467 |
# allowed_vlans: 2,4,15 |
| 468 |
# native_vlan: 10 |
| 469 |
# - access: |
| 470 |
# vlan: 30 |
| 471 |
# name: Ethernet1/2 |
| 472 |
# - name: mgmt0 |
| 473 |
# commands: |
| 474 |
# - interface Ethernet1/1 |
| 475 |
# - no switchport trunk native vlan |
| 476 |
# - switchport trunk allowed vlan 5-10,15 |
| 477 |
# - switchport trunk native vlan 20 |
| 478 |
# after: |
| 479 |
# - name: Ethernet1/1 |
| 480 |
# trunk: |
| 481 |
# allowed_vlans: 5-10,15 |
| 482 |
# native_vlan: 20 |
| 483 |
# - access: |
| 484 |
# vlan: 30 |
| 485 |
# name: Ethernet1/2 |
| 486 |
# - name: mgmt0 |
| 487 |
|
| 488 |
# After state: |
| 489 |
# ------------ |
| 490 |
# |
| 491 |
# switch# show running-config | section interface |
| 492 |
# interface Ethernet1/1 |
| 493 |
# switchport trunk native vlan 20 |
| 494 |
# switchport trunk allowed vlan 5-10,15 |
| 495 |
# interface Ethernet1/2 |
| 496 |
# switchport trunk native vlan 20 |
| 497 |
# switchport mode trunk |
| 498 |
# interface mgmt0 |
| 499 |
# ip address dhcp |
| 500 |
# ipv6 address auto-config |
| 501 |
|
| 502 |
# Using overridden |
| 503 |
|
| 504 |
# Before state: |
| 505 |
# ------------- |
| 506 |
# |
| 507 |
# switch# show running-config | section interface |
| 508 |
# interface Ethernet1/1 |
| 509 |
# switchport trunk native vlan 20 |
| 510 |
# switchport trunk allowed vlan 5-10,15 |
| 511 |
# interface Ethernet1/2 |
| 512 |
# switchport trunk native vlan 20 |
| 513 |
# switchport mode trunk |
| 514 |
# interface mgmt0 |
| 515 |
# ip address dhcp |
| 516 |
# ipv6 address auto-config |
| 517 |
|
| 518 |
- name: Override device configuration with provided configuration. |
| 519 |
cisco.nxos.nxos_l2_interfaces: |
| 520 |
config: |
| 521 |
- name: Ethernet1/2 |
| 522 |
access: |
| 523 |
vlan: 30 |
| 524 |
state: overridden |
| 525 |
|
| 526 |
# Task Output |
| 527 |
# ----------- |
| 528 |
# |
| 529 |
# before: |
| 530 |
# - name: Ethernet1/1 |
| 531 |
# trunk: |
| 532 |
# allowed_vlans: 5,6,7,8,9,10,15 |
| 533 |
# native_vlan: 20 |
| 534 |
# - access: |
| 535 |
# vlan: 30 |
| 536 |
# name: Ethernet1/2 |
| 537 |
# - name: mgmt0 |
| 538 |
# commands: |
| 539 |
# - interface Ethernet1/1 |
| 540 |
# - no switchport trunk allowed vlan |
| 541 |
# - no switchport trunk native vlan |
| 542 |
# after: |
| 543 |
# - name: Ethernet1/1 |
| 544 |
# - access: |
| 545 |
# vlan: 30 |
| 546 |
# name: Ethernet1/2 |
| 547 |
# - name: mgmt0 |
| 548 |
|
| 549 |
# After state: |
| 550 |
# ------------ |
| 551 |
# |
| 552 |
# switch# show running-config | section interface |
| 553 |
# interface Ethernet1/1 |
| 554 |
# interface Ethernet1/2 |
| 555 |
# switchport access vlan 30 |
| 556 |
# interface mgmt0 |
| 557 |
# ip address dhcp |
| 558 |
# ipv6 address auto-config |
| 559 |
|
| 560 |
|
| 561 |
# Using deleted |
| 562 |
|
| 563 |
# Before state: |
| 564 |
# ------------- |
| 565 |
# |
| 566 |
# switch# show running-config | section interface |
| 567 |
# interface Ethernet1/1 |
| 568 |
# switchport trunk native vlan 10 |
| 569 |
# switchport trunk allowed vlan 2,4,15 |
| 570 |
# interface Ethernet1/2 |
| 571 |
# switchport access vlan 30 |
| 572 |
# interface mgmt0 |
| 573 |
# ip address dhcp |
| 574 |
# ipv6 address auto-config |
| 575 |
|
| 576 |
- name: Delete L2 attributes of given interfaces (Note This won't delete the interface |
| 577 |
itself). |
| 578 |
cisco.nxos.nxos_l2_interfaces: |
| 579 |
config: |
| 580 |
- name: Ethernet1/1 |
| 581 |
- name: Ethernet1/2 |
| 582 |
state: deleted |
| 583 |
|
| 584 |
# Task Output |
| 585 |
# ----------- |
| 586 |
# |
| 587 |
# before: |
| 588 |
# - name: Ethernet1/1 |
| 589 |
# trunk: |
| 590 |
# allowed_vlans: 2,4,15 |
| 591 |
# native_vlan: 10 |
| 592 |
# - access: |
| 593 |
# vlan: 30 |
| 594 |
# name: Ethernet1/2 |
| 595 |
# - name: mgmt0 |
| 596 |
# commands: |
| 597 |
# - interface Ethernet1/1 |
| 598 |
# - no switchport trunk allowed vlan |
| 599 |
# - no switchport trunk native vlan |
| 600 |
# - interface Ethernet1/2 |
| 601 |
# - no switchport access vlan |
| 602 |
# after: |
| 603 |
# - name: Ethernet1/1 |
| 604 |
# - name: Ethernet1/2 |
| 605 |
# - name: mgmt0 |
| 606 |
|
| 607 |
# After state: |
| 608 |
# ------------ |
| 609 |
# |
| 610 |
# switch# show running-config | section interface |
| 611 |
# interface Ethernet1/1 |
| 612 |
# interface Ethernet1/2 |
| 613 |
# interface mgmt0 |
| 614 |
# ip address dhcp |
| 615 |
# ipv6 address auto-config |
| 616 |
|
| 617 |
# Using rendered |
| 618 |
|
| 619 |
- name: Render platform specific configuration lines (without connecting to the device) |
| 620 |
cisco.nxos.nxos_l2_interfaces: |
| 621 |
config: |
| 622 |
- name: Ethernet1/1 |
| 623 |
trunk: |
| 624 |
native_vlan: 10 |
| 625 |
allowed_vlans: 2,4,15 |
| 626 |
- name: Ethernet1/2 |
| 627 |
access: |
| 628 |
vlan: 30 |
| 629 |
- name: Ethernet1/3 |
| 630 |
trunk: |
| 631 |
native_vlan: 20 |
| 632 |
allowed_vlans: 5-10, 15 |
| 633 |
state: rendered |
| 634 |
|
| 635 |
# Task Output |
| 636 |
# ----------- |
| 637 |
# |
| 638 |
# rendered: |
| 639 |
# - interface Ethernet1/1 |
| 640 |
# - switchport trunk allowed vlan 2,4,15 |
| 641 |
# - switchport trunk native vlan 10 |
| 642 |
# - interface Ethernet1/2 |
| 643 |
# - switchport access vlan 30 |
| 644 |
# - interface Ethernet1/3 |
| 645 |
# - switchport trunk allowed vlan 5-10,15 |
| 646 |
# - switchport trunk native vlan 20 |
| 647 |
|
| 648 |
# Using parsed |
| 649 |
|
| 650 |
# parsed.cfg |
| 651 |
# ------------ |
| 652 |
# |
| 653 |
# interface Ethernet1/800 |
| 654 |
# switchport access vlan 18 |
| 655 |
# switchport trunk allowed vlan 210 |
| 656 |
# interface Ethernet1/801 |
| 657 |
# switchport trunk allowed vlan 2,4,15 |
| 658 |
|
| 659 |
- name: Use parsed state to convert externally supplied config to structured format |
| 660 |
cisco.nxos.nxos_l2_interfaces: |
| 661 |
running_config: "{{ lookup('file', 'parsed.cfg') }}" |
| 662 |
state: parsed |
| 663 |
|
| 664 |
# Task output |
| 665 |
# ----------- |
| 666 |
# |
| 667 |
# parsed: |
| 668 |
# - name: Ethernet1/800 |
| 669 |
# access: |
| 670 |
# vlan: 18 |
| 671 |
# trunk: |
| 672 |
# allowed_vlans: "210" |
| 673 |
# - name: Ethernet1/801 |
| 674 |
# trunk: |
| 675 |
# allowed_vlans: "2,4,15" |
| 676 |
|
| 677 |
# Using gathered |
| 678 |
|
| 679 |
# Before state: |
| 680 |
# ------------- |
| 681 |
# |
| 682 |
# switch# sh running-config | section ^interface |
| 683 |
# interface Ethernet1/1 |
| 684 |
# switchport access vlan 6 |
| 685 |
# switchport trunk allowed vlan 200 |
| 686 |
# interface Ethernet1/2 |
| 687 |
# switchport trunk native vlan 10 |
| 688 |
|
| 689 |
- name: Gather l2_interfaces facts from the device using nxos_l2_interfaces |
| 690 |
cisco.nxos.nxos_l2_interfaces: |
| 691 |
state: gathered |
| 692 |
|
| 693 |
# Task output |
| 694 |
# ----------- |
| 695 |
# |
| 696 |
# gathered: |
| 697 |
# - name: "Ethernet1/1" |
| 698 |
# access: |
| 699 |
# vlan: 6 |
| 700 |
# trunk: |
| 701 |
# allowed_vlans: "200" |
| 702 |
# - name: "Ethernet1/2" |
| 703 |
# trunk: |
| 704 |
# native_vlan: 10 |
| 705 |
|
| 706 |
# Using allowed_vlans_none |
| 707 |
|
| 708 |
# Before state: |
| 709 |
# ------------- |
| 710 |
# |
| 711 |
# switch# show running-config | section interface |
| 712 |
# interface Ethernet1/1 |
| 713 |
# switchport mode trunk |
| 714 |
# switchport trunk allowed vlan 10-100 |
| 715 |
# interface Ethernet1/2 |
| 716 |
# switchport mode trunk |
| 717 |
|
| 718 |
- name: Configure trunk interface to allow no VLANs (block all traffic) |
| 719 |
cisco.nxos.nxos_l2_interfaces: |
| 720 |
config: |
| 721 |
- name: Ethernet1/1 |
| 722 |
trunk: |
| 723 |
allowed_vlans_none: true |
| 724 |
state: merged |
| 725 |
|
| 726 |
# Task Output |
| 727 |
# ----------- |
| 728 |
# |
| 729 |
# before: |
| 730 |
# - name: Ethernet1/1 |
| 731 |
# trunk: |
| 732 |
# allowed_vlans: "10-100" |
| 733 |
# - name: Ethernet1/2 |
| 734 |
# trunk: |
| 735 |
# allowed_vlans: "1-4094" |
| 736 |
# commands: |
| 737 |
# - interface Ethernet1/1 |
| 738 |
# - switchport trunk allowed vlan none |
| 739 |
# after: |
| 740 |
# - name: Ethernet1/1 |
| 741 |
# trunk: |
| 742 |
# allowed_vlans_none: true |
| 743 |
# - name: Ethernet1/2 |
| 744 |
# trunk: |
| 745 |
# allowed_vlans: "1-4094" |
| 746 |
|
| 747 |
# After state: |
| 748 |
# ------------ |
| 749 |
# |
| 750 |
# switch# show running-config | section interface |
| 751 |
# interface Ethernet1/1 |
| 752 |
# switchport mode trunk |
| 753 |
# switchport trunk allowed vlan none |
| 754 |
# interface Ethernet1/2 |
| 755 |
# switchport mode trunk |
| 756 |
|
| 757 |
# Note: When allowed_vlans_none is not configured on a trunk interface, |
| 758 |
# the module assumes the default allowed VLANs range of 1-4094. |
| 759 |
# This is consistent with NX-OS default behavior where all VLANs are |
| 760 |
# allowed on trunk ports unless explicitly restricted. |
| 761 |
|
| 762 |
- name: Configure specific VLANs after removing none restriction |
| 763 |
cisco.nxos.nxos_l2_interfaces: |
| 764 |
config: |
| 765 |
- name: Ethernet1/1 |
| 766 |
trunk: |
| 767 |
allowed_vlans: "10,20,30" |
| 768 |
- name: Ethernet1/2 |
| 769 |
trunk: |
| 770 |
allowed_vlans_none: true |
| 771 |
state: replaced |
| 772 |
|
| 773 |
# Task Output |
| 774 |
# ----------- |
| 775 |
# |
| 776 |
# commands: |
| 777 |
# - interface Ethernet1/1 |
| 778 |
# - switchport trunk allowed vlan 10,20,30 |
| 779 |
# - interface Ethernet1/2 |
| 780 |
# - switchport trunk allowed vlan none |
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
Return Values |
| 785 |
------------- |
| 786 |
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: |
| 787 |
|
| 788 |
.. raw:: html |
| 789 |
|
| 790 |
<table border=0 cellpadding=0 class="documentation-table"> |
| 791 |
<tr> |
| 792 |
<th colspan="1">Key</th> |
| 793 |
<th>Returned</th> |
| 794 |
<th width="100%">Description</th> |
| 795 |
</tr> |
| 796 |
<tr> |
| 797 |
<td colspan="1"> |
| 798 |
<div class="ansibleOptionAnchor" id="return-"></div> |
| 799 |
<b>after</b> |
| 800 |
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> |
| 801 |
<div style="font-size: small"> |
| 802 |
<span style="color: purple">list</span> |
| 803 |
</div> |
| 804 |
</td> |
| 805 |
<td>when changed</td> |
| 806 |
<td> |
| 807 |
<div>The configuration as structured data after module completion.</div> |
| 808 |
<br/> |
| 809 |
<div style="font-size: smaller"><b>Sample:</b></div> |
| 810 |
<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 |
| 811 |
of the parameters above.</div> |
| 812 |
</td> |
| 813 |
</tr> |
| 814 |
<tr> |
| 815 |
<td colspan="1"> |
| 816 |
<div class="ansibleOptionAnchor" id="return-"></div> |
| 817 |
<b>before</b> |
| 818 |
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> |
| 819 |
<div style="font-size: small"> |
| 820 |
<span style="color: purple">list</span> |
| 821 |
</div> |
| 822 |
</td> |
| 823 |
<td>always</td> |
| 824 |
<td> |
| 825 |
<div>The configuration as structured data prior to module invocation.</div> |
| 826 |
<br/> |
| 827 |
<div style="font-size: smaller"><b>Sample:</b></div> |
| 828 |
<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 |
| 829 |
of the parameters above.</div> |
| 830 |
</td> |
| 831 |
</tr> |
| 832 |
<tr> |
| 833 |
<td colspan="1"> |
| 834 |
<div class="ansibleOptionAnchor" id="return-"></div> |
| 835 |
<b>commands</b> |
| 836 |
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> |
| 837 |
<div style="font-size: small"> |
| 838 |
<span style="color: purple">list</span> |
| 839 |
</div> |
| 840 |
</td> |
| 841 |
<td>always</td> |
| 842 |
<td> |
| 843 |
<div>The set of commands pushed to the remote device.</div> |
| 844 |
<br/> |
| 845 |
<div style="font-size: smaller"><b>Sample:</b></div> |
| 846 |
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['interface Ethernet1/1', 'switchport trunk allowed vlan 2,4,15', 'switchport trunk native vlan 10', 'interface Ethernet1/2', 'switchport access vlan 30', 'interface Ethernet1/3', 'switchport trunk allowed vlan 5,6,7,8,9,10,15', 'switchport trunk native vlan 20']</div> |
| 847 |
</td> |
| 848 |
</tr> |
| 849 |
<tr> |
| 850 |
<td colspan="1"> |
| 851 |
<div class="ansibleOptionAnchor" id="return-"></div> |
| 852 |
<b>gathered</b> |
| 853 |
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> |
| 854 |
<div style="font-size: small"> |
| 855 |
<span style="color: purple">list</span> |
| 856 |
</div> |
| 857 |
</td> |
| 858 |
<td>when <em>state</em> is <code>gathered</code></td> |
| 859 |
<td> |
| 860 |
<div>Facts about the network resource gathered from the remote device as structured data.</div> |
| 861 |
<br/> |
| 862 |
<div style="font-size: smaller"><b>Sample:</b></div> |
| 863 |
<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> |
| 864 |
</td> |
| 865 |
</tr> |
| 866 |
<tr> |
| 867 |
<td colspan="1"> |
| 868 |
<div class="ansibleOptionAnchor" id="return-"></div> |
| 869 |
<b>parsed</b> |
| 870 |
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> |
| 871 |
<div style="font-size: small"> |
| 872 |
<span style="color: purple">list</span> |
| 873 |
</div> |
| 874 |
</td> |
| 875 |
<td>when <em>state</em> is <code>parsed</code></td> |
| 876 |
<td> |
| 877 |
<div>The device native config provided in <em>running_config</em> option parsed into structured data as per module argspec.</div> |
| 878 |
<br/> |
| 879 |
<div style="font-size: smaller"><b>Sample:</b></div> |
| 880 |
<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> |
| 881 |
</td> |
| 882 |
</tr> |
| 883 |
</table> |
| 884 |
<br/><br/> |
| 885 |
|
| 886 |
|
| 887 |
Status |
| 888 |
------ |
| 889 |
|
| 890 |
|
| 891 |
Authors |
| 892 |
~~~~~~~ |
| 893 |
|
| 894 |
- Trishna Guha (@trishnaguha) |
| 895 |
- Vinay Mulugund (@roverflow) |