cisco.nxos.nxos_vpc_interface module – VPC interface resource module.

Note

This module is part of the cisco.nxos collection (version 14.0.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install cisco.nxos.

To use it in a playbook, specify: cisco.nxos.nxos_vpc_interface.

New in cisco.nxos 1.0.0

Synopsis

  • This module manages VPC-related interface configuration on Cisco NX-OS devices.

Note

This module has a corresponding action plugin.

Aliases: vpc_interface

Parameters

Parameter

Comments

config

list / elements=dictionary

A list of VPC interface configurations.

name

string / required

Full name of the interface (e.g. port-channel10 or Ethernet1/3).

orphan_port_suspend

boolean

When true, configure the interface as a VPC orphan-port that suspends when the VPC secondary peer-link goes down.

Supported on any interface type.

Choices:

  • false

  • true

boolean

When true, configure this port-channel as the VPC peer-link.

Mutually exclusive with vpc.

Choices:

  • false

  • true

vpc

string

VPC ID to assign to this port-channel.

Mutually exclusive with peer_link.

running_config

string

This option is used only with state parsed.

The value of this option should be the output received from the NX-OS device by executing the command show running-config | section ^interface.

The state parsed reads the configuration from running_config option and transforms it into Ansible structured data as per the resource module’s argspec and the value is then returned in the parsed key within the result.

state

string

The state the configuration should be left in.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "rendered"

  • "parsed"

Notes

Note

Examples

# Using merged

# Before state:
# -------------
# nxos# show running-config | section ^interface port-channel
# interface port-channel10
#   switchport
# interface port-channel20
#   switchport

- name: Merge the provided configuration with the existing running configuration
  cisco.nxos.nxos_vpc_interface:
    config:
      - name: port-channel10
        vpc: 100
      - name: port-channel20
        peer_link: true
      - name: Ethernet1/3
        orphan_port_suspend: true
    state: merged

# Task output:
# ------------
# before: []
#
# commands:
#   - interface port-channel10
#   - vpc 100
#   - interface port-channel20
#   - vpc peer-link
#   - interface Ethernet1/3
#   - vpc orphan-port suspend
#
# after:
#   - name: Ethernet1/3
#     orphan_port_suspend: true
#   - name: port-channel10
#     vpc: "100"
#   - name: port-channel20
#     peer_link: true

# After state:
# ------------
# interface port-channel10
#   vpc 100
# interface port-channel20
#   vpc peer-link


# Using merged to remove an attribute

# Before state:
# -------------
# interface port-channel20
#   vpc peer-link
# interface Ethernet1/3
#   vpc orphan-port suspend

- name: Remove the peer-link and the orphan-port suspend flag
  cisco.nxos.nxos_vpc_interface:
    config:
      - name: port-channel20
        peer_link: false
      - name: Ethernet1/3
        orphan_port_suspend: false
    state: merged

# Task output:
# ------------
# commands:
#   - interface port-channel20
#   - no vpc peer-link
#   - interface Ethernet1/3
#   - no vpc orphan-port suspend


# Using replaced

# Before state:
# -------------
# interface port-channel10
#   vpc 100
# interface port-channel20
#   vpc peer-link

- name: Replace the VPC configuration of listed port-channels
  cisco.nxos.nxos_vpc_interface:
    config:
      - name: port-channel10
        vpc: 200
    state: replaced

# Task output:
# ------------
# before:
#   - name: port-channel10
#     vpc: "100"
#   - name: port-channel20
#     peer_link: true
#
# commands:
#   - interface port-channel10
#   - no vpc
#   - vpc 200
#
# after:
#   - name: port-channel10
#     vpc: "200"
#   - name: port-channel20
#     peer_link: true

# Note: port-channel20 is unchanged because it is not in the config list.


# Using overridden

# Before state:
# -------------
# interface port-channel10
#   vpc 100
# interface port-channel20
#   vpc peer-link
# interface port-channel30
#   vpc 300

- name: Override all VPC interface configuration with provided configuration
  cisco.nxos.nxos_vpc_interface:
    config:
      - name: port-channel10
        vpc: 100
      - name: port-channel20
        peer_link: true
    state: overridden

# Task output:
# ------------
# before:
#   - name: port-channel10
#     vpc: "100"
#   - name: port-channel20
#     peer_link: true
#   - name: port-channel30
#     vpc: "300"
#
# commands:
#   - interface port-channel30
#   - no vpc
#
# after:
#   - name: port-channel10
#     vpc: "100"
#   - name: port-channel20
#     peer_link: true

# Note: port-channel30 is removed because it is not in the want list.


# Using deleted

# Before state:
# -------------
# interface port-channel10
#   vpc 100
# interface port-channel20
#   vpc peer-link

- name: Delete the VPC configuration of listed port-channels
  cisco.nxos.nxos_vpc_interface:
    config:
      - name: port-channel10
    state: deleted

# Task output:
# ------------
# before:
#   - name: port-channel10
#     vpc: "100"
#   - name: port-channel20
#     peer_link: true
#
# commands:
#   - interface port-channel10
#   - no vpc
#
# after:
#   - name: port-channel20
#     peer_link: true

# Using deleted (no config — removes all VPC interface configuration)

- name: Delete the VPC configuration of all port-channels
  cisco.nxos.nxos_vpc_interface:
    state: deleted

# Task output:
# ------------
# commands:
#   - interface port-channel10
#   - no vpc
#   - interface port-channel20
#   - no vpc peer-link


# Using gathered

# Existing device config:
# -----------------------
# interface port-channel10
#   vpc 100
# interface port-channel20
#   vpc peer-link

- name: Gather VPC interface facts from the device
  cisco.nxos.nxos_vpc_interface:
    state: gathered

# Task output:
# ------------
# gathered:
#   - name: port-channel10
#     vpc: "100"
#   - name: port-channel20
#     peer_link: true


# Using rendered

- name: Render platform specific configuration lines
  cisco.nxos.nxos_vpc_interface:
    config:
      - name: port-channel10
        vpc: 100
      - name: port-channel20
        peer_link: true
    state: rendered

# Task output:
# ------------
# rendered:
#   - interface port-channel10
#   - vpc 100
#   - interface port-channel20
#   - vpc peer-link


# Using parsed

# parsed.cfg
# ----------
# interface port-channel10
#   vpc 100
# interface port-channel20
#   vpc peer-link

- name: Parse externally supplied configuration into structured data
  cisco.nxos.nxos_vpc_interface:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Task output:
# ------------
# parsed:
#   - name: port-channel10
#     vpc: "100"
#   - name: port-channel20
#     peer_link: true

Return Values

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

Key

Description

after

list / elements=string

The resulting configuration after module execution.

Returned: when changed

Sample: ["This output will always be in the same format as the module argspec.\n"]

before

list / elements=string

The configuration prior to the module execution.

Returned: when state is merged, replaced, overridden or deleted

Sample: ["This output will always be in the same format as the module argspec.\n"]

commands

list / elements=string

The set of commands pushed to the remote device.

Returned: when state is merged, replaced, overridden or deleted

Sample: ["interface port-channel10", "vpc 100", "interface port-channel20", "vpc peer-link"]

gathered

list / elements=string

Facts about the network resource gathered from the remote device as structured data.

Returned: when state is gathered

Sample: ["This output will always be in the same format as the module argspec.\n"]

parsed

list / elements=string

The device native config provided in running_config option, parsed into structured data.

Returned: when state is parsed

Sample: ["This output will always be in the same format as the module argspec.\n"]

rendered

list / elements=string

The provided configuration rendered in device-native format (offline).

Returned: when state is rendered

Sample: ["interface port-channel10", "vpc 100"]

Authors

  • Jason Edelman (@jedelman8)

  • Gabriele Gerbino (@GGabriele)

  • Jorgen Spange (@jorgenspange)