cisco.iosxr.iosxr_vrf_address_family 模块 – 配置 VRF 地址族的资源模块。

注意

此模块是 cisco.iosxr 集合 (版本 10.2.2) 的一部分。

如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install cisco.iosxr

要在剧本中使用它,请指定:cisco.iosxr.iosxr_vrf_address_family

cisco.iosxr 10.0.0 新增

概要

  • 此模块配置和管理 Cisco IOS-XR 设备上 VRF 地址族的属性。

参数

参数

注释

config

列表 / 元素=字典

VRF 地址族配置。

address_families

列表 / 元素=字典

启用地址族并进入其配置模式 - AFI/SAFI 配置

afi

字符串

地址族标识符 (AFI)

选项

  • "ipv4"

  • "ipv6"

export

字典

VRF 出口

route_policy

字符串

使用 route_policy 进行出口

route_target

字符串

指定出口路由目标扩展社区。

to

字典

将路由导出到 VRF

default_vrf

字典

将路由导出到默认 VRF

route_policy

字符串

使用 route_policy 进行出口

vrf

字典

将路由导出到 VRF

allow_imported_vpn

布尔值

允许将导入的 VPN 路由导出到非默认 VRF

选项

  • false

  • true

import_config

字典

VRF 导入

from_config

字典

从 VRF 导入路由

bridge_domain

字典

VRF 导入

advertise_as_vpn

布尔值

将本地 EVPN 导入路由通告给 PE

选项

  • false

  • true

default_vrf

字典

将路由导出到默认 VRF

route_policy

字符串

使用 route_policy 进行出口

vrf

字典

从 VRF 导入路由

advertise_as_vpn

布尔值

将本地 EVPN 导入路由通告给 PE

选项

  • false

  • true

route_policy

字符串

使用 route_policy 进行出口

route_target

字符串

指定出口路由目标扩展社区。

maximum

字典

设置最大前缀限制

prefix

整数

设置表的最大前缀限制。

safi

字符串

地址族修饰符

选项

  • "flowspec"

  • "multicast"

  • "unicast"

name

字符串 / 必需

VRF 的名称。

running_config

字符串

此选项仅与状态 *parsed* 一起使用。

此选项的值应为通过执行命令 **show running-config vrf** 从 IOS-XR 设备接收到的输出。

状态 *parsed* 从 running_config 选项读取配置并将其转换为 Ansible 结构化数据,该数据符合资源模块的 argspec,然后在结果中的 *parsed* 密钥中返回该值。

state

字符串

配置应保留的状态

状态 *rendered*、*gathered* 和 *parsed* 不会对设备进行任何更改。

状态 *rendered* 将 config 选项中的配置转换为特定于平台的 CLI 命令,这些命令将在结果中的 *rendered* 密钥中返回。对于状态 *rendered*,不需要与远程主机的活动连接。

状态 *gathered* 将从设备获取运行配置,并将其转换为符合资源模块 argspec 格式的结构化数据,并在结果中的 *gathered* 密钥中返回该值。

状态 *parsed* 从 running_config 选项读取配置,并根据资源模块参数将其转换为 JSON 格式,并在结果中的 *parsed* 密钥中返回该值。running_config 选项的值应与命令 *show running-config vrf* 的输出格式相同。不需要与远程主机的连接。

选项

  • "parsed"

  • "gathered"

  • "deleted"

  • "merged" ← (默认)

  • "replaced"

  • "rendered"

  • "overridden"

备注

注意

  • 针对 Cisco IOS XR 版本 10.0.0 进行了测试

  • 此模块使用连接 network_cli。请参阅 IOS_XR 平台选项

  • 有关使用 Ansible 管理网络设备的更多信息,请参阅:ref:`Ansible 网络指南 <network_guide>`

  • 有关使用 Ansible 管理 Cisco 设备的更多信息,请参阅 `Cisco 集成页面 <https://ansible.org.cn/integrations/networks/cisco>`。

示例

# Using merged
#
# Before state:
# -------------
#
# RP/0/0/CPU0:iosxr#show running-config vrf
# vrf test
#

