cisco.ios.ios_ospf_interfaces 模块 – 用于配置 OSPF 接口的资源模块。

注意

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

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

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

要在 playbook 中使用它,请指定:cisco.ios.ios_ospf_interfaces

cisco.ios 1.0.0 中的新功能

概要

  • 此模块在 IOS 平台上配置和管理开放最短路径优先 (OSPF) 版本 2。

参数

参数

注释

config

列表 / 元素=字典

OSPF 接口选项的字典。

address_family

列表 / 元素=字典

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

adjacency

布尔值

邻接错开

选择

  • false

  • true

afi

字符串 / 必需

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

选择

  • "ipv4"

  • "ipv6"

authentication

字典

启用身份验证

key_chain

字符串

使用密钥链进行加密身份验证密钥

message_digest

布尔值

使用消息摘要身份验证

选择

  • false

  • true

null

布尔值

不使用身份验证

选择

  • false

  • true

bfd

布尔值

BFD 配置命令

在此接口上启用/禁用 BFD

选择

  • false

  • true

cost

字典

接口成本

dynamic_cost

字典

指定动态成本选项

仅对 IPv6 OSPF 配置有效

default

整数

指定默认链路度量值

hysteresis

字典

指定 LSA 阻尼的滞后值

percent

整数

指定滞后百分比已更改。请参阅供应商文档以了解有效值。

threshold

整数

指定滞后阈值。请参阅供应商文档以了解有效值。

weight

字典

指定放置在各个指标上的权重

l2_factor

整数

指定 L2 因子指标的权重

L2 因子指标的百分比权重。请参阅供应商文档以了解有效值。

latency

整数

指定延迟指标的权重。

延迟指标的百分比权重。请参阅供应商文档以了解有效值。

oc

布尔值

指定 cdr/mdr 对于 oc 的权重

为当前数据速率提供 100% 的权重(最大数据速率为 0)

选择

  • false

  • true

resources

整数

指定资源指标的权重

资源指标的百分比权重。请参阅供应商文档以了解有效值。

throughput

整数

指定吞吐量指标的权重

吞吐量指标的百分比权重。请参阅供应商文档以了解有效值。

interface_cost

整数

此接口的接口成本或路由成本

database_filter

布尔值

在同步和泛洪期间筛选 OSPF LSA

选择

  • false

  • true

dead_interval

字典

声明邻居死亡的时间间隔

minimal

整数

设置为 1 秒并设置 Hello 的乘数

在 1 秒内发送的 Hello 数量。请参阅供应商文档以了解有效值。

仅对 IP OSPF 配置有效

time

整数

以秒为单位的时间

demand_circuit

字典

OSPF 按需电路,启用或禁用按需电路’

disable

布尔值

在此接口上禁用按需电路

仅对 IPv6 OSPF 配置有效

选择

  • false

  • true

enable

布尔值

启用按需电路

选择

  • false

  • true

ignore

布尔值

忽略按需电路自动协商请求

选择

  • false

  • true

flood_reduction

布尔值

OSPF 泛洪减少

选择

  • false

  • true

hello_interval

整数

HELLO 数据包之间的时间

请参阅供应商文档以了解有效值。

lls

布尔值

链路本地信号 (LLS) 支持

仅对 IP OSPF 配置有效

选择

  • false

  • true

manet

字典

移动自组织网络选项

MANET 对等选项

仅对 IPv6 OSPF 配置有效

cost

字典

对等所需的冗余路径成本改进

percent

整数

相对增量路径成本。请参阅供应商文档以了解有效值。

threshold

整数

绝对增量路径成本。请参阅供应商文档以了解有效值。

字典

对等所需的冗余路径成本改进

整数

最小链路成本阈值。请参阅供应商文档以了解有效值。

布尔值

启用链路度量

选择

  • false

  • true

mtu_ignore

布尔值

忽略 DBD 数据包中的 MTU

选择

  • false

  • true

multi_area

字典

设置 OSPF 多区域 ID

仅对 IP OSPF 配置有效

cost

整数

接口成本

id

整数

