cisco.ios.ios_lldp_global 模块 – 配置 LLDP 的资源模块。

注意

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

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

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

要在剧本中使用它,请指定: cisco.ios.ios_lldp_global

cisco.ios 1.0.0 中的新增功能

概要

  • 此模块配置和管理 IOS 平台上的链路层发现协议 (LLDP) 属性。

参数

参数

注释

config

字典

LLDP 选项的字典

enabled

布尔值

启用 LLDP

选项

  • false

  • true

holdtime

整数

LLDP 保持时间(以秒为单位),将发送在数据包中。

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

reinit

整数

指定 LLDP 初始化的延迟(以秒为单位)。

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

注意,如果 LLDP reinit 配置了起始值,则不会保持幂等性,因为 Cisco 设备不会记录配置的起始 reinit 值。因此,Ansible 无法从设备端验证相应的起始 reinit 值是否已配置。如果尝试在每次运行中应用起始 reinit 值,Ansible 将显示 changed 为 True。对于任何其他 reinit 值,将保持幂等性,因为任何其他 reinit 值都会记录在 Cisco 设备中。

timer

整数

指定发送 LLDP 数据包的速率(以秒为单位)。

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

tlv_select

字典

选择要发送的 LLDP TLV,即类型-长度-值。

注意,如果配置了 tlv-select,则不会保持幂等性,因为 Cisco 设备不会记录配置的 tlv-select 选项。因此,Ansible 无法从设备端验证相应的 tlv-select 选项是否已配置。如果尝试在每次运行中应用 tlv-select 选项,Ansible 将显示 changed 为 True。

four_wire_power_management

布尔值

通过 MDI TLV 进行 Cisco 4 线供电

选项

  • false

  • true

mac_phy_cfg

布尔值

IEEE 802.3 MAC/Phy 配置/状态 TLV

选项

  • false

  • true

management_address

布尔值

管理地址 TLV

选项

  • false

  • true

port_description

布尔值

端口描述 TLV

选项

  • false

  • true

port_vlan

布尔值

端口 VLAN ID TLV

选项

  • false

  • true

power_management

布尔值

IEEE 802.3 DTE 通过 MDI TLV 供电

选项

  • false

  • true

system_capabilities

布尔值

系统功能 TLV

选项

  • false

  • true

system_description

布尔值

系统描述 TLV

选项

  • false

  • true

system_name

布尔值

系统名称 TLV

选项

  • false

  • true

running_config

字符串

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

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

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

state

字符串

配置应保留的状态

该模块对 replaced 和 overridden 状态具有声明性相似的行为。

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

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

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

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

选项

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "rendered"

  • "gathered"

  • "parsed"

备注

注意

示例

# Using merged

# Before state:
# -------------
# vios#sh running-config | section ^lldp
# vios1#

- name: Merge provided configuration with device configuration
  cisco.ios.ios_lldp_global:
    config:
      holdtime: 10
      enabled: true
      reinit: 3
      timer: 10
    state: merged

# After state:
# ------------
# vios#sh running-config | section ^lldp
#  lldp timer 10
#  lldp holdtime 10
#  lldp reinit 3
#  lldp run

# Using replaced

# Before state:
# -------------
# vios#sh running-config | section ^lldp
#  lldp timer 10
#  lldp holdtime 10
#  lldp reinit 3
#  lldp run

- name: Replaces LLDP device configuration with provided configuration
  cisco.ios.ios_lldp_global:
    config:
      holdtime: 20
      reinit: 5
    state: replaced

# After state:
# -------------
# vios#sh running-config | section ^lldp
#  lldp holdtime 20
#  lldp reinit 5

# Using Deleted without any config passed
# "(NOTE: This will delete all of configured LLDP module attributes)"

# Before state:
# -------------
# vios#sh running-config | section ^lldp
#  lldp timer 10
#  lldp holdtime 10
#  lldp reinit 3
#  lldp run

- name: Delete LLDP attributes
  cisco.ios.ios_lldp_global:
    state: deleted

# After state:
# -------------
# vios#sh running-config | section ^lldp
# vios1#

# Using Gathered

# Before state:
# -------------
#
# vios#sh running-config | section ^lldp
#  lldp timer 10
#  lldp holdtime 10
#  lldp reinit 3
#  lldp run

- name: Gather listed interfaces with provided configurations
  cisco.ios.ios_lldp_global:
    config:
    state: gathered

# Module Execution Result:
# ------------------------
#
# "gathered": {
#         "enabled": true,
#         "holdtime": 10,
#         "reinit": 3,
#         "timer": 10
#     }

# After state:
# ------------
#
# vios#sh running-config | section ^lldp
#  lldp timer 10
#  lldp holdtime 10
#  lldp reinit 3
#  lldp run

# Using Rendered
- name: Render the commands for provided  configuration
  cisco.ios.ios_lldp_global:
    config:
      holdtime: 10
      enabled: true
      reinit: 3
      timer: 10
    state: rendered

# Module Execution Result:
# ------------------------
#
# "rendered": [
#         "lldp holdtime 10",
#         "lldp run",
#         "lldp timer 10",
#         "lldp reinit 3"
#     ]

# Using Parsed

# File: parsed.cfg
# ----------------
#
# lldp timer 10
# lldp holdtime 10
# lldp reinit 3
# lldp run

- name: Parse the commands for provided configuration
  cisco.ios.ios_lldp_global:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Module Execution Result:
# ------------------------
#
# "parsed": {
#         "enabled": true,
#         "holdtime": 10,
#         "reinit": 3,
#         "timer": 10
#     }

返回值

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

描述

after

字典

模块完成后的结构化数据配置。

返回值:已更改时

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

before

字典

模块调用之前的结构化数据配置。

返回值:始终返回

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

commands

列表 / 元素=字符串

推送到远程设备的命令集

返回值:始终返回

示例: ["lldp holdtime 10", "lldp run", "lldp timer 10"]

作者

  • Sumit Jaiswal (@justjais)