- name: Merge provided configuration with device configuration
  cisco.iosxr.iosxr_vrf_address_family:
    config:
      - name: VRF4
        address_families:
          - afi: "ipv4"
            safi: "unicast"
            export:
              route_target: "192.0.2.1:400"
              route_policy: "rm-policy"
              to:
                default_vrf:
                  route_policy: "rm-policy"
                vrf:
                  allow_imported_vpn: true
            import_config:
              route_target: "192.0.2.6:200"
              route_policy: "test-policy"
              from_config:
                bridge_domain:
                  advertise_as_vpn: true
                default_vrf:
                  route_policy: "test-policy"
                vrf:
                  advertise_as_vpn: true
            maximum:
              prefix: 100
    state: merged

# Task Output:
# ------------
#
# before: []
#
# commands:
# - vrf VRF4
# - address-family ipv4 unicast
# - export route-policy rm-policy
# - export route-target 192.0.2.1:400
# - export to default-vrf route-policy rm-policy
# - export to vrf allow-imported-vpn
# - import route-target 192.0.2.6:200
# - import route-policy test-policy
# - import from bridge-domain advertise-as-vpn
# - import from default-vrf route-policy test-policy
# - import from vrf advertise-as-vpn
# - maximum prefix 100
#
# after:
# - name: VRF4
#   address_families:
#     - afi: "ipv4"
#       safi: "unicast"
#       export:
#         route_target: "192.0.2.1:400"
#         route_policy: "rm-policy"
#         to:
#           default_vrf:
#             route_policy: "rm-policy"
#           vrf:
#             allow_imported_vpn: true
#       import_config:
#         route_target: "192.0.2.6:200"
#         route_policy: "test-policy"
#         from_config:
#           bridge_domain:
#             advertise_as_vpn: true
#           default_vrf:
#             route_policy: "test-policy"
#           vrf:
#             advertise_as_vpn: true
#       maximum:
#         prefix: 100
#
# After state:
# ------------
#
# RP/0/0/CPU0:iosxr#show running-config vrf
# vrf VRF4
#  address-family ipv4 unicast
#   export route-policy rm-policy
#   export route-target 192.0.2.1:400
#   export to default-vrf route-policy rm-policy
#   export to vrf allow-imported-vpn
#   import route-target 192.0.2.6:200
#   import route-policy test-policy
#   import from bridge-domain advertise-as-vpn
#   import from default-vrf route-policy test-policy
#   import from vrf advertise-as-vpn
#   maximum prefix 100

# Using replaced
#
# Before state:
# -------------
#
# RP/0/0/CPU0:iosxr#show running-config vrf
# vrf VRF4
#  address-family ipv4 unicast
#   export route-policy rm-policy
#   export route-target 192.0.2.1:400
#   export to default-vrf route-policy rm-policy
#   export to vrf allow-imported-vpn
#   import route-target 192.0.2.6:200
#   import route-policy test-policy
#   import from bridge-domain advertise-as-vpn
#   import from default-vrf route-policy test-policy
#   import from vrf advertise-as-vpn
#   maximum prefix 100

- name: Replace the provided configuration with the existing running configuration
  cisco.iosxr.iosxr_vrf_address_family:
    config:
      - name: VRF7
        address_families:
          - afi: "ipv4"
            safi: "unicast"
            export:
              route_target: "192.0.2.2:400"
              route_policy: "rm-policy"
              to:
                default_vrf:
                  route_policy: "rm-policy"
                vrf:
                  allow_imported_vpn: true
            import_config:
              route_target: "192.0.2.4:400"
              route_policy: "test-policy"
              from_config:
                bridge_domain:
                  advertise_as_vpn: true
                default_vrf:
                  route_policy: "test-policy"
                vrf:
                  advertise_as_vpn: true
            maximum:
              prefix: 200
    state: replaced

