cisco.iosxr.iosxr_vrf_interfaces module – Resource module to configure VRF interfaces.

Note

This module is part of the cisco.iosxr collection (version 10.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.iosxr.

To use it in a playbook, specify: cisco.iosxr.iosxr_vrf_interfaces.

New in cisco.iosxr 10.3.0

Synopsis

  • This module configures and manages the VRF configuration in interface on IOS XR platforms.

Aliases: vrf_interfaces

Parameters

Parameter

Comments

config

list / elements=dictionary

A list of VRF interfaces options.

name

string / required

Full name of the interface excluding any logical unit number, i.e. GigabitEthernet0/0/0/1.

vrf_name

string

Vrf that is to be added to 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 IOS device by executing the command sh 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

The state the configuration should be left in

The states rendered, gathered and parsed does not perform any change on the device.

The state rendered will transform the configuration in config option to platform specific CLI commands which will be returned in the rendered key within the result. For state rendered active connection to remote host is not required.

The state gathered will fetch the running configuration from device and transform it into structured data in the format as per the resource module argspec and the value is returned in the gathered key within the result.

The state parsed reads the configuration from running_config option and transforms it into JSON format as per the resource module parameters and the value is returned in the parsed key within the result. The value of running_config option should be the same format as the output of command show running-config | include ip route|ipv6 route executed on device. For state parsed active connection to remote host is not required.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "rendered"

  • "parsed"

Notes

Note

  • Tested against Cisco IOS-XR 7.2.2.

  • This module works with connection network_cli.

Examples

# Using merged

# Before state:
# -------------
#
# viosxr#show running-config interfaces
# interface MgmtEth0/RP0/CPU0/0
#  ipv4 address dhcp
# !
# interface GigabitEthernet0/0/0/0
#  description this is interface0
#  cdp
# !
# interface GigabitEthernet0/0/0/1
#  shutdown
# !
# interface GigabitEthernet0/0/0/2
#  shutdown
# !

- name: Simple merge selective
  cisco.iosxr.iosxr_vrf_interfaces:
    state: merged
    config:
      - name: MgmtEth0/RP0/CPU0/0
      - name: GigabitEthernet0/0/0/0
      - name: GigabitEthernet0/0/0/1
        vrf_name: vrf_C
      - name: GigabitEthernet0/0/0/2
        vrf_name: vrf_D

# Task Output
# -----------
#
# before:
#   - name: MgmtEth0/RP0/CPU0/0
#   - name: GigabitEthernet0/0/0/0
#   - name: GigabitEthernet0/0/0/1
#   - name: GigabitEthernet0/0/0/2
# commands:
#   - interface GigabitEthernet0/0/0/1
#   - vrf vrf_C
#   - interface GigabitEthernet0/0/0/2
#   - vrf vrf_D
# after:
#   - name: MgmtEth0/RP0/CPU0/0
#   - name: GigabitEthernet0/0/0/0
#   - name: GigabitEthernet0/0/0/1
#     vrf_name: vrf_C
#   - name: GigabitEthernet0/0/0/2
#     vrf_name: vrf_D

# After state:
# -------------
#
# viosxr#show running-config interfaces
# interface MgmtEth0/RP0/CPU0/0
#  ipv4 address dhcp
# !
# interface GigabitEthernet0/0/0/0
#  description this is interface0
#  cdp
# !
# interface GigabitEthernet0/0/0/1
#  vrf vrf_C
#  shutdown
# !
# interface GigabitEthernet0/0/0/2
#  vrf vrf_D
#  shutdown
# !

# Using replaced

# Before state:
# -------------
#
# viosxr#show running-config interfaces
# interface MgmtEth0/RP0/CPU0/0
#  ipv4 address dhcp
# !
# interface GigabitEthernet0/0/0/0
#  description this is interface0
#  cdp
# !
# interface GigabitEthernet0/0/0/1
#  vrf vrf_C
#  shutdown
# !
# interface GigabitEthernet0/0/0/2
#  vrf vrf_D
#  shutdown
# !

- name: Simple replaced selective
  cisco.iosxr.iosxr_vrf_interfaces:
    state: replaced
    config:
      - name: MgmtEth0/RP0/CPU0/0
      - name: GigabitEthernet0/0/0/0
      - name: GigabitEthernet0/0/0/1
        vrf_name: vrf_E
      - name: GigabitEthernet0/0/0/2
        vrf_name: vrf_D

# Task Output
# -----------
#
# before:
#   - name: MgmtEth0/RP0/CPU0/0
#   - name: GigabitEthernet0/0/0/0
#   - name: GigabitEthernet0/0/0/1
#     vrf_name: vrf_C
#   - name: GigabitEthernet0/0/0/2
#     vrf_name: vrf_D
# commands:
#   - interface GigabitEthernet0/0/0/1
#   - vrf vrf_E
# after:
#   - name: MgmtEth0/RP0/CPU0/0
#   - name: GigabitEthernet0/0/0/0
#   - name: GigabitEthernet0/0/0/1
#     vrf_name: vrf_E
#   - name: GigabitEthernet0/0/0/2
#     vrf_name: vrf_D

# After state:
# -------------
#
# viosxr#show running-config interfaces
# interface MgmtEth0/RP0/CPU0/0
#  ipv4 address dhcp
# !
# interface GigabitEthernet0/0/0/0
#  description this is interface0
#  cdp
# !
# interface GigabitEthernet0/0/0/1
#  vrf vrf_E
#  shutdown
# !
# interface GigabitEthernet0/0/0/2
#  vrf vrf_D
#  shutdown
# !

# Using overridden

# Before state:
# -------------
#
# viosxr#show running-config interfaces
# interface MgmtEth0/RP0/CPU0/0
#  ipv4 address dhcp
# !
# interface GigabitEthernet0/0/0/0
#  description this is interface0
#  cdp
# !
# interface GigabitEthernet0/0/0/1
#  vrf vrf_C
#  shutdown
# !
# interface GigabitEthernet0/0/0/2
#  vrf vrf_D
#  shutdown
# !

- name: Simple overridden selective
  cisco.iosxr.iosxr_vrf_interfaces:
    state: overridden
    config:
      - name: MgmtEth0/RP0/CPU0/0
      - name: GigabitEthernet0/0/0/0
      - name: GigabitEthernet0/0/0/1
        vrf_name: vrf_E

# Task Output
# -----------
#
# before:
#   - name: MgmtEth0/RP0/CPU0/0
#   - name: GigabitEthernet0/0/0/0
#   - name: GigabitEthernet0/0/0/1
#     vrf_name: vrf_C
#   - name: GigabitEthernet0/0/0/2
#     vrf_name: vrf_D
# commands:
#   - interface GigabitEthernet0/0/0/1
#   - vrf vrf_E
#   - interface GigabitEthernet0/0/0/2
#   - no vrf vrf_E
# after:
#   - name: MgmtEth0/RP0/CPU0/0
#   - name: GigabitEthernet0/0/0/0
#   - name: GigabitEthernet0/0/0/1
#     vrf_name: vrf_E
#   - name: GigabitEthernet0/0/0/2

# After state:
# -------------
#
# viosxr#show running-config interfaces
# interface MgmtEth0/RP0/CPU0/0
#  ipv4 address dhcp
# !
# interface GigabitEthernet0/0/0/0
#  description this is interface0
#  cdp
# !
# interface GigabitEthernet0/0/0/1
#  vrf vrf_E
#  shutdown
# !
# interface GigabitEthernet0/0/0/2
#  shutdown
# !

# Using deleted

# Before state:
# -------------
#
# viosxr#show running-config interfaces
# interface MgmtEth0/RP0/CPU0/0
#  ipv4 address dhcp
# !
# interface GigabitEthernet0/0/0/0
#  description this is interface0
#  cdp
# !
# interface GigabitEthernet0/0/0/1
#  vrf vrf_E
#  shutdown
# !
# interface GigabitEthernet0/0/0/2
#  vrf vrf_D
#  shutdown
# !

- name: Simple deleted selective
  cisco.iosxr.iosxr_vrf_interfaces:
    state: deleted
    config:
      - name: GigabitEthernet0/0/0/1
        vrf_name: vrf_E

# Task Output
# -----------
#
# before:
#   - name: MgmtEth0/RP0/CPU0/0
#   - name: GigabitEthernet0/0/0/0
#   - name: GigabitEthernet0/0/0/1
#     vrf_name: vrf_E
#   - name: GigabitEthernet0/0/0/2
#     vrf_name: vrf_D
# commands:
#   - interface GigabitEthernet0/0/0/1
#   - no vrf vrf_E
# after:
#   - name: MgmtEth0/RP0/CPU0/0
#   - name: GigabitEthernet0/0/0/0
#   - name: GigabitEthernet0/0/0/1
#   - name: GigabitEthernet0/0/0/2
#     vrf_name: vrf_D

# After state:
# -------------
#
# viosxr#show running-config interfaces
# interface MgmtEth0/RP0/CPU0/0
#  ipv4 address dhcp
# !
# interface GigabitEthernet0/0/0/0
#  description this is interface0
#  cdp
# !
# interface GigabitEthernet0/0/0/1
#  shutdown
# !
# interface GigabitEthernet0/0/0/2
#  vrf vrf_D
#  shutdown
# !

# Using gathered

# Before state:
# -------------
#
# viosxr#show running-config interfaces
# interface MgmtEth0/RP0/CPU0/0
#  ipv4 address dhcp
# !
# interface GigabitEthernet0/0/0/0
#  description this is interface0
#  cdp
# !
# interface GigabitEthernet0/0/0/1
#  vrf vrf_C
#  shutdown
# !
# interface GigabitEthernet0/0/0/2
#  vrf vrf_D
#  shutdown
# !

- name: Simple gathered selective
  cisco.iosxr.iosxr_vrf_interfaces:
    state: gathered

# Task Output
# -----------
#
# gathered:
#   - name: MgmtEth0/RP0/CPU0/0
#   - name: GigabitEthernet0/0/0/0
#   - name: GigabitEthernet0/0/0/1
#     vrf_name: vrf_C
#   - name: GigabitEthernet0/0/0/2
#     vrf_name: vrf_D

# Using rendered

# Before state:
# -------------
#
# viosxr#show running-config interfaces
# interface MgmtEth0/RP0/CPU0/0
#  ipv4 address dhcp
# !
# interface GigabitEthernet0/0/0/0
#  description this is interface0
#  cdp
# !
# interface GigabitEthernet0/0/0/1
#  vrf vrf_C
#  shutdown
# !
# interface GigabitEthernet0/0/0/2
#  vrf vrf_D
#  shutdown
# !

- name: Simple rendered selective
  cisco.iosxr.iosxr_vrf_interfaces:
    state: rendered

# Task Output
# -----------
#
# commands:
#   - interface GigabitEthernet0/0/0/1
#   - vrf vrf_C
#   - interface GigabitEthernet0/0/0/2
#   - vrf vrf_D

Return Values

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

Key

Description

after

dictionary

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

dictionary

The configuration prior to the module execution.

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

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, deleted or purged

Sample: ["interface GigabitEthernet0/0/0/1", "no vrf test_vrf1", "vrf test_vrf2"]

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 as per module argspec.

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 in the task rendered in device-native format (offline).

Returned: when state is rendered

Sample: ["interface GigabitEthernet0/0/0/1", "no vrf test_vrf1", "vrf test_vrf2"]

Authors

  • Sagar Paul (@KB-perByte)