cisco.iosxr.iosxr_ospf_interfaces 模块 – 配置 OSPF 接口的资源模块。

注意

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

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

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

要在 playbook 中使用它,请指定:cisco.iosxr.iosxr_ospf_interfaces

cisco.iosxr 1.2.0 新增功能

概要

  • 此模块管理在运行 Cisco IOS-XR 的设备上接口的 OSPF(v2/v3) 配置。

参数

参数

注释

config

列表 / 元素=字典

接口的 OSPF 配置列表。

address_family

列表 / 元素=字典

接口在地址族上下文中的 OSPF 设置。

afi

字符串 / 必需

接口上 OSPF 设置的地址族标识符 (AFI)。

选项

  • "ipv4"

  • "ipv6"

apply_group_option

字典

指定来自组的配置

group_name

字符串

指定组的名称

operation

字符串

指定组配置操作

选项

  • "add"

  • "remove"

  • "append"

authentication

字典

启用身份验证

message_digest

字典

使用消息摘要身份验证

keychain

字符串

指定密钥链名称

null_auth

布尔值

不使用身份验证

选项

  • false

  • true

authentication_key

字典

指定身份验证密码(密钥)

clear

字符串

指定将使用未加密密码(密钥)

encrypted

字符串

指定将使用加密密码(密钥)

password

字符串

OSPFv2 密码(密钥)

bfd

字典

配置 BFD 参数

fast_detect

字典

配置快速检测

set

布尔值

仅启用快速检测

选项

  • false

  • true

strict_mode

布尔值

在 BFD 会话启动之前保持邻居会话

选项

  • false

  • true

minimum_interval

整数

以毫秒为单位的 Hello 间隔

multiplier

整数

检测乘数

cost

整数

指定接口成本

cost_fallback

字典

当累积带宽低于阈值时指定成本

cost

整数

根据累积带宽指定成本

threshold

整数

应用 cost-fallback 时的阈值带宽

database_filter

字典

在同步和泛洪期间过滤 OSPF LSA。

all_outgoing_lsa

布尔值

过滤所有传出的 LSA

选项

  • false

  • true

dead_interval

整数

指定声明邻居失效后的间隔

demand_circuit

布尔值

启用/禁用按需电路

选项

  • false

  • true

fast_reroute

字典

指定 IP 快速重路由

disabled

布尔值

禁用 IP 快速重路由

选项

  • false

  • true

字典

指定每前缀计算

字符串

指定每链路 LFA 排除或 FRR LFA 候选信息

选项

  • "exclude"

  • "lfa_candidate"

字典

指定每链路 LFA 排除信息

列表 / 元素=字典

指定聚合以太网接口

整数

指定接口 ID

列表 / 元素=字典

指定桥接组虚拟接口

整数

指定接口 ID

列表 / 元素=字典

指定 FastEthernet/IEEE 802.3 接口

字符串

指定接口 ID

列表 / 元素=字典

指定 FiftyGigE/IEEE 802.3 接口

字符串

指定接口 ID

列表 / 元素=字典

指定 FortyGigE/IEEE 802.3 接口

字符串

指定接口 ID

列表 / 元素=字典

指定 FourHundredGigE/IEEE 802.3 接口

字符串

指定接口 ID

列表 / 元素=字典

指定 GigabitEthernet/IEEE 802.3 接口

字符串

指定接口 ID

列表 / 元素=字典

指定 HundredGigE/IEEE 802.3 接口

字符串

指定接口 ID

列表 / 元素=字典

指定 MgmtEth/IEEE 802.3 接口

字符串

指定接口 ID

列表 / 元素=字典

指定多链路网络接口

字符串

指定接口 ID

列表 / 元素=字典

指定网络虚拟化端点接口

整数

指定接口 ID

列表 / 元素=字典

指定聚合 pos 接口

整数

指定接口 ID

列表 / 元素=字典

指定 PWHE 以太网接口

整数

指定接口 ID

列表 / 元素=字典

指定 PWHE VC11 IP 互通接口

整数

指定接口 ID

列表 / 元素=字典

指定串行网络接口

字符串

指定接口 ID

列表 / 元素=字典

指定 SRP 接口

字符串

指定接口 ID

列表 / 元素=字典

指定 TenGigabitEthernet/IEEE 802.3 接口

字符串

指定接口 ID

列表 / 元素=字典

指定 GRE/IPinIP 隧道接口

整数

指定接口 ID

列表 / 元素=字典

指定 IPSec 隧道接口

整数

指定接口 ID

列表 / 元素=字典

MPLS 传输协议隧道接口

字符串

指定接口 ID

列表 / 元素=字典

指定 MPLS 交通工程 P2MP 隧道接口

整数

指定接口 ID

列表 / 元素=字典