# Task Output:
# ------------
#
# - name: VRF4
#   address_families:
#     - afi: "ipv4"
#       safi: "unicast"
#       export:
#         route_target: "192.0.2.1:400"
#         route_policy: "rm-policy"
#         to:
#           default_vrf:
#             route_policy: "rm-policy"
#           vrf:
#             allow_imported_vpn: true
#       import_config:
#         route_target: "192.0.2.6:200"
#         route_policy: "test-policy"
#         from_config:
#           bridge_domain:
#             advertise_as_vpn: true
#           default_vrf:
#             route_policy: "test-policy"
#           vrf:
#             advertise_as_vpn: true
#       maximum:
#         prefix: 100
#
# commands:
# - vrf VRF7
# - address-family ipv4 unicast
# - export route-policy rm-policy
# - export route-target 192.0.2.2:400
# - export to default-vrf route-policy rm-policy
# - export to vrf allow-imported-vpn
# - import route-target 192.0.2.4:400
# - import route-policy test-policy
# - import from bridge-domain advertise-as-vpn
# - import from default-vrf route-policy test-policy
# - import from vrf advertise-as-vpn
# - maximum prefix 200
#
# after:
# - name: VRF7
#   address_families:
#     - afi: "ipv4"
#       safi: "unicast"
#       export:
#         route_target: "192.0.2.2:400"
#         route_policy: "rm-policy"
#         to:
#           default_vrf:
#             route_policy: "rm-policy"
#           vrf:
#             allow_imported_vpn: true
#       import_config:
#         route_target: "192.0.2.4:400"
#         route_policy: "test-policy"
#         from_config:
#           bridge_domain:
#             advertise_as_vpn: true
#           default_vrf:
#             route_policy: "test-policy"
#           vrf:
#             advertise_as_vpn: true
#       maximum:
#         prefix: 200
#
# After state:
# ------------
#
# RP/0/RP0/CPU0:iosxr(config)#show running-config vrf
# vrf VRF7
#  address-family ipv4 unicast
#   import route-policy test-policy
#   import from bridge-domain advertise-as-vpn
#   import from default-vrf route-policy test-policy
#   import from vrf advertise-as-vpn
#   import route-target
#    192.0.2.4:400
#   !
#   export route-policy rm-policy
#   export to vrf allow-imported-vpn
#   export to default-vrf route-policy rm-policy
#   export route-target
#    192.0.2.2:400
#   !
#   maximum prefix 200

# Using overridden
#
# Before state:
# -------------
#
# RP/0/RP0/CPU0:iosxr(config)#show running-config vrf
# vrf VRF7
#  address-family ipv4 unicast
#   import route-policy test-policy
#   import from bridge-domain advertise-as-vpn
#   import from default-vrf route-policy test-policy
#   import from vrf advertise-as-vpn
#   import route-target
#    192.0.2.4:400
#   !
#   export route-policy rm-policy
#   export to vrf allow-imported-vpn
#   export to default-vrf route-policy rm-policy
#   export route-target
#    192.0.2.2:400
#   !
#   maximum prefix 200

- name: Override the provided configuration with the existing running configuration
  cisco.iosxr.iosxr_vrf_address_family:
    state: overridden
    config:
      - name: VRF6
        address_families:
          - afi: "ipv4"
            safi: "unicast"
            export:
              route_target: "192.0.2.8:200"
              route_policy: "rm-policy1"
              to:
                default_vrf:
                  route_policy: "rm-policy"
                vrf:
                  allow_imported_vpn: "true"
            import_config:
              route_target: "192.0.2.2:200"
              route_policy: "test-policy"
              from_config:
                bridge_domain:
                  advertise_as_vpn: "true"
                default_vrf:
                  route_policy: "test-policy"
                vrf:
                  advertise_as_vpn: "true"
            maximum:
              prefix: 500