作为十进制值的 OSPF 多区域 ID。请参阅供应商文档以了解有效值。

IP 地址格式的 OSPF 多区域 ID(例如,A.B.C.D)

neighbor

字典

OSPF 邻居链路本地 IPv6 地址 (X:X:X:X::X)

仅对 IPv6 OSPF 配置有效

address

字符串

邻居链路本地 IPv6 地址

cost

整数

点到多点邻居的 OSPF 成本

database_filter

布尔值

筛选点到多点邻居的同步和泛洪期间的 OSPF LSA

选择

  • false

  • true

poll_interval

整数

OSPF 死路由器轮询间隔

priority

整数

非广播邻居的 OSPF 优先级

network

字典

网络类型

broadcast

布尔值

指定 OSPF 广播多路访问网络

选择

  • false

  • true

manet

布尔值

指定 MANET OSPF 接口类型

仅对 IPv6 OSPF 配置有效

选择

  • false

  • true

non_broadcast

布尔值

指定 OSPF NBMA 网络

选择

  • false

  • true

point_to_multipoint

布尔值

指定 OSPF 点到多点网络

选择

  • false

  • true

point_to_point

布尔值

指定 OSPF 点到点网络

选择

  • false

  • true

prefix_suppression

布尔值

启用/禁用 OSPF 前缀抑制

选择

  • false

  • true

priority

整数

路由器优先级。请参阅供应商文档以了解有效值。

process

字典

OSPF 接口进程配置

area_id

字符串

作为十进制值的 OSPF 接口区域 ID。请参阅供应商文档以了解有效值。

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

id

整数

接口上 OSPF 接口设置的地址族标识符 (AFI)。请参阅供应商文档以了解有效值。

instance_id

整数

根据 ID 设置 OSPF 实例

仅对 IPv6 OSPF 配置有效

secondaries

布尔值

包括或排除辅助 IP 地址。

仅对 IPv4 配置有效

选择

  • false

  • true

resync_timeout

整数

如果未启动 oob-resync,则在重置邻接之后的时间间隔。请参阅供应商文档以了解有效值。

retransmit_interval

整数

重新传输丢失的链路状态通告之间的时间。请参阅供应商文档以了解有效值。

shutdown

布尔值

在当前接口下将 OSPF 协议的状态设置为禁用

选择

  • false

  • true

transmit_delay

整数

链路状态传输延迟。请参阅供应商文档以了解有效值。

ttl_security

字典

TTL 安全检查

仅对 IPV4 OSPF 配置有效

hops

整数

允许的最大 IP 跳数

请参阅供应商文档以了解有效值。

set

布尔值

在所有接口上启用 TTL 安全性

选择

  • false

  • true

name

字符串 / 必需

接口的全名,不包括任何逻辑单元号,即 GigabitEthernet0/1。

running_config

字符串

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

此选项的值应该是通过执行命令 sh running-config | section ^interface 从 IOS 设备接收到的输出。

parsed 状态从 running_config 选项读取配置,并根据资源模块的参数规范将其转换为 Ansible 结构化数据,然后在结果中的 parsed 键中返回该值。

state

字符串

配置应保留的状态

renderedgatheredparsed 状态不会对设备执行任何更改。

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

gathered 状态将从设备获取运行配置,并按照资源模块参数规范将其转换为结构化数据,然后在结果的 gathered 键中返回该值。

parsed 状态从 running_config 选项读取配置,并根据资源模块参数将其转换为 JSON 格式,然后在结果的 parsed 键中返回该值。running_config 选项的值应与在设备上执行的命令 *show running-config | section ^interface* 的输出格式相同。 对于 parsed 状态,不需要与远程主机的活动连接。

