W3cubDocs

/Ansible 2.9

nxos_l2_interfaces – Manages Layer-2 Interfaces attributes of NX-OS Interfaces

New in version 2.9.

Synopsis

  • This module manages Layer-2 interfaces attributes of NX-OS Interfaces.

Parameters

Parameter Choices/Defaults Comments
config
list / elements=dictionary
A dictionary of Layer-2 interface options
access
dictionary
Switchport mode access command to configure the interface as a Layer-2 access.
vlan
integer
Configure given VLAN in access port. It's used as the access VLAN ID.
name
string / required
Full name of interface, i.e. Ethernet1/1.
trunk
dictionary
Switchport mode trunk command to configure the interface as a Layer-2 trunk.
allowed_vlans
string
List of allowed VLANs in a given trunk port. These are the only VLANs that will be configured on the trunk.
native_vlan
integer
Native VLAN to be configured in trunk port. It is used as the trunk native VLAN ID.
state
string
    Choices:
  • merged
  • replaced
  • overridden
  • deleted
The state of the configuration after module completion.

Notes

Note

  • Tested against NXOS 7.3.(0)D1(1) on VIRL

Examples

# Using merged

# Before state:
# -------------
#
# interface Ethernet1/1
#   switchport access vlan 20
# interface Ethernet1/2
#   switchport trunk native vlan 20
# interface mgmt0
#   ip address dhcp
#   ipv6 address auto-config

- name: Merge provided configuration with device configuration.
  nxos_l2_interfaces:
    config:
      - name: Ethernet1/1
        trunk:
          native_vlan: 10
          allowed_vlans: 2,4,15
      - name: Ethernet1/2
        access:
          vlan: 30
    state: merged

# After state:
# ------------
#
# interface Ethernet1/1
#   switchport trunk native vlan 10
#   switchport trunk allowed vlans 2,4,15
# interface Ethernet1/2
#   switchport access vlan 30
# interface mgmt0
#   ip address dhcp
#   ipv6 address auto-config


# Using replaced

# Before state:
# -------------
#
# interface Ethernet1/1
#   switchport access vlan 20
# interface Ethernet1/2
#   switchport trunk native vlan 20
# interface mgmt0
#   ip address dhcp
#   ipv6 address auto-config

- name: Replace device configuration of specified L2 interfaces with provided configuration.
  nxos_l2_interfaces:
    config:
      - name: Ethernet1/1
        trunk:
          native_vlan: 20
          trunk_vlans: 5-10, 15
    state: replaced

# After state:
# ------------
#
# interface Ethernet1/1
#   switchport trunk native vlan 20
#   switchport trunk allowed vlan 5-10,15
# interface Ethernet1/2
#   switchport trunk native vlan 20
#   switchport mode trunk
# interface mgmt0
#   ip address dhcp
#   ipv6 address auto-config


# Using overridden

# Before state:
# -------------
#
# interface Ethernet1/1
#   switchport access vlan 20
# interface Ethernet1/2
#   switchport trunk native vlan 20
# interface mgmt0
#   ip address dhcp
#   ipv6 address auto-config

- name: Override device configuration of all L2 interfaces on device with provided configuration.
  nxos_l2_interfaces:
    config:
      - name: Ethernet1/2
        access:
          vlan: 30
    state: overridden

# After state:
# ------------
#
# interface Ethernet1/1
# interface Ethernet1/2
#   switchport access vlan 30
# interface mgmt0
#   ip address dhcp
#   ipv6 address auto-config


# Using deleted

# Before state:
# -------------
#
# interface Ethernet1/1
#   switchport access vlan 20
# interface Ethernet1/2
#   switchport trunk native vlan 20
# interface mgmt0
#   ip address dhcp
#   ipv6 address auto-config

- name: Delete L2 attributes of given interfaces (Note This won't delete the interface itself).
  nxos_l2_interfaces:
    config:
      - name: Ethernet1/1
      - name: Ethernet1/2
    state: deleted

# After state:
# ------------
#
# interface Ethernet1/1
# interface Ethernet1/2
# interface mgmt0
#   ip address dhcp
#   ipv6 address auto-config

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
after
list
when changed
The configuration as structured data after module completion.

Sample:
The configuration returned will always be in the same format of the parameters above.
before
list
always
The configuration as structured data prior to module invocation.

Sample:
The configuration returned will always be in the same format of the parameters above.
commands
list
always
The set of commands pushed to the remote device.

Sample:
['command 1', 'command 2', 'command 3']


Status

Red Hat Support

More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.

Authors

  • Trishna Guha (@trishnaguha)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/modules/nxos_l2_interfaces_module.html