# Task Output:
# ------------
#
# before:
# - name: VRF7
#   address_families:
#     - afi: "ipv4"
#       safi: "unicast"
#       export:
#         route_target: "192.0.2.2:400"
#         route_policy: "rm-policy"
#         to:
#           default_vrf:
#             route_policy: "rm-policy"
#           vrf:
#             allow_imported_vpn: true
#       import_config:
#         route_target: "192.0.2.4:400"
#         route_policy: "test-policy"
#         from_config:
#           bridge_domain:
#             advertise_as_vpn: true
#           default_vrf:
#             route_policy: "test-policy"
#           vrf:
#             advertise_as_vpn: true
#       maximum:
#         prefix: 200
#
# commands:
# - vrf VRF7
# - address-family ipv4 unicast
# - no import route-policy test-policy
# - no import from bridge-domain advertise-as-vpn
# - no import from default-vrf route-policy test-policy
# - no import from vrf advertise-as-vpn
# - no import route-target 192.0.2.4:400
# - no export route-policy rm-policy
# - no export route-target 192.0.2.2:400
# - no export to default-vrf route-policy rm-policy
# - no export to vrf allow-imported-vpn
# - no maximum prefix 200
# - vrf VRF6
# - address-family ipv4 unicast
# - export route-policy rm-policy1
# - export route-target 192.0.2.8:200
# - export to default-vrf route-policy rm-policy
# - export to vrf allow-imported-vpn
# - import route-target 192.0.2.2:200
# - import route-policy test-policy
# - import from bridge-domain advertise-as-vpn
# - import from default-vrf route-policy test-policy
# - import from vrf advertise-as-vpn
# - maximum prefix 500
#
# after:
# - name: VRF4
# - name: VRF6
#   address_families:
#     - afi: "ipv4"
#       safi: "unicast"
#       export:
#         route_target: "192.0.2.8:200"
#         route_policy: "rm-policy1"
#         to:
#           default_vrf:
#             route_policy: "rm-policy"
#           vrf:
#             allow_imported_vpn: "true"
#       import_config:
#         route_target: "192.0.2.2:200"
#         route_policy: "test-policy"
#         from_config:
#           bridge_domain:
#             advertise_as_vpn: "true"
#           default_vrf:
#             route_policy: "test-policy"
#           vrf:
#             advertise_as_vpn: "true"
#       maximum:
#         prefix: 500
# - name: VRF7
#
# After state:
# -------------
# RP/0/RP0/CPU0:iosxr(config)#show running-config vrf
# vrf VRF4
# vrf VRF6
#  address-family ipv4 unicast
#   import route-policy test-policy
#   import from bridge-domain advertise-as-vpn
#   import from default-vrf route-policy test-policy
#   import from vrf advertise-as-vpn
#   import route-target
#    192.0.2.2:200
#   export route-policy rm-policy1
#   export to vrf allow-imported-vpn
#   export to default-vrf route-policy rm-policy
#   export route-target
#    192.0.2.8:200
#   maximum prefix 500
# vrf VRF7

# Using deleted
#
# Before state:
# -------------
#
# RP/0/RP0/CPU0:iosxr(config)#show running-config vrf
# vrf VRF4
# vrf VRF6
#  address-family ipv4 unicast
#   import route-policy test-policy
#   import from bridge-domain advertise-as-vpn
#   import from default-vrf route-policy test-policy
#   import from vrf advertise-as-vpn
#   import route-target
#    192.0.2.2:200
#   export route-policy rm-policy1
#   export to vrf allow-imported-vpn
#   export to default-vrf route-policy rm-policy
#   export route-target
#    192.0.2.8:200
#   maximum prefix 500
# vrf VRF7

- name: Delete the provided configuration
  cisco.iosxr.iosxr_vrf_address_family:
    config:
    state: deleted

# Task Output:
# ------------
#
# before:
# - name: VRF4
# - name: VRF6
#   address_families:
#     - afi: "ipv4"
#       safi: "unicast"
#       export:
#         route_target: "192.0.2.8:200"
#         route_policy: "rm-policy1"
#         to:
#           default_vrf:
#             route_policy: "rm-policy"
#           vrf:
#             allow_imported_vpn: "true"
#       import_config:
#         route_target: "192.0.2.2:200"
#         route_policy: "test-policy"
#         from_config:
#           bridge_domain:
#             advertise_as_vpn: "true"
#           default_vrf:
#             route_policy: "test-policy"
#           vrf:
#             advertise_as_vpn: "true"
#       maximum:
#         prefix: 500
# - name: VRF7

# commands:
# - vrf VRF4
# - vrf VRF6
# - no address-family ipv4 unicast
# - vrf VRF7
#
# after:
# - name: VRF4
# - name: VRF6
# - name: VRF7
#
# After state:
# ------------
#
# RP/0/RP0/CPU0:iosxr(config)#show running-config vrf
# vrf VRF4
# vrf VRF6
# vrf VRF7

# Using rendered
#
- name: Render provided configuration with device configuration
  cisco.iosxr.iosxr_vrf_address_family:
    config:
      - name: VRF4
        address_families:
          - afi: "ipv4"
            safi: "unicast"
            export:
              route_target: "192.0.2.1:400"
              route_policy: "rm-policy"
              to:
                default_vrf:
                  route_policy: "rm-policy"
                vrf:
                  allow_imported_vpn: true
            import_config:
              route_target: "192.0.2.6:200"
              route_policy: "test-policy"
              from_config:
                bridge_domain:
                  advertise_as_vpn: true
                default_vrf:
                  route_policy: "test-policy"
                vrf:
                  advertise_as_vpn: true
            maximum:
              prefix: 100
    state: rendered