指定 TwentyFiveGigabitEthernet/IEEE 802.3 接口

字符串

指定接口 ID

列表 / 元素=字典

指定 TwoHundredGigE/IEEE 802.3 接口

字符串

指定接口 ID

布尔值

启用/禁用仅从候选列表中选择备份

选项

  • false

  • true

flood_reduction

布尔值

启用/禁用泛洪减少

选项

  • false

  • true

hello_interval

整数

指定 HELLO 数据包之间的时间

布尔值

配置接口关闭参数

选项

  • false

  • true

message_digest_key

字典

消息摘要身份验证密码(密钥)

id

整数 / 必需

密钥 ID

md5

字典 / 必需

使用 MD5 算法

clear

布尔值

指定将使用未加密密码(密钥)

选项

  • false

  • true

encrypted

布尔值

指定将使用加密密码(密钥)

选项

  • false

  • true

password

字符串

OSPFv2 密码(密钥)

mpls_ldp_sync

布尔值

启用/禁用 MPLS LDP 同步

选项

  • false

  • true

mtu_ignore

布尔值

启用/禁用忽略 DBD 数据包中的 MTU

选项

  • false

  • true

neighbors

列表 / 元素=字典

指定邻居路由器

cost

整数

指定点到多点邻居的OSPF开销

db_filter_all_out

布尔值

在同步和泛洪期间,指定过滤点到多点邻居的OSPF LSA

选项

  • false

  • true

neighbor_id

字符串

指定邻居地址(名称)

poll_interval

整数

指定OSPF死路由器轮询间隔

priority

整数

指定非广播邻居的OSPF优先级

network

字符串

指定网络类型

选项

  • "广播"

  • "非广播"

  • "点到多点"

  • "点到点"

packet_size

整数

自定义OSPF数据包大小,最大值为MTU

passive

布尔值

启用/禁用被动模式

选项

  • false

  • true

prefix_suppression

布尔值

抑制前缀通告

选项

  • false

  • true

priority

整数

指定路由器优先级

processes

列表 / 元素=字典

OSPF进程的接口配置。

area

字典

指定区域ID

area_id

字符串

OSPF接口区域ID,以十进制值表示。请参考厂商文档了解有效值。

OSPF接口区域ID,以IP地址格式表示(例如:A.B.C.D)

process_id

字符串 / 必需

OSPF进程标签。

retransmit_interval

整数

指定重传丢失的链路状态通告之间的时间间隔

security_ttl

字典

启用安全功能

hops

整数

允许的最大IP跳数 <1-254>

set

布尔值

启用TTL安全

选项

  • false

  • true

transmit_delay

整数

指定发送链路状态更新数据包所需的大致时间

name

字符串 / 必需

接口的名称/标识符。

type

字符串 / 必需

接口类型。

running_config

字符串

此选项仅在状态为 *parsed* 时使用。

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

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

state

字符串

配置应保留的状态。

选项

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "parsed"

  • "rendered"

注释

注意

示例

# Using merged

# Before state:
# -------------
#
# RP/0/RP0/CPU0:anton#show running-config router ospf
# % No such configuration item(s)
#

- name: Merge provided OSPF interfaces configuration with the existing configuration
  cisco.iosxr.iosxr_ospf_interfaces:
    config:
      - name: GigabitEthernet0/0/0/0
        type: gigabitethernet
        address_family:
          - afi: ipv4
            processes:
              - process_id: LAB3
                area:
                  area_id: 0.0.0.3
            cost: 20
            authentication:
              message_digest:
                keychain: cisco
          - afi: ipv6
            processes:
              - process_id: LAB3
                area:
                  area_id: 0.0.0.2
            cost: 30
    state: merged

#
#
# Task Output:
# ------------
#
# before: []
#
# commands:
#   - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20
#   - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest
#   - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain cisco
#   - router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0 cost 30
#
# after:
#   - address_family:
#     - afi: ipv4
#       authentication:
#         message_digest:
#           keychain: cisco
#       cost: 20
#       processes:
#       - area:
#           area_id: 0.0.0.3
#         process_id: LAB3
#     - afi: ipv6
#       cost: 30
#       processes:
#       - area:
#           area_id: 0.0.0.2
#         process_id: LAB3
#     name: GigabitEthernet0/0/0/0
#     type: gigabitethernet
#
# After state:
# ------------
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:00:57.217 UTC
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 20
#    authentication message-digest keychain cisco
#   !
#  !
# !
# router ospfv3 LAB3
#  area 0.0.0.2
#   interface GigabitEthernet0/0/0/0
#    cost 30
#   !
#  !
# !

# Using replaced
#
# Before state:
# -------------
#
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:00:57.217 UTC
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 20
#    authentication message-digest keychain cisco
#   !
#  !
# !
# router ospfv3 LAB3
#  area 0.0.0.2
#   interface GigabitEthernet0/0/0/0
#    cost 30
#   !
#  !
# !

