cisco.nxos.nxos_vrf_interfaces module – Resource module to configure VRF interfaces.
Note
This module is part of the cisco.nxos collection (version 9.3.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_vrf_interfaces
.
New in cisco.nxos 1.0.0
Synopsis
This module configures and manages the VRF configuration on interfaces on NX-OS platforms.
Parameters
Parameter |
Comments |
---|---|
A list of interface VRF configurations. |
|
Full name of the interface excluding any logical unit number, i.e. Ethernet1/1. |
|
Name of the VRF to be configured on the interface. When configured, applies ‘vrf member <vrf_name>’ under the interface. |
|
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 interface. The state parsed reads the configuration from |
|
The state the configuration should be left in Choices:
|
Notes
Note
Tested against Cisco NX-OS.
This module works with connection
network_cli
.
Examples
# Using merged
# Before state:
# -------------
#
# nxos#show running-config interface
# interface Ethernet1/1
# no switchport
# interface Ethernet1/2
# description test
# no switchport
# no shutdown
# interface Ethernet1/3
# interface Ethernet1/4
# no switchport
# speed 1000
# no shutdown
- name: Merge provided configuration with device configuration
cisco.nxos.nxos_vrf_interfaces:
config:
- name: Ethernet1/1
- name: Ethernet1/2
vrf_name: test
- name: Ethernet1/3
- name:Ethernet1/4
state: merged
# Task Output:
# ------------
#
# before:
# - name: "Ethernet1/1"
# - name: "Ethernet1/2"
# - name: "Ethernet1/3"
# - name: "Ethernet1/4"
#
# commands:
# - interface Ethernet1/2
# - vrf member test
#
# after:
# - name: "Ethernet1/1"
# - name: "Ethernet1/2"
# vrf_name: "test2"
# - name: "Ethernet1/3"
# - name: "Ethernet1/4"
# After state:
# ------------
#
# nxos#show running-config interface
# interface Ethernet1/1
# no ip address
# interface Ethernet1/2
# vrf member test
# no ip address
# shutdown
# negotiation auto
# interface Ethernet1/3
# no ip address
# negotiation auto
# interfaceEthernet1/4
# no ip address
# shutdown
# negotiation auto
# Using overridden
# Before state:
# -------------
#
# nxos#show running-config interface
# interface Ethernet1/1
# no ip address
# interface Ethernet1/1
# ip address dhcp
# negotiation auto
# interface Ethernet1/2
# vrf member vrf_B
# no ip address
# shutdown
# negotiation auto
# interface Ethernet1/3
# no ip address
# negotiation auto
# interface Ethernet1/4
# no ip address
# shutdown
# negotiation auto
- name: Override device configuration with provided configuration
cisco.nxos.nxos_vrf_interfaces:
config:
- name: Ethernet1/1
- name: Ethernet1/2
- name: Ethernet1/3
- name: Ethernet1/4
state: overridden
# Task Output:
# ------------
#
# before:
# - name: "Ethernet1/1"
# - name: "Ethernet1/2"
# vrf_name: "vrf_B"
# - name: "Ethernet1/3"
# - name: "Ethernet1/4"
#
# commands:
# - interface Ethernet1/2
# - no vrf member vrf_B
#
# after:
# - name: "Ethernet1/1"
# - name: "Ethernet1/2"
# - name: "Ethernet1/3"
# - name: "Ethernet1/4"
# After state:
# ------------
#
# nxos#show running-config interface
# interface Ethernet1/1
# no ip address
# interface Ethernet1/2
# no ip address
# shutdown
# negotiation auto
# interface Ethernet1/3
# no ip address
# negotiation auto
# interface Ethernet1/4
# no ip address
# shutdown
# negotiation auto
# Using gathered
# Before state:
# -------------
#
# nxos#show running-config interface
# interface Ethernet1/1
# no ip address
# interface Ethernet1/2
# vrf member vrf_B
# no ip address
# shutdown
# negotiation auto
# interface Ethernet1/3
# no ip address
# negotiation auto
# interfaceEthernet1/4
# no ip address
# shutdown
# negotiation auto
- name: Gather listed VRF interfaces
cisco.nxos.nxos_vrf_interfaces:
state: gathered
# Task Output:
# ------------
#
# gathered:
# - name: "Ethernet1/1"
# - name: "Ethernet1/2"
# vrf_name: "vrf_B"
# - name: "Ethernet1/3"
# Using rendered
- name: Render VRF configuration
cisco.nxos.nxos_vrf_interfaces:
config:
- name: Ethernet1/1
- name: Ethernet1/2
vrf_name: test
- name: Ethernet1/3
- name: Ethernet1/4
state: rendered
# Task Output:
# ------------
#
# rendered:
# - interface Ethernet1/2
# - vrf member test
# Using parsed
# File: parsed.cfg
# ---------------
#
# interface Ethernet1/2
# no switchport
# vrf member VRF1
# interface Ethernet1/6
# no switchport
# speed 1000
# vrf member TEST_VRF
- name: Parse configuration from device running config
cisco.nxos.nxos_vrf_interfaces:
running_config: "{{ lookup('file', 'parsed.cfg') }}"
state: parsed
# Task Output:
# ------------
#
# parsed:
# - name: "Ethernet1/2"
# vrf_name: "VRF1"
# - name: "Ethernet1/6"
# vrf_name: "TEST_VRF"
# Using replaced
# Before state:
# -------------
#
# nxos#show running-config interface
# interface Ethernet1/1
# no ip address
# interface Ethernet1/2
# vrf member vrf_B
# no ip address
# shutdown
# interface Ethernet1/3
# no ip address
# interfaceEthernet1/4
# vrf member vrf_C
# no ip address
# shutdown
- name: Replace device configuration of listed VRF interfaces with provided configuration
cisco.nxos.nxos_vrf_interfaces:
config:
- name: Ethernet1/1
vrf_name: test
- name: Ethernet1/2
vrf_name: vrf_E
state: replaced
# Task Output:
# ------------
#
# before:
# - name: "Ethernet1/1"
# vrf_name: "vrf_A"
# - name: "Ethernet1/2"
# vrf_name: "vrf_B"
# - name: "Ethernet1/3"
# - name: "Ethernet1/4"
# vrf_name: "vrf_C"
#
# commands:
# - interface Ethernet1/1
# - no vrf member vrf_A
# - vrf member test
# - interface Ethernet1/2
# - no vrf member vrf_B
# - vrf member vrf_E
#
# after:
# - name: "Ethernet1/1"
# vrf_name: "test"
# - name: "Ethernet1/2"
# vrf_name: "vrf_E"
# - name: "Ethernet1/3"
# - name: "Ethernet1/4"
# vrf_name: "vrf_C"
# Using deleted
# Before state:
# -------------
#
# nxos#show running-config interface
# interface Ethernet1/1
# vrf member vrf_A
# ip address dhcp
# interface Ethernet1/2
# vrf member vrf_B
# no ip address
# shutdown
# interface Ethernet1/3
# no ip address
# interfaceEthernet1/4
# vrf member vrf_C
# no ip address
# shutdown
- name: Delete VRF configuration of specified interfaces
cisco.nxos.nxos_vrf_interfaces:
config:
- name: Ethernet1/1
- name: Ethernet1/2
state: deleted
# Task Output:
# ------------
#
# before:
# - name: "Ethernet1/1"
# vrf_name: "vrf_A"
# - name: "Ethernet1/2"
# vrf_name: "vrf_B"
# - name: "Ethernet1/3"
# - name: "Ethernet1/4"
# vrf_name: "vrf_C"
#
# commands:
# - interface Ethernet1/1
# - no vrf member vrf_A
# - interface Ethernet1/2
# - no vrf member vrf_B
#
# after:
# - name: "Ethernet1/1"
# - name: "Ethernet1/1"
# - name: "Ethernet1/2"
# - name: "Ethernet1/3"
# - name: "Ethernet1/4"
# vrf_name: "vrf_C"
# After state:
# ------------
#
# nxos#show running-config interface
# interface Ethernet1/1
# ip address dhcp
# interface Ethernet1/2
# no ip address
# shutdown
# interface Ethernet1/3
# no ip address
# interfaceEthernet1/4
# vrf member vrf_C
# no ip address
# shutdown
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The resulting configuration after module execution. Returned: when changed Sample: |
|
The configuration prior to the module execution. Returned: when state is Sample: |
|
The set of commands pushed to the remote device. Returned: when state is Sample: |
|
Facts about the network resource gathered from the remote device as structured data. Returned: when state is Sample: |
|
The device native config provided in running_config option parsed into structured data as per module argspec. Returned: when state is Sample: |
|
The provided configuration in the task rendered in device-native format (offline). Returned: when state is Sample: |