cisco.nxos.nxos_interfaces – Interfaces resource module¶
Note
This plugin is part of the cisco.nxos collection (version 1.4.0).
To install it use: ansible-galaxy collection install cisco.nxos
.
To use it in a playbook, specify: cisco.nxos.nxos_interfaces
.
New in version 1.0.0: of cisco.nxos
Synopsis¶
This module manages the interface attributes of NX-OS interfaces.
Note
This module has a corresponding action plugin.
Parameters¶
Examples¶
# Using merged
# Before state:
# -------------
#
# interface Ethernet1/1
# description testing
# mtu 1800
- name: Merge provided configuration with device configuration
cisco.nxos.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
cisco.nxos.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
cisco.nxos.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
cisco.nxos.nxos_interfaces:
config:
- name: Ethernet1/1
state: deleted
# After state:
# ------------
#
# interface Ethernet1/1
# interface Ethernet1/2
# interface mgmt0
# description Management interface
# ip address dhcp
# Using rendered
- name: Use rendered state to convert task input to device specific commands
cisco.nxos.nxos_interfaces:
config:
- name: Ethernet1/1
description: outbound-intf
mode: layer3
speed: 100
- name: Ethernet1/2
mode: layer2
enabled: true
duplex: full
state: rendered
# Task Output (redacted)
# -----------------------
# rendered:
# - "interface Ethernet1/1"
# - "description outbound-intf"
# - "speed 100"
# - "interface Ethernet1/2"
# - "switchport"
# - "duplex full"
# - "no shutdown"
# Using parsed
# parsed.cfg
# ------------
# interface Ethernet1/800
# description test-1
# speed 1000
# shutdown
# no switchport
# duplex half
# interface Ethernet1/801
# description test-2
# switchport
# no shutdown
# mtu 1800
- name: Use parsed state to convert externally supplied config to structured format
cisco.nxos.nxos_interfaces:
running_config: "{{ lookup('file', 'parsed.cfg') }}"
state: parsed
# Task output (redacted)
# -----------------------
# parsed:
# - description: "test-1"
# duplex: "half"
# enabled: false
# mode: "layer3"
# name: "Ethernet1/800"
# speed: "1000"
#
# - description: "test-2"
# enabled: true
# mode: "layer2"
# mtu: "1800"
# name: "Ethernet1/801"
# Using gathered
# Existing device config state
# -----------------------------
# interface Ethernet1/1
# description outbound-intf
# switchport
# no shutdown
# interface Ethernet1/2
# description intf-l3
# speed 1000
# interface Ethernet1/3
# interface Ethernet1/4
# interface Ethernet1/5
- name: Gather interfaces facts from the device using nxos_interfaces
cisco.nxos.nxos_interfaces:
state: gathered
# Task output (redacted)
# -----------------------
# - name: Ethernet1/1
# description: outbound-intf
# mode: layer2
# enabled: True
# - name: Ethernet1/2
# description: intf-l3
# speed: "1000"
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Authors¶
Trishna Guha (@trishnaguha)