- name: Replace OSPF interfaces configuration
  cisco.iosxr.iosxr_ospf_interfaces:
    config:
      - name: GigabitEthernet0/0/0/0
        type: gigabitethernet
        address_family:
          - afi: ipv4
            processes:
              - process_id: LAB3
                area:
                  area_id: 0.0.0.3
            cost: 30
            authentication:
              message_digest:
                keychain: ciscoiosxr
          - afi: ipv6
            processes:
              - process_id: LAB3
                area:
                  area_id: 0.0.0.2
            cost: 30
    state: replaced
#
# Task Output:
# ------------
#
# before:
#   - address_family:
#     - afi: ipv4
#       authentication:
#         message_digest:
#           keychain: cisco
#       cost: 20
#       processes:
#       - area:
#           area_id: 0.0.0.3
#         process_id: LAB3
#     - afi: ipv6
#       cost: 30
#       processes:
#       - area:
#           area_id: 0.0.0.2
#         process_id: LAB3
#     name: GigabitEthernet0/0/0/0
#     type: gigabitethernet
#
# commands:
#   - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 30
#   - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest
#   - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain ciscoiosxr
#
# after:
#   - address_family:
#     - afi: ipv4
#       authentication:
#         message_digest:
#           keychain: ciscoiosxr
#       cost: 30
#       processes:
#       - area:
#           area_id: 0.0.0.3
#         process_id: LAB3
#     - afi: ipv6
#       cost: 30
#       processes:
#       - area:
#           area_id: 0.0.0.2
#         process_id: LAB3
#     name: GigabitEthernet0/0/0/0
#     type: gigabitethernet
#
# After state:
# ------------
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:10:39.827 UTC
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 30
#    authentication message-digest keychain ciscoiosxr
#   !
# router ospfv3 LAB3
#  area 0.0.0.2
#   interface GigabitEthernet0/0/0/0
#    cost 30
#   !
#  !
# !

# Using overridden
#
# Before state
# ------------
#
- name: Override existing OSPF interfaces configuration
  cisco.iosxr.iosxr_ospf_interfaces:
    config:
      - name: GigabitEthernet0/0/0/1
        type: gigabitethernet
        address_family:
          - afi: ipv4
            processes:
              - process_id: LAB1
                area:
                  area_id: 0.0.0.3
            cost: 10
            authentication:
              message_digest:
                keychain: iosxr
    state: overridden

#
#
# Task Output:
# ------------
#
# before:
#   - address_family:
#     - afi: ipv4
#       authentication:
#         message_digest:
#           keychain: ciscoiosxr
#       cost: 30
#       processes:
#       - area:
#           area_id: 0.0.0.3
#         process_id: LAB3
#     - afi: ipv6
#       cost: 30
#       processes:
#       - area:
#           area_id: 0.0.0.2
#         process_id: LAB3
#     name: GigabitEthernet0/0/0/0
#     type: gigabitethernet
#
# commands:
#   - no router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0
#   - no router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0
#   - router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 cost 10
#   - router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 authentication message-digest
#   - router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 authentication message-digest keychain iosxr
#
# after:
#   - address_family:
#     - afi: ipv4
#       authentication:
#         message_digest:
#           keychain: iosxr
#       cost: 10
#       processes:
#       - area:
#           area_id: 0.0.0.3
#         process_id: LAB1
#     name: GigabitEthernet0/0/0/1
#     type: gigabitethernet
#
# After state:
# ------------
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:28:15.025 UTC
# router ospf LAB1
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/1
#    cost 10
#    authentication message-digest keychain iosxr
#   !
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#  !
# !
# router ospfv3 LAB3
#  area 0.0.0.2
#  !
# !

# Using deleted
#
# Before state:
# -------------
#
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:28:15.025 UTC
# router ospf LAB1
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/1
#    cost 10
#    authentication message-digest keychain iosxr
#   !
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 20
#    authentication message-digest keychain cisco
#   !
#  !
# !
# router ospfv3 LAB3
#  area 0.0.0.2
#   interface GigabitEthernet0/0/0/0
#    cost 30
#   !
#  !
# !

- name: Deleted existing OSPF interfaces from the device
  cisco.iosxr.iosxr_ospf_interfaces:
    config:
      - name: GigabitEthernet0/0/0/1
        type: gigabitethernet
    state: deleted

