.. _cisco.nxos.nxos_vrf_interfaces_module: ****************************** cisco.nxos.nxos_vrf_interfaces ****************************** **Resource module to configure VRF interfaces.** Version added: 9.3.0 .. contents:: :local: :depth: 1 Synopsis -------- - This module configures and manages the VRF configuration on interfaces on NX-OS platforms. Parameters ---------- .. raw:: html
Parameter Choices/Defaults Comments
config
list / elements=dictionary
A list of interface VRF configurations.
name
string / required
Full name of the interface excluding any logical unit number, i.e. Ethernet1/1.
vrf_name
string
Name of the VRF to be configured on the interface.
When configured, applies 'vrf member <vrf_name>' under the interface.
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 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
    Choices:
  • merged ←
  • replaced
  • overridden
  • deleted
  • gathered
  • rendered
  • parsed
The state the configuration should be left in

Notes ----- .. note:: - Tested against Cisco NX-OS. - This module works with connection ``network_cli``. Examples -------- .. code-block:: yaml # 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: .. raw:: html
Key Returned Description
after
list
when changed
The resulting configuration after module execution.

Sample:
[ { "name": "Ethernet1/1" }, { "name": "Ethernet1/2", "vrf_name": "test" }, { "name": "Ethernet1/3" }, { "name": "Ethernet1/4" } ]
before
list
when state is merged, replaced, overridden, deleted
The configuration prior to the module execution.

Sample:
[ { "name": "Ethernet1/1" }, { "name": "Ethernet1/2", "vrf_name": "test" }, { "name": "Ethernet1/3" }, { "name": "Ethernet1/4" } ]
commands
list
when state is merged, replaced, overridden, deleted
The set of commands pushed to the remote device.

Sample:
['interface Ethernet1/2', 'vrf member test', 'no vrf member vrf_B']
gathered
list
when state is gathered
Facts about the network resource gathered from the remote device as structured data.

Sample:
[ { "name": "Ethernet1/1" }, { "name": "Ethernet1/2", "vrf_name": "vrf_B" }, { "name": "Ethernet1/3" }, { "name": "Ethernet1/4" } ]
parsed
list
when state is parsed
The device native config provided in running_config option parsed into structured data as per module argspec.

Sample:
[ { "name": "Ethernet1/1", "vrf_name": "vrf_C" }, { "name": "Ethernet1/2", "vrf_name": "test" }, { "name": "Ethernet1/3" }, { "name": "Ethernet1/4" } ]
rendered
list
when state is rendered
The provided configuration in the task rendered in device-native format (offline).

Sample:
['interface Ethernet1/1', 'vrf member vrf_C', 'interface Ethernet1/2', 'vrf member test']


Status ------ Authors ~~~~~~~ - Ruchi Pakhle (@Ruchip16)