cisco.ios.ios_vrf_interfaces module – Manages VRF configuration on interfaces.
Note
This module is part of the cisco.ios collection (version 9.1.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.ios
.
To use it in a playbook, specify: cisco.ios.ios_vrf_interfaces
.
New in cisco.ios 1.0.0
Synopsis
Manages Virtual Routing and Forwarding (VRF) configuration on interfaces of Cisco IOS devices.
Parameters
Parameter |
Comments |
---|---|
A list of interface VRF configurations. |
|
Full name of the interface to be configured. Example - GigabitEthernet1, Loopback24 |
|
Name of the VRF to be configured on the interface. When configured, applies ‘vrf forwarding <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 IOS device by executing the command show running-config | section ^interface. The state parsed reads the configuration from |
|
The state the configuration should be left in. Choices:
|
Notes
Note
Tested against Cisco IOS XE Version 17.13.01a
VRF must exist before assigning to an interface
When removing VRF from interface, associated IP addresses will be removed
For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>`
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:
# -------------
#
# vios#show running-config | section ^interface
# interface Loopback24
# no ip address
# interface GigabitEthernet1
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# shutdown
# negotiation auto
# interface GigabitEthernet3
# no ip address
# negotiation auto
# interface GigabitEthernet4
# no ip address
# shutdown
# negotiation auto
- name: Merge provided configuration with device configuration
cisco.ios.ios_vrf_interfaces:
config:
- name: GigabitEthernet1
- name: GigabitEthernet2
vrf_name: vrf_D
- name: GigabitEthernet3
- name: GigabitEthernet4
state: merged
# Task Output:
# ------------
#
# before:
# - name: "Loopback24"
# - name: "GigabitEthernet1"
# - name: "GigabitEthernet2"
# - name: "GigabitEthernet3"
# - name: "GigabitEthernet4"
#
# commands:
# - interface GigabitEthernet2
# - vrf forwarding vrf_D
#
# after:
# - name: "Loopback24"
# - name: "GigabitEthernet1"
# - name: "GigabitEthernet2"
# vrf_name: "vrf_D"
# - name: "GigabitEthernet3"
# - name: "GigabitEthernet4"
# After state:
# ------------
#
# vios#show running-config | section ^interface
# interface Loopback24
# no ip address
# interface GigabitEthernet1
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# vrf forwarding vrf_D
# no ip address
# shutdown
# negotiation auto
# interface GigabitEthernet3
# no ip address
# negotiation auto
# interface GigabitEthernet4
# no ip address
# shutdown
# negotiation auto
# Using overridden
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Loopback24
# no ip address
# interface GigabitEthernet1
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# vrf forwarding vrf_B
# no ip address
# shutdown
# negotiation auto
# interface GigabitEthernet3
# no ip address
# negotiation auto
# interface GigabitEthernet4
# no ip address
# shutdown
# negotiation auto
- name: Override device configuration with provided configuration
cisco.ios.ios_vrf_interfaces:
config:
- name: GigabitEthernet1
- name: GigabitEthernet2
- name: GigabitEthernet3
- name: GigabitEthernet4
state: overridden
# Task Output:
# ------------
#
# before:
# - name: "Loopback24"
# - name: "GigabitEthernet1"
# - name: "GigabitEthernet2"
# vrf_name: "vrf_B"
# - name: "GigabitEthernet3"
# - name: "GigabitEthernet4"
#
# commands:
# - interface GigabitEthernet2
# - no vrf forwarding vrf_B
#
# after:
# - name: "Loopback24"
# - name: "GigabitEthernet1"
# - name: "GigabitEthernet2"
# - name: "GigabitEthernet3"
# - name: "GigabitEthernet4"
# After state:
# ------------
#
# vios#show running-config | section ^interface
# interface Loopback24
# no ip address
# interface GigabitEthernet1
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# shutdown
# negotiation auto
# interface GigabitEthernet3
# no ip address
# negotiation auto
# interface GigabitEthernet4
# no ip address
# shutdown
# negotiation auto
# Using gathered
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Loopback24
# no ip address
# interface GigabitEthernet1
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# vrf forwarding vrf_B
# no ip address
# shutdown
# negotiation auto
# interface GigabitEthernet3
# no ip address
# negotiation auto
# interface GigabitEthernet4
# no ip address
# shutdown
# negotiation auto
- name: Gather listed VRF interfaces
cisco.ios.ios_vrf_interfaces:
state: gathered
# Task Output:
# ------------
#
# gathered:
# - name: "Loopback24"
# - name: "GigabitEthernet1"
# - name: "GigabitEthernet2"
# vrf_name: "vrf_B"
# - name: "GigabitEthernet3"
# - name: "GigabitEthernet4"
# Using rendered
- name: Render VRF configuration
cisco.ios.ios_vrf_interfaces:
config:
- name: GigabitEthernet1
- name: GigabitEthernet2
vrf_name: vrf_D
- name: GigabitEthernet3
- name: GigabitEthernet4
state: rendered
# Task Output:
# ------------
#
# rendered:
# - interface GigabitEthernet2
# - vrf forwarding vrf_D
# Using parsed
# File: parsed.cfg
# ---------------
#
# interface GigabitEthernet1
# vrf vrf_C
# shutdown
# !
# interface GigabitEthernet2
# vrf vrf_D
# shutdown
# !
# interface GigabitEthernet3
# shutdown
# !
# interface GigabitEthernet4
# shutdown
# !
- name: Parse configuration from device running config
cisco.ios.ios_vrf_interfaces:
running_config: "{{ lookup('file', 'parsed.cfg') }}"
state: parsed
# Task Output:
# ------------
#
# parsed:
# - name: "GigabitEthernet1"
# vrf_name: "vrf_C"
# - name: "GigabitEthernet2"
# vrf_name: "vrf_D"
# - name: "GigabitEthernet3"
# - name: "GigabitEthernet4"
# Using replaced
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Loopback24
# no ip address
# interface GigabitEthernet1
# vrf forwarding vrf_A
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# vrf forwarding vrf_B
# no ip address
# shutdown
# negotiation auto
# interface GigabitEthernet3
# no ip address
# negotiation auto
# interface GigabitEthernet4
# vrf forwarding vrf_C
# no ip address
# shutdown
# negotiation auto
- name: Replace device configuration of listed VRF interfaces with provided configuration
cisco.ios.ios_vrf_interfaces:
config:
- name: GigabitEthernet1
vrf_name: vrf_D
- name: GigabitEthernet2
vrf_name: vrf_E
state: replaced
# Task Output:
# ------------
#
# before:
# - name: "Loopback24"
# - name: "GigabitEthernet1"
# vrf_name: "vrf_A"
# - name: "GigabitEthernet2"
# vrf_name: "vrf_B"
# - name: "GigabitEthernet3"
# - name: "GigabitEthernet4"
# vrf_name: "vrf_C"
#
# commands:
# - interface GigabitEthernet1
# - no vrf forwarding vrf_A
# - vrf forwarding vrf_D
# - interface GigabitEthernet2
# - no vrf forwarding vrf_B
# - vrf forwarding vrf_E
#
# after:
# - name: "Loopback24"
# - name: "GigabitEthernet1"
# vrf_name: "vrf_D"
# - name: "GigabitEthernet2"
# vrf_name: "vrf_E"
# - name: "GigabitEthernet3"
# - name: "GigabitEthernet4"
# vrf_name: "vrf_C"
# Using deleted
# Before state:
# -------------
#
# vios#show running-config | section ^interface
# interface Loopback24
# no ip address
# interface GigabitEthernet1
# vrf forwarding vrf_A
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# vrf forwarding vrf_B
# no ip address
# shutdown
# negotiation auto
# interface GigabitEthernet3
# no ip address
# negotiation auto
# interface GigabitEthernet4
# vrf forwarding vrf_C
# no ip address
# shutdown
# negotiation auto
- name: Delete VRF configuration of specified interfaces
cisco.ios.ios_vrf_interfaces:
config:
- name: GigabitEthernet1
- name: GigabitEthernet2
state: deleted
# Task Output:
# ------------
#
# before:
# - name: "Loopback24"
# - name: "GigabitEthernet1"
# vrf_name: "vrf_A"
# - name: "GigabitEthernet2"
# vrf_name: "vrf_B"
# - name: "GigabitEthernet3"
# - name: "GigabitEthernet4"
# vrf_name: "vrf_C"
#
# commands:
# - interface GigabitEthernet1
# - no vrf forwarding vrf_A
# - interface GigabitEthernet2
# - no vrf forwarding vrf_B
#
# after:
# - name: "Loopback24"
# - name: "GigabitEthernet1"
# - name: "GigabitEthernet2"
# - name: "GigabitEthernet3"
# - name: "GigabitEthernet4"
# vrf_name: "vrf_C"
# After state:
# ------------
#
# vios#show running-config | section ^interface
# interface Loopback24
# no ip address
# interface GigabitEthernet1
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# shutdown
# negotiation auto
# interface GigabitEthernet3
# no ip address
# negotiation auto
# interface GigabitEthernet4
# vrf forwarding vrf_C
# no ip address
# shutdown
# negotiation auto
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: |