# Task Output:
# ------------
#
# rendered:
# - vrf VRF4
# - address-family ipv4 unicast
# - export route-policy rm-policy
# - export route-target 192.0.2.1:400
# - export to default-vrf route-policy rm-policy
# - export to vrf allow-imported-vpn
# - import route-target 192.0.2.6:200
# - import route-policy test-policy
# - import from bridge-domain advertise-as-vpn
# - import from default-vrf route-policy test-policy
# - import from vrf advertise-as-vpn
# - maximum prefix 100

# Using gathered
#
# Before state:
# -------------
#
# RP/0/RP0/CPU0:iosxr(config)#show running-config vrf
# vrf VRF4
#  address-family ipv4 unicast
#   export route-policy rm-policy
#   export route-target 192.0.2.1:400
#   export to default-vrf route-policy rm-policy
#   export to vrf allow-imported-vpn
#   import route-target 192.0.2.6:200
#   import route-policy test-policy
#   import from bridge-domain advertise-as-vpn
#   import from default-vrf route-policy test-policy
#   import from vrf advertise-as-vpn
#   maximum prefix 100

- name: Gather existing running configuration
  cisco.iosxr.iosxr_vrf_address_family:
    state: gathered

# Task Output:
# ------------
#
# gathered:
# - name: VRF4
#   address_families:
#     - afi: "ipv4"
#       safi: "unicast"
#       export:
#         route_target: "192.0.2.1:400"
#         route_policy: "rm-policy"
#         to:
#           default_vrf:
#             route_policy: "rm-policy"
#           vrf:
#             allow_imported_vpn: true
#       import_config:
#         route_target: "192.0.2.6:200"
#         route_policy: "test-policy"
#         from_config:
#           bridge_domain:
#             advertise_as_vpn: true
#           default_vrf:
#             route_policy: "test-policy"
#           vrf:
#             advertise_as_vpn: true
#       maximum:
#         prefix: 100

# Using parsed
#
# File: parsed.cfg
# ----------------
#
# vrf test
#  address-family ipv4 unicast
#   export to default-vrf route-policy "rm-policy"
#   export to vrf allow-imported-vpn
#   export route-policy "export-policy"
#   export route-target
#    192.0.2.1:400
#   import route-target
#    192.0.2.2:200
#   import route-policy "test-policy"
#   import from bridge-domain advertise-as-vpn
#   import from default-vrf route-policy "new-policy"
#   import from vrf advertise-as-vpn
#   maximum prefix 23

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

# Task Output:
# ------------
#
# parsed:
#   - address_families:
#     - afi: ipv4
#       export:
#         route_policy: export-policy
#         route_target: 192.0.2.1:400
#         to:
#           default_vrf:
#             route_policy: rm-policy
#           vrf:
#             allow_imported_vpn: true
#       import_config:
#         from_config:
#           bridge_domain:
#             advertise_as_vpn: true
#           default_vrf:
#             route_policy: new-policy
#           vrf:
#             advertise_as_vpn: true
#         route_policy: test-policy
#         route_target: 192.0.2.2:200
#       maximum:
#         prefix: 23
#       safi: unicast
#     name: test

返回值

常用返回值已在此处记录 此处,以下是此模块独有的字段

描述

after

列表 / 元素=字符串

生成的配置模型调用。

返回:发生更改时

示例:["The configuration returned will always be in the same format\n of the parameters above.\n"]

before

列表 / 元素=字符串

模型调用之前的配置。

返回:始终

示例:["The configuration returned will always be in the same format\n of the parameters above.\n"]

commands

列表 / 元素=字符串

推送到远程设备的命令集。

返回:始终

示例:["vrf VRF7", "address-family ipv4 unicast", "export route-policy rm-policy", "import route-policy test-policy"]

gathered

列表 / 元素=字符串

从远程设备收集到的关于网络资源的事实,作为结构化数据。

返回:当 *state* 为 gathered

示例:["This output will always be in the same format as the module argspec.\n"]

parsed

列表 / 元素=字符串

根据模块参数规范(argspec),将running_config选项中提供的设备原生配置解析为结构化数据。

返回:stateparsed

示例:["This output will always be in the same format as the module argspec.\n"]

渲染

列表 / 元素=字符串

在任务中提供的配置以设备原生格式(离线)渲染。

返回:staterendered

示例:["vrf VRF4", "address-family ipv4 unicast", "export route-policy rm-policy"]

作者

  • Ruchi Pakhle (@Ruchip16)