cisco.ios.ios_lldp_interfaces 模块 – 用于配置 LLDP 接口的资源模块。
注意
此模块是 cisco.ios 集合(版本 9.0.3)的一部分。
如果您正在使用 ansible
包,您可能已经安装了这个集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install cisco.ios
。
要在 Playbook 中使用它,请指定:cisco.ios.ios_lldp_interfaces
。
cisco.ios 1.0.0 中的新功能
概要
此模块管理 Cisco IOS 设备上接口的链路层发现协议 (LLDP) 属性。
参数
参数 |
注释 |
---|---|
LLDP 选项的字典 |
|
要发送的 LLDP MED TLV 的选择 注意,如果配置了 med-tlv-select,则不会保持幂等性,因为 Cisco 设备不会记录配置的 med-tlv-select 选项。因此,Ansible 无法从设备端验证是否已配置相应的 med-tlv-select 选项。如果您尝试在每次运行中应用 med-tlv-select 选项,Ansible 将显示 changed 为 True。 |
|
LLDP MED 库存管理 TLV 选择
|
|
接口的全名,不包括任何逻辑单元号,例如 GigabitEthernet0/1。 |
|
在接口上启用 LLDP 接收。 选择
|
|
要发送的 LLDP 类型-长度-值,即 TLV 的选择 注意,如果配置了 tlv-select,则不会保持幂等性,因为 Cisco 设备不会记录配置的 tlv-select 选项。因此,Ansible 无法从设备端验证是否已配置相应的 tlv-select 选项。如果您尝试在每次运行中应用 tlv-select 选项,Ansible 将显示 changed 为 True。 |
|
通过 MDI TLV 的 IEEE 802.3 DTE 电源 选择
|
|
在接口上启用 LLDP 传输。 选择
|
|
此选项仅在状态为 *parsed* 时使用。 此选项的值应该是通过执行命令 **sh lldp interface** 从 IOS 设备收到的输出。 状态 *parsed* 从 |
|
配置应保留的状态 状态 *rendered*、*gathered* 和 *parsed* 不会对设备执行任何更改。 状态 *rendered* 会将 状态 *gathered* 将从设备获取运行配置,并将其转换为结构化数据,格式符合资源模块 argspec,然后该值将返回到结果中的 *gathered* 键中。 状态 *parsed* 从 选择
|
注释
注意
已针对 CML 上的 Cisco IOSXE 版本 17.3 进行测试。
此模块与连接
network_cli
一起使用。请参阅 https://docs.ansible.org.cn/ansible/latest/network/user_guide/platform_ios.html
示例
# Using merged
#
# Before state:
# -------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: enabled
# Rx: disabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/2:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: INIT
#
# GigabitEthernet0/3:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
- name: Merge provided configuration with device configuration
cisco.ios.ios_lldp_interfaces:
config:
- name: GigabitEthernet0/1
receive: true
transmit: true
- name: GigabitEthernet0/2
receive: true
- name: GigabitEthernet0/3
transmit: true
state: merged
# After state:
# ------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: enabled
# Rx: disabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/2:
# Tx: disabled
# Rx: enabled
# Tx state: IDLE
# Rx state: INIT
#
# GigabitEthernet0/3:
# Tx: enabled
# Rx: disabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# Using overridden
#
# Before state:
# -------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/2:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: INIT
#
# GigabitEthernet0/3:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
- name: Override device configuration of all lldp_interfaces with provided configuration
cisco.ios.ios_lldp_interfaces:
config:
- name: GigabitEthernet0/2
receive: true
transmit: true
state: overridden
# After state:
# ------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/2:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: INIT
#
# GigabitEthernet0/3:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
# Using replaced
#
# Before state:
# -------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/2:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: INIT
#
# GigabitEthernet0/3:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
- name: Replaces device configuration of listed lldp_interfaces with provided configuration
cisco.ios.ios_lldp_interfaces:
config:
- name: GigabitEthernet0/2
receive: true
transmit: true
- name: GigabitEthernet0/3
receive: true
state: replaced
# After state:
# ------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/2:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: INIT
#
# GigabitEthernet0/3:
# Tx: disabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# Using Deleted
#
# Before state:
# -------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/2:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: INIT
#
# GigabitEthernet0/3:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
- name: "Delete LLDP attributes of given interfaces (Note: This won't delete the interface itself)"
cisco.ios.ios_lldp_interfaces:
config:
- name: GigabitEthernet0/1
state: deleted
# After state:
# -------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: INIT
#
# GigabitEthernet0/2:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: INIT
#
# GigabitEthernet0/3:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# Using Deleted without any config passed
# "(NOTE: This will delete all of configured LLDP module attributes)"
#
# Before state:
# -------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/2:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: INIT
#
# GigabitEthernet0/3:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
- name: "Delete LLDP attributes for all configured interfaces (Note: This won't delete the interface itself)"
cisco.ios.ios_lldp_interfaces:
state: deleted
# After state:
# -------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/2:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: INIT
#
# GigabitEthernet0/3:
# Tx: disabled
# Rx: disabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
# Using Gathered
# Before state:
# -------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/2:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
- name: Gather listed LLDP interfaces with provided configurations
cisco.ios.ios_lldp_interfaces:
config:
state: gathered
# Module Execution Result:
# ------------------------
#
# "gathered": [
# {
# "name": "GigabitEthernet0/0",
# "receive": true,
# "transmit": true
# },
# {
# "name": "GigabitEthernet0/1",
# "receive": true,
# "transmit": true
# },
# {
# "name": "GigabitEthernet0/2",
# "receive": true,
# "transmit": true
# }
# ]
# After state:
# ------------
#
# vios#sh lldp interface
# GigabitEthernet0/0:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
# GigabitEthernet0/2:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
# Using Rendered
- name: Render the commands for provided configuration
cisco.ios.ios_lldp_interfaces:
config:
- name: GigabitEthernet0/0
receive: true
transmit: true
- name: GigabitEthernet0/1
receive: true
transmit: true
- name: GigabitEthernet0/2
receive: true
state: rendered
# Module Execution Result:
# ------------------------
#
# "rendered": [
# "interface GigabitEthernet0/0",
# "lldp receive",
# "lldp transmit",
# "interface GigabitEthernet0/1",
# "lldp receive",
# "lldp transmit",
# "interface GigabitEthernet0/2",
# "lldp receive"
# ]
# Using Parsed
# File: parsed.cfg
# ----------------
#
# GigabitEthernet0/0:
# Tx: enabled
# Rx: disabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/1:
# Tx: enabled
# Rx: enabled
# Tx state: IDLE
# Rx state: WAIT FOR FRAME
#
# GigabitEthernet0/2:
# Tx: disabled
# Rx: enabled
# Tx state: IDLE
# Rx state: INIT
- name: Parse the commands for provided configuration
cisco.ios.ios_lldp_interfaces:
running_config: "{{ lookup('file', 'parsed.cfg') }}"
state: parsed
# Module Execution Result:
# ------------------------
#
# "parsed": [
# {
# "name": "GigabitEthernet0/0",
# "receive": false,
# "transmit": true
# },
# {
# "name": "GigabitEthernet0/1",
# "receive": true,
# "transmit": true
# },
# {
# "name": "GigabitEthernet0/2",
# "receive": true,
# "transmit": false
# }
# ]
返回值
通用返回值记录在此处,以下是此模块独有的字段
键 |
描述 |
---|---|
模块完成后,以结构化数据形式呈现的配置。 返回: 当发生更改时 示例: |
|
模块调用前,以结构化数据形式呈现的配置。 返回: 始终 示例: |
|
推送到远程设备的命令集。 返回: 始终 示例: |