cisco.nxos.nxos_evpn_vnis module – EVPN VNIs 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_evpn_vnis.

New in cisco.nxos 13.1.0

Synopsis

  • This module manages the Layer 2 VNIs configured under the evpn section (vni <id> l2) on Cisco NX-OS devices, with their route distinguisher and route targets.

  • It is the resource module counterpart of cisco.nxos.nxos_evpn_vni, which manages a single VNI per task.

Note

This module has a corresponding action plugin.

Aliases: evpn_vnis

Parameters

Parameter

Comments

config

list / elements=dictionary

A list of EVPN VNI configurations.

route_distinguisher

string

Route distinguisher of the VNI, either auto or in the form ASN:NN or IP:NN.

route_target_both

list / elements=string

Route targets to both import and export, auto or in the form ASN:NN or IP:NN.

Merged into route_target_import and route_target_export.

route_target_export

list / elements=string

Route targets to export, auto or in the form ASN:NN or IP:NN.

route_target_import

list / elements=string

Route targets to import, auto or in the form ASN:NN or IP:NN.

vni

integer / required

The Layer 2 VNI identifier.

Valid range is 1-16777214.

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 ^evpn.

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.

With deleted, the VNIs listed in config are removed, or all VNIs when config is not given.

With overridden, VNIs that are not listed in config are removed.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "rendered"

  • "parsed"

Notes

Note

  • Tested against NX-OS 10.6(4) on N9K-C93180YC-FX.

  • Unsupported for Cisco MDS.

  • nv overlay evpn must be enabled for the evpn section to be available.

  • route_target_both is an input convenience. It is expanded into route_target_import and route_target_export before comparing with the device and is never returned by gathered or parsed. If the device displays route-target both, it is parsed as an import and an export.

  • Under merged, route targets are only added and the route distinguisher is only replaced, nothing is removed.

  • Under replaced and overridden, route targets and the route distinguisher of a listed VNI that are not in config are removed.

  • Layer 3 VNIs (vni <id> l3 under vrf context) are not managed by this module.

  • This module works with connection network_cli and httpapi. See https://docs.ansible.com/ansible/latest/network/user_guide/platform_nxos.html

  • The parsed state reads configuration from running_config and does not connect to the device.

  • For information on using CLI and NX-API see the NXOS Platform Options guide https://docs.ansible.com/ansible/latest/network/user_guide/platform_nxos.html.

  • For more information on using Ansible to manage network devices see the Ansible Network Guide https://docs.ansible.com/ansible/latest/network/getting_started/index.html.

  • For more information on using Ansible to manage Cisco devices see the Cisco integration page https://www.ansible.com/integrations/networks/cisco.

Examples

# Using merged

# Before state:
# -------------
# nxos# show running-config | section ^evpn
# evpn
#   vni 10100 l2
#     rd auto

- name: Merge the provided configuration with the existing running configuration
  cisco.nxos.nxos_evpn_vnis:
    config:
      - vni: 10100
        route_target_both:
          - auto
      - vni: 10200
        route_distinguisher: 65000:10200
        route_target_import:
          - 65000:10200
        route_target_export:
          - 65000:10200
    state: merged

# Task output:
# ------------
# commands:
#   - evpn
#   - vni 10100 l2
#   - route-target import auto
#   - route-target export auto
#   - vni 10200 l2
#   - rd 65000:10200
#   - route-target import 65000:10200
#   - route-target export 65000:10200

# After state:
# ------------
# nxos# show running-config | section ^evpn
# evpn
#   vni 10100 l2
#     rd auto
#     route-target import auto
#     route-target export auto
#   vni 10200 l2
#     rd 65000:10200
#     route-target import 65000:10200
#     route-target export 65000:10200

# Using replaced

# Before state:
# -------------
# evpn
#   vni 10100 l2
#     rd auto
#     route-target import auto
#     route-target export auto
#   vni 10200 l2
#     rd 65000:10200

- name: Replace the configuration of the listed VNIs only
  cisco.nxos.nxos_evpn_vnis:
    config:
      - vni: 10100
        route_distinguisher: auto
        route_target_import:
          - 65000:10100
    state: replaced

# Task output:
# ------------
# commands:
#   - evpn
#   - vni 10100 l2
#   - no route-target import auto
#   - no route-target export auto
#   - route-target import 65000:10100

# Using overridden

# Before state:
# -------------
# evpn
#   vni 10100 l2
#     rd auto
#   vni 10200 l2
#     rd 65000:10200

- name: Override all VNIs with the provided configuration
  cisco.nxos.nxos_evpn_vnis:
    config:
      - vni: 10100
        route_distinguisher: auto
    state: overridden

# Task output:
# ------------
# commands:
#   - evpn
#   - no vni 10200 l2

# Using deleted

# Before state:
# -------------
# evpn
#   vni 10100 l2
#     rd auto
#   vni 10200 l2
#     rd 65000:10200

- name: Delete the listed VNIs (omit config to delete all of them)
  cisco.nxos.nxos_evpn_vnis:
    config:
      - vni: 10100
    state: deleted

# Task output:
# ------------
# commands:
#   - evpn
#   - no vni 10100 l2

# Using rendered

- name: Render platform specific configuration lines (without connecting to the device)
  cisco.nxos.nxos_evpn_vnis:
    config:
      - vni: 10100
        route_distinguisher: auto
        route_target_both:
          - auto
    state: rendered

# Task Output (redacted)
# -----------------------
# rendered:
#   - evpn
#   - vni 10100 l2
#   - rd auto
#   - route-target import auto
#   - route-target export auto

# Using parsed

# parsed.cfg
# ------------
# evpn
#   vni 10100 l2
#     rd auto
#     route-target import auto
#     route-target export auto

- name: Parse the provided configuration
  cisco.nxos.nxos_evpn_vnis:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Task output (redacted)
# -----------------------
# parsed:
#   - vni: 10100
#     route_distinguisher: auto
#     route_target_import:
#       - auto
#     route_target_export:
#       - auto

# Using gathered

- name: Gather the VNI configuration from the device
  cisco.nxos.nxos_evpn_vnis:
    state: gathered

# Task output (redacted)
# -----------------------
# gathered:
#   - vni: 10100
#     route_distinguisher: auto
#     route_target_import:
#       - auto
#     route_target_export:
#       - auto

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: ["evpn", "vni 10100 l2", "rd auto", "route-target import auto"]

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: ["evpn", "vni 10100 l2", "rd auto"]

Authors

  • Jorgen Spange (@jorgenspange)