#
# Task Output:
# ------------
#
# before:
#   - address_family:
#     - afi: ipv4
#       authentication:
#         message_digest:
#           keychain: iosxr
#       cost: 10
#       processes:
#       - area:
#           area_id: 0.0.0.3
#         process_id: LAB1
#     name: GigabitEthernet0/0/0/1
#     type: gigabitethernet
#   - address_family:
#     - afi: ipv4
#       authentication:
#         message_digest:
#           keychain: cisco
#       cost: 20
#       processes:
#       - area:
#           area_id: 0.0.0.3
#         process_id: LAB3
#     - afi: ipv6
#       cost: 30
#       processes:
#       - area:
#           area_id: 0.0.0.2
#         process_id: LAB3
#     name: GigabitEthernet0/0/0/0
#     type: gigabitethernet
#
# commands:
#   - no router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1]
#
# after:
#   - address_family:
#     - afi: ipv4
#       authentication:
#         message_digest:
#           keychain: cisco
#       cost: 20
#       processes:
#       - area:
#           area_id: 0.0.0.3
#         process_id: LAB3
#     - afi: ipv6
#       cost: 30
#       processes:
#       - area:
#           area_id: 0.0.0.2
#         process_id: LAB3
#     name: GigabitEthernet0/0/0/0
#     type: gigabitethernet
#
# After state:
# ------------
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:34:38.319 UTC
# router ospf LAB1
#  area 0.0.0.3
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 20
#    authentication message-digest keychain cisco
#   !
#  !
# !
# router ospfv3 LAB3
#  area 0.0.0.2
#   interface GigabitEthernet0/0/0/0
#    cost 30
#   !
#  !
# !

# Using parsed
#
# parsed.cfg
# ------------
# router ospf LAB
#  area 0.0.0.0
#  !
#  area 0.0.0.9
#  !
# !
# router ospf LAB1
#  area 0.0.0.1
#  !
#  area 0.0.0.3
#  !
# !
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 20
#    authentication message-digest keychain cisco
#   !
#  !
# !
# router ospf ipv4
# !
- name: Parsed running config and display structured facts.
  cisco.iosxr.iosxr_ospf_interfaces:
    running_config: "{{ lookup('file', './parsed.cfg') }}"
    state: parsed
#
# Task Output:
# ------------
#
# parsed:
#   - address_family:
#     - afi: ipv4
#       authentication:
#         message_digest:
#           keychain: cisco
#       cost: 20
#       processes:
#       - area:
#           area_id: 0.0.0.3
#         process_id: LAB3
#     name: GigabitEthernet0/0/0/0
#     type: gigabitethernet

# Using rendered
#
- name: Render the commands for provided  configuration
  cisco.iosxr.iosxr_ospf_interfaces:
    config:
      - name: GigabitEthernet0/0/0/0
        type: gigabitethernet
        address_family:
          - afi: ipv4
            processes:
              - process_id: LAB3
                area:
                  area_id: 0.0.0.3
            cost: 20
            authentication:
              message_digest:
                keychain: cisco
          - afi: ipv6
            processes:
              - process_id: LAB3
                area:
                  area_id: 0.0.0.2
            cost: 30
    state: rendered

#
# Task Output:
# ------------
#
# rendered:
#   - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20
#   - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest
#   - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain cisco
#   - router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0 cost 30

# Using gathered
#
# Before state:
# -------------
#
# RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
# Thu Oct 23 06:50:38.743 UTC
# router ospf LAB3
#  area 0.0.0.3
#   interface GigabitEthernet0/0/0/0
#    cost 20
#    authentication message-digest keychain cisco
#   !
#  !
# !
# router ospfv3 LAB3
#  area 0.0.0.2
#   interface GigabitEthernet0/0/0/0
#    cost 30
#   !
#  !
# !


- name: Gather ospf_interfaces routes configuration
  cisco.iosxr.iosxr_ospf_interfaces:
    state: gathered
#
# Task Output:
# ------------
#
# gathered:
#   - address_family:
#     - afi: ipv4
#       authentication:
#         message_digest:
#           keychain: cisco
#       cost: 20
#       processes:
#       - area:
#           area_id: 0.0.0.3
#         process_id: LAB3
#     - afi: ipv6
#       cost: 30
#       processes:
#       - area:
#           area_id: 0.0.0.2
#         process_id: LAB3
#     name: GigabitEthernet0/0/0/0
#     type: gigabitethernet

返回值

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

描述

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

列表 / 元素=字符串

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

返回:始终返回

示例: ["router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20", "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest"]

gathered

列表 / 元素=字符串

从远程设备收集的关于网络资源的事实,以结构化数据表示。

返回:当 *state* 为 gathered

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

parsed

列表 / 元素=字符串

根据模块argspec将 *running_config* 选项中提供的设备原生配置解析为结构化数据。

返回:当 *state* 为 parsed

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

rendered

列表 / 元素=字符串

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

返回:当 *state* 为 rendered

示例: ["router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20"]

作者

  • Rohit Thakur (@rohitthakur2590)