nxos_interfaces – Manages interface attributes of NX-OS Interfaces

From Get docs
Ansible/docs/2.9/modules/nxos interfaces module


nxos_interfaces – Manages interface attributes of NX-OS Interfaces

New in version 2.9.


Synopsis

  • This module manages the interface attributes of NX-OS interfaces.

Parameters

Parameter Choices/Defaults Comments

config

list / elements=dictionary

A dictionary of interface options

description

string

Interface description.

duplex

string

  • full
  • half
  • auto

Interface link status. Applicable for Ethernet interfaces only.

enabled

boolean

  • no
  • yes

Administrative state of the interface. Set the value to true to administratively enable the interface or false to disable it

fabric_forwarding_anycast_gateway

boolean

  • no
  • yes

Associate SVI with anycast gateway under VLAN configuration mode. Applicable for SVI interfaces only.

ip_forward

boolean

  • no
  • yes

Enable or disable IP forward feature on SVIs. Set the value to true to enable or false to disable.

mode

string

  • layer2
  • layer3

Manage Layer2 or Layer3 state of the interface. Applicable for Ethernet and port channel interfaces only.

mtu

string

MTU for a specific interface. Must be an even number between 576 and 9216. Applicable for Ethernet interfaces only.

name

string / required

Full name of interface, e.g. Ethernet1/1, port-channel10.

speed

string

Interface link speed. Applicable for Ethernet interfaces only.

state

string

  • 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
#   description testing
#   mtu 1800

- name: Merge provided configuration with device configuration
  nxos_interfaces:
    config:
      - name: Ethernet1/1
        description: 'Configured by Ansible'
        enabled: True
      - name: Ethernet1/2
        description: 'Configured by Ansible Network'
        enabled: False
    state: merged

# After state:
# ------------
#
# interface Ethernet1/1
#    description Configured by Ansible
#    no shutdown
#    mtu 1800
# interface Ethernet2
#    description Configured by Ansible Network
#    shutdown


# Using replaced

# Before state:
# -------------
#
# interface Ethernet1/1
#    description Interface 1/1
# interface Ethernet1/2

- name: Replaces device configuration of listed interfaces with provided configuration
  nxos_interfaces:
    config:
      - name: Ethernet1/1
        description: 'Configured by Ansible'
        enabled: True
        mtu: 2000
      - name: Ethernet1/2
        description: 'Configured by Ansible Network'
        enabled: False
        mode: layer2
    state: replaced

# After state:
# ------------
#
# interface Ethernet1/1
#   description Configured by Ansible
#   no shutdown
#   mtu 1500
# interface Ethernet2/2
#    description Configured by Ansible Network
#    shutdown
#    switchport


# Using overridden

# Before state:
# -------------
#
# interface Ethernet1/1
#    description Interface Ethernet1/1
# interface Ethernet1/2
# interface mgmt0
#    description Management interface
#    ip address dhcp

- name: Override device configuration of all interfaces with provided configuration
  nxos_interfaces:
    config:
      - name: Ethernet1/1
        enabled: True
      - name: Ethernet1/2
        description: 'Configured by Ansible Network'
        enabled: False
    state: overridden

# After state:
# ------------
#
# interface Ethernet1/1
# interface Ethernet1/2
#    description Configured by Ansible Network
#    shutdown
# interface mgmt0
#    ip address dhcp


# Using deleted

# Before state:
# -------------
#
# interface Ethernet1/1
#    description Interface Ethernet1/1
# interface Ethernet1/2
# interface mgmt0
#    description Management interface
#    ip address dhcp

- name: Delete or return interface parameters to default settings
  nxos_interfaces:
    config:
      - name: Ethernet1/1
    state: deleted

# After state:
# ------------
#
# interface Ethernet1/1
# interface Ethernet1/2
# interface mgmt0
#    description Management interface
#    ip address dhcp

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:

['interface Ethernet1/1', 'mtu 1800']




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_interfaces_module.html