junipernetworks.junos.junos_lldp_interfaces 模块 – LLDP 接口资源模块

注意

此模块是 junipernetworks.junos 集合(版本 9.1.0)的一部分。

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

要安装它,请使用:ansible-galaxy collection install junipernetworks.junos

要在 playbook 中使用它,请指定:junipernetworks.junos.junos_lldp_interfaces

junipernetworks.junos 1.0.0 中的新增功能

概要

  • 此模块管理 Juniper JUNOS 设备上接口的链路层发现协议 (LLDP) 属性。

参数

参数

注释

config

列表 / elements=字典

链路层发现协议接口属性配置的列表

enabled

布尔值

这是一个布尔值,用于控制在接口 name 上禁用 LLDP

选项

  • false

  • true

name

字符串 / 必需

需要在其上配置 LLDP 的接口的名称。

running_config

字符串

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

此选项的值应是通过执行命令 **show protocols lldp** 从 Junos 设备接收的输出。

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

state

字符串

模块完成后的配置状态。

选项

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "rendered"

  • "parsed"

示例

# Using merged
# Before state:
# -------------
# user@junos01# # show protocols lldp
# management-address 10.1.1.1;
# advertisement-interval 10000;

- name: Merge provided configuration with device configuration
  junipernetworks.junos.junos_lldp_interfaces:
    config:
      - name: ge-0/0/1
      - name: ge-0/0/2
        enabled: false
    state: merged

# After state:
# -------------
# user@junos01# show protocols lldp
# management-address 10.1.1.1;
# advertisement-interval 10000;
# interface ge-0/0/1;
# interface ge-0/0/2 {
#     disable;
# }

# Using replaced
# Before state:
# -------------
# user@junos01# show protocols lldp
# management-address 10.1.1.1;
# advertisement-interval 10000;
# interface ge-0/0/1;
# interface ge-0/0/2 {
#     disable;
# }

- name: Replace provided configuration with device configuration
  junipernetworks.junos.junos_lldp_interfaces:
    config:
      - name: ge-0/0/2
        disable: false
      - name: ge-0/0/3
        enabled: false
    state: replaced

# After state:
# -------------
# user@junos01# show protocols lldp
# management-address 10.1.1.1;
# advertisement-interval 10000;
# interface ge-0/0/1;
# interface ge-0/0/2;
# interface ge-0/0/3 {
#     disable;
# }

# Using overridden
# Before state:
# -------------
# user@junos01# show protocols lldp
# management-address 10.1.1.1;
# advertisement-interval 10000;
# interface ge-0/0/1;
# interface ge-0/0/2 {
#     disable;
# }

- name: Override provided configuration with device configuration
  junipernetworks.junos.junos_lldp_interfaces:
    config:
      - name: ge-0/0/2
        enabled: false
    state: overridden

# After state:
# -------------
# user@junos01# show protocols lldp
# management-address 10.1.1.1;
# advertisement-interval 10000;
# interface ge-0/0/2 {
#     disable;
# }

# Using deleted
# Before state:
# -------------
# user@junos01# show protocols lldp
# management-address 10.1.1.1;
# advertisement-interval 10000;
# interface ge-0/0/1;
# interface ge-0/0/2;
# interface ge-0/0/3 {
#     disable;
# }
- name: Delete lldp interface configuration (this will not delete other lldp configuration)
  junipernetworks.junos.junos_lldp_interfaces:
    config:
      - name: ge-0/0/1
      - name: ge-0/0/3
    state: deleted

# After state:
# -------------
# user@junos01# show protocols lldp
# management-address 10.1.1.1;
# advertisement-interval 10000;
# interface ge-0/0/2;
# interface ge-0/0/1;
# Using gathered
# Before state:
# ------------
#
# ansible@cm123456tr21# show protocols lldp
# interface ge-0/0/1;
# interface ge-0/0/2 {
#     disable;
# }
- name: Gather junos lldp interfaces as in given arguments
  junipernetworks.junos.junos_lldp_interfaces:
    state: gathered
# Task Output (redacted)
# -----------------------
#
# "gathered": [
#         {
#             "name": "ge-0/0/1"
#         },
#         {
#             "enabled": false,
#             "name": "ge-0/0/2"
#         }
#     ]
# After state:
# ------------
#
# ansible@cm123456tr21# show protocols lldp
# interface ge-0/0/1;
# interface ge-0/0/2 {
#     disable;
# }
# Using rendered
- name: Render platform specific xml from task input using rendered state
  junipernetworks.junos.junos_lldp_interfaces:
    config:
      - name: ge-0/0/1
      - name: ge-0/0/2
        enabled: false
    state: rendered
# Task Output (redacted)
# -----------------------
# "rendered": "<nc:protocols
#     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
#     <nc:lldp>
#         <nc:interface>
#             <nc:name>ge-0/0/1</nc:name>
#             <nc:disable delete="delete"/>
#         </nc:interface>
#         <nc:interface>
#             <nc:name>ge-0/0/2</nc:name>
#             <nc:disable/>
#         </nc:interface>
#     </nc:lldp>
# </nc:protocols>"
# Using parsed
# parsed.cfg
# ------------
#
# <?xml version="1.0" encoding="UTF-8"?>
# <rpc-reply message-id="urn:uuid:0cadb4e8-5bba-47f4-986e-72906227007f">
#     <configuration changed-seconds="1590139550" changed-localtime="2020-05-22 09:25:50 UTC">
#         <protocols>
#             <ospf>
#                 <area>
#                     <name>0.0.0.0</name>
#                     <interface>
#                         <name>ge-0/0/0.0</name>
#                     </interface>
#                 </area>
#             </ospf>
#             <lldp>
#                 <interface>
#                     <name>ge-0/0/1</name>
#                 </interface>
#                 <interface>
#                     <name>ge-0/0/2</name>
#                     <disable/>
#                 </interface>
#             </lldp>
#         </protocols>
#     </configuration>
# </rpc-reply>
# - name: Convert lldp interfaces config to argspec without connecting to the appliance
#   junipernetworks.junos.junos_lldp_interfaces:
#     running_config: "{{ lookup('file', './parsed.cfg') }}"
#     state: parsed
# Task Output (redacted)
# -----------------------
# "parsed": [
#         {
#             "name": "ge-0/0/1"
#         },
#         {
#             "enabled": false,
#             "name": "ge-0/0/2"
#         }
#     ]

返回值

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

描述

after

列表 / elements=字符串

模块完成后,配置作为结构化数据。

返回: 当更改时

示例: ["返回的配置将始终与上述参数的格式相同。\n"]

before

列表 / elements=字符串

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

返回: 始终

示例: ["返回的配置将始终与上述参数的格式相同。\n"]

commands

列表 / elements=字符串

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

返回: 始终

示例: ["<nc:protocols xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> <nc:lldp> <nc:interface> <nc:name>ge-0/0/1</nc:name> <nc:disable delete=\"delete\"/> </nc:interface> <nc:interface> <nc:name>ge-0/0/2</nc:name> <nc:disable/> </nc:interface> </nc:lldp> </nc:protocols>", "xml 2", "xml 3"]

作者

  • Ganesh Nalawade (@ganeshrn)