选择

  • "merged" ←(默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "rendered"

  • "parsed"

备注

注意

示例

# Using deleted

# Before state:
# -------------
#
# router-ios#sh running-config | section ^interface
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
#  ipv6 ospf 55 area 105
#  ipv6 ospf priority 20
#  ipv6 ospf transmit-delay 30
#  ipv6 ospf adjacency stagger disable
# interface GigabitEthernet0/2
#  ip ospf priority 40
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf 10 area 20
#  ip ospf cost 30

- name: Delete provided OSPF Interface config
  cisco.ios.ios_ospf_interfaces:
    config:
      - name: GigabitEthernet0/1
    state: deleted

# Task Output:
# ------------

# before:
#   - name: GigabitEthernet0/0
#   - address_family:
#     - adjacency: true
#       afi: ipv6
#       priority: 20
#       process:
#         area_id: '105'
#         id: 55
#       transmit_delay: 30
#     name: GigabitEthernet0/1
#   - address_family:
#     - adjacency: true
#       afi: ipv4
#       cost:
#         interface_cost: 30
#       priority: 40
#       process:
#         area_id: '20'
#         id: 10
#       ttl_security:
#         hops: 50
#         set: true
#     name: GigabitEthernet0/2
#
# commands:
# - interface GigabitEthernet0/1
# - no ipv6 ospf 55 area 105
# - no ipv6 ospf adjacency stagger disable
# - no ipv6 ospf priority 20
# - no ipv6 ospf transmit-delay 30
#
# after:
#   - name: GigabitEthernet0/0
#   - name: GigabitEthernet0/1
#   - address_family:
#     - adjacency: true
#       afi: ipv4
#       cost:
#         interface_cost: 30
#       priority: 40
#       process:
#         area_id: '20'
#         id: 10
#       ttl_security:
#         hops: 50
#         set: true
#     name: GigabitEthernet0/2
#
# After state:
# ------------
# router-ios#sh running-config | section ^interface
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
# interface GigabitEthernet0/2
#  ip ospf priority 40
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf 10 area 20
#  ip ospf cost 30

# Using deleted without any config passed (NOTE: This will delete all OSPF Interfaces configuration from device)

# Before state:
# -------------
#
# router-ios#sh running-config | section ^interface
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
#  ipv6 ospf 55 area 105
#  ipv6 ospf priority 20
#  ipv6 ospf transmit-delay 30
#  ipv6 ospf adjacency stagger disable
# interface GigabitEthernet0/2
#  ip ospf priority 40
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf 10 area 20
#  ip ospf cost 30

- name: Delete all OSPF config from interfaces
  cisco.ios.ios_ospf_interfaces:
    state: deleted

# Task Output:
# ------------

# before:
#   - name: GigabitEthernet0/0
#   - address_family:
#     - adjacency: true
#       afi: ipv6
#       priority: 20
#       process:
#         area_id: '105'
#         id: 55
#       transmit_delay: 30
#     name: GigabitEthernet0/1
#   - address_family:
#     - adjacency: true
#       afi: ipv4
#       cost:
#         interface_cost: 30
#       priority: 40
#       process:
#         area_id: '20'
#         id: 10
#       ttl_security:
#         hops: 50
#         set: true
#     name: GigabitEthernet0/2
#
# commands:
# - interface GigabitEthernet0/2
# - no ip ospf 10 area 20
# - no ip ospf adjacency stagger disable
# - no ip ospf cost 30
# - no ip ospf priority 40
# - no ip ospf ttl-security hops 50
# - interface GigabitEthernet0/1
# - no ipv6 ospf 55 area 105
# - no ipv6 ospf adjacency stagger disable
# - no ipv6 ospf priority 20
# - no ipv6 ospf transmit-delay 30
#
# after:
#   - name: GigabitEthernet0/0
#   - name: GigabitEthernet0/1
#   - name: GigabitEthernet0/2

# After state:
# -------------
# router-ios#sh running-config | section ^interface
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
# interface GigabitEthernet0/2

# Using merged

# Before state:
# -------------
#
# router-ios#sh running-config | section ^interface
# router-ios#

- name: Merge provided OSPF Interfaces configuration
  cisco.ios.ios_ospf_interfaces:
    config:
      - name: GigabitEthernet0/1
        address_family:
          - afi: ipv4
            process:
              id: 10
              area_id: 30
            adjacency: true
            bfd: true
            cost:
              interface_cost: 5
            dead_interval:
              time: 5
            demand_circuit:
              ignore: true
            network:
              broadcast: true
            priority: 25
            resync_timeout: 10
            shutdown: true
            ttl_security:
              hops: 50
          - afi: ipv6
            process:
              id: 35
              area_id: 45
            adjacency: true
            database_filter: true
            manet:
              link_metrics:
                cost_threshold: 10
            priority: 55
            transmit_delay: 45
    state: merged

# Task Output:
# ------------
# before: []
#
# commands:
# - interface GigabitEthernet0/1
# - ip ospf 10 area 30
# - ip ospf adjacency stagger disable
# - ip ospf bfd
# - ip ospf cost 5
# - ip ospf dead-interval 5
# - ip ospf demand-circuit ignore
# - ip ospf network broadcast
# - ip ospf priority 25
# - ip ospf resync-timeout 10
# - ip ospf shutdown
# - ip ospf ttl-security hops 50
# - ipv6 ospf 35 area 45
# - ipv6 ospf adjacency stagger disable
# - ipv6 ospf database-filter all out
# - ipv6 ospf manet peering link-metrics 10
# - ipv6 ospf priority 55
# - ipv6 ospf transmit-delay 45
#
# after:
#   - name: GigabitEthernet0/0
#   - address_family:
#     - adjacency: true
#       afi: ipv4
#       bfd: true
#       cost:
#         interface_cost: 5
#       dead_interval:
#         time: 5
#       demand_circuit:
#         enable: true
#         ignore: true
#       network:
#         broadcast: true
#       priority: 25
#       process:
#         area_id: '30'
#         id: 10
#       resync_timeout: 10
#       shutdown: true
#       ttl_security:
#         hops: 50
#         set: true
#     - adjacency: true
#       afi: ipv6
#       database_filter: true
#       manet:
#         link_metrics:
#           cost_threshold: 10
#       priority: 55
#       process:
#         area_id: '45'
#         id: 35
#       transmit_delay: 45
#     name: GigabitEthernet0/1
#   - name: GigabitEthernet0/2

# After state:
# -------------
#
# router-ios#sh running-config | section ^interface
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
#  ip ospf network broadcast
#  ip ospf resync-timeout 10
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf demand-circuit ignore
#  ip ospf bfd
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf shutdown
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf 35 area 45
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
#  ipv6 ospf database-filter all out
#  ipv6 ospf adjacency stagger disable
#  ipv6 ospf manet peering link-metrics 10
# interface GigabitEthernet0/2

# Using overridden

# Before state:
# -------------
#
# router-ios#sh running-config | section ^interface
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
#  ip ospf network broadcast
#  ip ospf resync-timeout 10
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf demand-circuit ignore
#  ip ospf bfd
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf shutdown
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf 35 area 45
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
#  ipv6 ospf database-filter all out
#  ipv6 ospf adjacency stagger disable
#  ipv6 ospf manet peering link-metrics 10
# interface GigabitEthernet0/2

- name: Override running config with provided OSPF Interfaces configuration
  cisco.ios.ios_ospf_interfaces:
    config:
      - name: GigabitEthernet0/1
        address_family:
          - afi: ipv6
            process:
              id: 55
              area_id: 105
            adjacency: true
            priority: 20
            transmit_delay: 30
      - name: GigabitEthernet0/2
        address_family:
          - afi: ipv4
            process:
              id: 10
              area_id: 20
            adjacency: true
            cost:
              interface_cost: 30
            priority: 40
            ttl_security:
              hops: 50
    state: overridden

# Task Output:
# ------------
#
# before:
#   - name: GigabitEthernet0/0
#   - address_family:
#     - adjacency: true
#       afi: ipv4
#       bfd: true
#       cost:
#         interface_cost: 5
#       dead_interval:
#         time: 5
#       demand_circuit:
#         enable: true
#         ignore: true
#       network:
#         broadcast: true
#       priority: 25
#       process:
#         area_id: '30'
#         id: 10
#       resync_timeout: 10
#       shutdown: true
#       ttl_security:
#         hops: 50
#         set: true
#     - adjacency: true
#       afi: ipv6
#       database_filter: true
#       manet:
#         link_metrics:
#           cost_threshold: 10
#       priority: 55
#       process:
#         area_id: '45'
#         id: 35
#       transmit_delay: 45
#     name: GigabitEthernet0/1
#   - name: GigabitEthernet0/2
#
# commands:
# - interface GigabitEthernet0/2
# - ip ospf 10 area 20
# - ip ospf adjacency stagger disable
# - ip ospf cost 30
# - ip ospf priority 40
# - ip ospf ttl-security hops 50
# - interface GigabitEthernet0/1
# - ipv6 ospf 55 area 105
# - no ipv6 ospf database-filter all out
# - no ipv6 ospf manet peering link-metrics 10
# - ipv6 ospf priority 20
# - ipv6 ospf transmit-delay 30
# - no ip ospf 10 area 30
# - no ip ospf adjacency stagger disable
# - no ip ospf bfd
# - no ip ospf cost 5
# - no ip ospf dead-interval 5
# - no ip ospf demand-circuit ignore
# - no ip ospf network broadcast
# - no ip ospf priority 25
# - no ip ospf resync-timeout 10
# - no ip ospf shutdown
# - no ip ospf ttl-security hops 50
#
# parsed:
#   - name: GigabitEthernet0/0
#   - address_family:
#     - adjacency: true
#       afi: ipv6
#       priority: 20
#       process:
#         area_id: '105'
#         id: 55
#       transmit_delay: 30
#     name: GigabitEthernet0/1
#   - address_family:
#     - adjacency: true
#       afi: ipv4
#       cost:
#         interface_cost: 30
#       priority: 40
#       process:
#         area_id: '20'
#         id: 10
#       ttl_security:
#         hops: 50
#         set: true
#     name: GigabitEthernet0/2
#
# After state:
# -------------
#
# router-ios#sh running-config | section ^interface
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
#  ipv6 ospf 55 area 105
#  ipv6 ospf priority 20
#  ipv6 ospf transmit-delay 30
#  ipv6 ospf adjacency stagger disable
# interface GigabitEthernet0/2
#  ip ospf priority 40
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf 10 area 20
#  ip ospf cost 30

# Using replaced

# Before state:
# -------------
#
# router-ios#sh running-config | section ^interface
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
#  ip ospf network broadcast
#  ip ospf resync-timeout 10
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf demand-circuit ignore
#  ip ospf bfd
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf shutdown
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf 35 area 45
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
#  ipv6 ospf database-filter all out
#  ipv6 ospf adjacency stagger disable
#  ipv6 ospf manet peering link-metrics 10
# interface GigabitEthernet0/2

- name: Replaced provided OSPF Interfaces configuration
  cisco.ios.ios_ospf_interfaces:
    config:
      - name: GigabitEthernet0/2
        address_family:
          - afi: ipv6
            process:
              id: 55
              area_id: 105
            adjacency: true
            priority: 20
            transmit_delay: 30
    state: replaced

# Task Output:
# ------------
#
# before:
#   - name: GigabitEthernet0/0
#   - address_family:
#     - adjacency: true
#       afi: ipv4
#       bfd: true
#       cost:
#         interface_cost: 5
#       dead_interval:
#         time: 5
#       demand_circuit:
#         enable: true
#         ignore: true
#       network:
#         broadcast: true
#       priority: 25
#       process:
#         area_id: '30'
#         id: 10
#       resync_timeout: 10
#       shutdown: true
#       ttl_security:
#         hops: 50
#         set: true
#     - adjacency: true
#       afi: ipv6
#       database_filter: true
#       manet:
#         link_metrics:
#           cost_threshold: 10
#       priority: 55
#       process:
#         area_id: '45'
#         id: 35
#       transmit_delay: 45
#     name: GigabitEthernet0/1
#   - name: GigabitEthernet0/2
#
# commands:
# - interface GigabitEthernet0/2
# - ipv6 ospf 55 area 105
# - ipv6 ospf adjacency stagger disable
# - ipv6 ospf priority 20
# - ipv6 ospf transmit-delay 30
#
# after:
#   - name: GigabitEthernet0/0
#   - address_family:
#     - adjacency: true
#       afi: ipv4
#       bfd: true
#       cost:
#         interface_cost: 5
#       dead_interval:
#         time: 5
#       demand_circuit:
#         enable: true
#         ignore: true
#       network:
#         broadcast: true
#       priority: 25
#       process:
#         area_id: '30'
#         id: 10
#       resync_timeout: 10
#       shutdown: true
#       ttl_security:
#         hops: 50
#         set: true
#     - adjacency: true
#       afi: ipv6
#       database_filter: true
#       manet:
#         link_metrics:
#           cost_threshold: 10
#       priority: 55
#       process:
#         area_id: '45'
#         id: 35
#       transmit_delay: 45
#     name: GigabitEthernet0/1
#   - address_family:
#     - adjacency: true
#       afi: ipv6
#       priority: 20
#       process:
#         area_id: '105'
#         id: 55
#       transmit_delay: 30
#     name: GigabitEthernet0/2

# After state:
# ------------
# router-ios#sh running-config | section ^interface
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
#  ip ospf network broadcast
#  ip ospf resync-timeout 10
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf demand-circuit ignore
#  ip ospf bfd
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf shutdown
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf 35 area 45
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
#  ipv6 ospf database-filter all out
#  ipv6 ospf adjacency stagger disable
#  ipv6 ospf manet peering link-metrics 10
# interface GigabitEthernet0/2
#  ipv6 ospf 55 area 105
#  ipv6 ospf priority 20
#  ipv6 ospf transmit-delay 30
#  ipv6 ospf adjacency stagger disable

# Using Gathered

# Before state:
# -------------
#
# router-ios#sh running-config | section ^interface
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
#  ip ospf network broadcast
#  ip ospf resync-timeout 10
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf demand-circuit ignore
#  ip ospf bfd
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf shutdown
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf 35 area 45
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
#  ipv6 ospf database-filter all out
#  ipv6 ospf adjacency stagger disable
#  ipv6 ospf manet peering link-metrics 10
# interface GigabitEthernet0/2

- name: Gather OSPF Interfaces provided configurations
  cisco.ios.ios_ospf_interfaces:
    config:
    state: gathered

# Task Output:
# ------------
#
# gathered:
#   - name: GigabitEthernet0/0
#   - address_family:
#     - adjacency: true
#       afi: ipv4
#       bfd: true
#       cost:
#         interface_cost: 5
#       dead_interval:
#         time: 5
#       demand_circuit:
#         enable: true
#         ignore: true
#       network:
#         broadcast: true
#       priority: 25
#       process:
#         area_id: '30'
#         id: 10
#       resync_timeout: 10
#       shutdown: true
#       ttl_security:
#         hops: 50
#         set: true
#     - adjacency: true
#       afi: ipv6
#       database_filter: true
#       manet:
#         link_metrics:
#           cost_threshold: 10
#       priority: 55
#       process:
#         area_id: '45'
#         id: 35
#       transmit_delay: 45
#     name: GigabitEthernet0/1
#   - name: GigabitEthernet0/2

# After state:
# ------------
#
# router-ios#sh running-config | section ^interface
# interface GigabitEthernet0/0
# interface GigabitEthernet0/1
#  ip ospf network broadcast
#  ip ospf resync-timeout 10
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf demand-circuit ignore
#  ip ospf bfd
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf shutdown
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf 35 area 45
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
#  ipv6 ospf database-filter all out
#  ipv6 ospf adjacency stagger disable
#  ipv6 ospf manet peering link-metrics 10
# interface GigabitEthernet0/2

# Using Rendered

- name: Render the commands for provided  configuration
  cisco.ios.ios_ospf_interfaces:
    config:
      - name: GigabitEthernet0/1
        address_family:
          - afi: ipv4
            process:
              id: 10
              area_id: 30
            adjacency: true
            bfd: true
            cost:
              interface_cost: 5
            dead_interval:
              time: 5
            demand_circuit:
              ignore: true
            network:
              broadcast: true
            priority: 25
            resync_timeout: 10
            shutdown: true
            ttl_security:
              hops: 50
          - afi: ipv6
            process:
              id: 35
              area_id: 45
            adjacency: true
            database_filter: true
            manet:
              link_metrics:
                cost_threshold: 10
            priority: 55
            transmit_delay: 45
    state: rendered

# Task Output:
# ------------
#
# rendered:
# - interface GigabitEthernet0/1
# - ip ospf 10 area 30
# - ip ospf adjacency stagger disable
# - ip ospf bfd
# - ip ospf cost 5
# - ip ospf dead-interval 5
# - ip ospf demand-circuit ignore
# - ip ospf network broadcast
# - ip ospf priority 25
# - ip ospf resync-timeout 10
# - ip ospf shutdown
# - ip ospf ttl-security hops 50
# - ipv6 ospf 35 area 45
# - ipv6 ospf adjacency stagger disable
# - ipv6 ospf database-filter all out
# - ipv6 ospf manet peering link-metrics 10
# - ipv6 ospf priority 55
# - ipv6 ospf transmit-delay 45
#

# Using Parsed

# File: parsed.cfg
# ----------------
#
# interface GigabitEthernet0/2
# interface GigabitEthernet0/1
#  ip ospf network broadcast
#  ip ospf resync-timeout 10
#  ip ospf dead-interval 5
#  ip ospf priority 25
#  ip ospf demand-circuit ignore
#  ip ospf bfd
#  ip ospf adjacency stagger disable
#  ip ospf ttl-security hops 50
#  ip ospf shutdown
#  ip ospf 10 area 30
#  ip ospf cost 5
#  ipv6 ospf 35 area 45
#  ipv6 ospf priority 55
#  ipv6 ospf transmit-delay 45
#  ipv6 ospf database-filter all out
#  ipv6 ospf adjacency stagger disable
#  ipv6 ospf manet peering link-metrics 10
# interface GigabitEthernet0/0

- name: Parse the provided configuration with the existing running configuration
  cisco.ios.ios_ospf_interfaces:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Task Output:
# ------------
#
# parsed:
#   - name: GigabitEthernet0/2
#   - address_family:
#     - adjacency: true
#       afi: ipv4
#       bfd: true
#       cost:
#         interface_cost: 5
#       dead_interval:
#         time: 5
#       demand_circuit:
#         enable: true
#         ignore: true
#       network:
#         broadcast: true
#       priority: 25
#       process:
#         area_id: '30'
#         id: 10
#       resync_timeout: 10
#       shutdown: true
#       ttl_security:
#         hops: 50
#         set: true
#     - adjacency: true
#       afi: ipv6
#       database_filter: true
#       manet:
#         link_metrics:
#           cost_threshold: 10
#       priority: 55
#       process:
#         area_id: '45'
#         id: 35
#       transmit_delay: 45
#     name: GigabitEthernet0/1
#   - name: GigabitEthernet0/0

返回值

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

描述

after

list / elements=string

模块执行后的结果配置。

返回: 当发生更改时

示例: ["此 输出 始终 模块 参数规范的格式相同。\n"]

before

list / elements=string

模块执行之前的配置。

返回:statemergedreplacedoverriddendeletedpurged

示例: ["此 输出 始终 模块 参数规范的格式相同。\n"]

commands

list / elements=string

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

返回:statemergedreplacedoverriddendeletedpurged

示例: ["interface GigabitEthernet2", "ip ospf priority 40", "ip ospf adjacency stagger disable"]

gathered

list / elements=string

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

返回:stategathered

示例: ["此 输出 始终 模块 参数规范的格式相同。\n"]

parsed

list / elements=string

running_config 选项中提供的设备本机配置,根据模块参数规范解析为结构化数据。

返回:stateparsed

示例: ["此 输出 始终 模块 参数规范的格式相同。\n"]

rendered

list / elements=string

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

返回:staterendered

示例: ["interface GigabitEthernet2", "ip ospf priority 40", "ip ospf adjacency stagger disable"]

作者

  • Sagar Paul (@KB-perByte)

  • Sumit Jaiswal (@justjais)