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

list / elements=dictionary

OSPF 接口选项的字典。

address_family

list / elements=dictionary

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

adjacency

boolean

邻接错开

选项

  • false

  • true

afi

string / required

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

选项

  • “ipv4”

  • “ipv6”

authentication

dictionary

启用身份验证

key_chain

string

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

message_digest

boolean

使用消息摘要身份验证

选项

  • false

  • true

null

boolean

不使用身份验证

选项

  • false

  • true

bfd

boolean

BFD 配置命令

在此接口上启用/禁用 BFD

选项

  • false

  • true

cost

dictionary

接口成本

dynamic_cost

dictionary

指定动态成本选项

仅对 IPv6 OSPF 配置有效

default

integer

指定默认链路度量值

hysteresis

dictionary

为 LSA 抑制指定迟滞值

percent

integer

指定迟滞百分比变化。请参阅供应商文档了解有效值。

threshold

integer

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

weight

dictionary

指定应用于各个度量的权重

l2_factor

integer

指定给予 L2 因子度量的权重

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

latency

integer

指定给予延迟度量的权重。

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

oc

boolean

指定给予 oc 的 cdr/mdr 的权重

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

选项

  • false

  • true

resources

integer

指定给予资源度量的权重

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

throughput

integer

指定给予吞吐量度量的权重

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

interface_cost

integer

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

database_filter

boolean

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

选项

  • false

  • true

dead_interval

dictionary

邻居被声明为死亡后经过的时间间隔

minimal

integer

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

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

仅对 IP OSPF 配置有效

time

integer

以秒为单位的时间

demand_circuit

dictionary

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

disable

boolean

禁用此接口上的按需电路

仅对 IPv6 OSPF 配置有效

选项

  • false

  • true

enable

boolean

启用按需电路

选项

  • false

  • true

ignore

boolean

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

选项

  • false

  • true

flood_reduction

boolean

OSPF 泛洪减少

选项

  • false

  • true

hello_interval

integer

HELLO 数据包之间的时间

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

lls

boolean

链路本地信令 (LLS) 支持

仅对 IP OSPF 配置有效

选项

  • false

  • true

manet

dictionary

移动自组织网络选项

MANET 对等选项

仅对 IPv6 OSPF 配置有效

cost

dictionary

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

percent

integer

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

threshold

integer

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

dictionary

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

integer

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

boolean

启用链路度量

选项

  • false

  • true

mtu_ignore

boolean

忽略 DBD 数据包中的 MTU

选项

  • false

  • true

multi_area

dictionary

设置 OSPF 多区域 ID

仅对 IP OSPF 配置有效

cost

integer

接口成本

id

integer

OSPF 多区域 ID(十进制值)。请参阅供应商文档了解有效值。

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

neighbor

dictionary

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

仅对 IPv6 OSPF 配置有效

address

string

邻居链路本地 IPv6 地址

cost

integer

点对多点邻居的 OSPF 成本

database_filter

boolean

在同步和泛洪期间过滤点对多点邻居的 OSPF LSA

选项

  • false

  • true

poll_interval

integer

OSPF 死路由器轮询间隔

priority

integer

非广播邻居的 OSPF 优先级

network

dictionary

网络类型

broadcast

boolean

指定 OSPF 广播多路访问网络

选项

  • false

  • true

manet

boolean

指定 MANET OSPF 接口类型

仅对 IPv6 OSPF 配置有效

选项

  • false

  • true

non_broadcast

boolean

指定 OSPF NBMA 网络

选项

  • false

  • true

point_to_multipoint

boolean

指定 OSPF 点对多点网络

选项

  • false

  • true

point_to_point

boolean

指定 OSPF 点对点网络

选项

  • false

  • true

prefix_suppression

boolean

启用/禁用 OSPF 前缀抑制

选项

  • false

  • true

priority

integer

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

process

dictionary

OSPF 接口配置

area_id

string

OSPF 接口区域 ID,以十进制数值表示。请参考供应商文档以获取有效值。

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

id

integer

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

instance_id

integer

根据 ID 设置 OSPF 实例。

仅对 IPv6 OSPF 配置有效

secondaries

boolean

包含或排除辅助 IP 地址。

仅在 IPv4 配置中有效。

选项

  • false

  • true

resync_timeout

integer

如果未启动 oob-resync,则重置邻接关系的间隔。请参考供应商文档以获取有效值。

retransmit_interval

integer

重新传输丢失的链路状态通告的时间间隔。请参考供应商文档以获取有效值。

shutdown

boolean

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

选项

  • false

  • true

transmit_delay

integer

链路状态传输延迟。请参考供应商文档以获取有效值。

ttl_security

dictionary

TTL 安全检查。

仅在 IPV4 OSPF 配置中有效。

hops

integer

允许的最大 IP 跳数。

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

set

boolean

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

选项

  • false

  • true

name

string / required

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

running_config

string

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

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

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

state

string

配置应保留的状态。

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

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

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

状态 parsedrunning_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

模块执行后的结果配置。

返回: 当发生更改时

示例: ["此输出始终与模块的argspec格式相同。\n"]

before

list / elements=string

模块执行之前的配置。

返回:statemergedreplacedoverriddendeletedpurged

示例: ["此输出始终与模块的argspec格式相同。\n"]

commands

list / elements=string

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

返回:statemergedreplacedoverriddendeletedpurged

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

gathered

list / elements=string

从远程设备收集的网络资源信息,以结构化数据形式表示。

返回:stategathered

示例: ["此输出始终与模块的argspec格式相同。\n"]

parsed

list / elements=string

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

返回:stateparsed

示例: ["此输出始终与模块的argspec格式相同。\n"]

rendered

list / elements=string

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

返回:staterendered

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

作者

  • Sagar Paul (@KB-perByte)

  • Sumit Jaiswal (@justjais)