junipernetworks.junos.junos_snmp_server 模块 – 管理 Junos 设备上的 SNMP 服务器配置。

注意

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

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

要安装它,请使用:ansible-galaxy collection install junipernetworks.junos。您需要其他需求才能使用此模块,有关详细信息,请参阅 需求

要在剧本中使用它,请指定:junipernetworks.junos.junos_snmp_server

junipernetworks.junos 2.9.0 中的新增功能

摘要

  • 此模块管理在运行 Junos 的设备上的 SNMP 服务器配置。

需求

执行此模块的主机需要以下需求。

  • ncclient (>=v0.6.4)

  • xmltodict (>=0.12.0)

参数

参数

注释

config

字典

SNMP 服务器配置的字典。

arp

字典

指定 JVision arp 设置。

host_name_resolution

布尔值

启用主机名解析。

选项

  • false

  • true

set

布尔值

设置 JVision arp。

选项

  • false

  • true

client_lists

列表 / 元素=字典

指定客户端列表。

addresses

列表 / 元素=字典

指定地址/前缀列表。

address

字符串

指定地址或前缀。

restrict

布尔值

拒绝访问。

选项

  • false

  • true

name

字符串

指定客户端列表名称。

communities

列表 / 元素=字典

指定社区字符串列表。

authorization

字符串

指定授权类型。

选项

  • "只读"

  • "读写"

client_list_name

字符串

指定客户端列表或前缀列表的名称。

clients

列表 / 元素=字典

指定要接受的源地址前缀范围列表。

address

字符串

指定地址或前缀。

restrict

布尔值

拒绝访问。

选项

  • false

  • true

logical_system

列表 / 元素=字符串

为 v1/v2c 客户端使用逻辑系统名称。

name

字符串

指定社区的名称。

routing_instances

列表 / 元素=字典

为 v1/v2c 客户端使用路由实例名称。

client_list_name

字符串

指定客户端列表或前缀列表的名称。

clients

列表 / 元素=字典

指定要接受的源地址前缀范围列表。

address

字符串

指定地址或前缀。

restrict

布尔值

拒绝访问。

选项

  • false

  • true

name

字符串

指定路由实例。

view

字符串

指定视图名称。

contact

字符串

指定管理员的联系信息。

customization

字典

基于旋钮自定义 SNMP 行为。

ether_stats_ifd_only

布尔值

停止将 IFL 作为 etherStatsTable 的一部分公开。

选项

  • false

  • true

description

字符串

系统描述。

engine_id

字典

指定 SNMPv3 引擎 ID

local

字符串

本地引擎 ID。

use_default_ip_address

布尔值

使用引擎 ID 的默认 IP 地址。

选项

  • false

  • true

use_mac_address

布尔值

使用管理接口 MAC 地址作为引擎 ID。

选项

  • false

  • true

filter_duplicates

布尔值

过滤具有重复源地址/端口和请求 ID 的请求。

选项

  • false

  • true

filter_interfaces

字典

需要过滤的接口列表。

all_internal_interfaces

布尔值

过滤所有内部接口。

选项

  • false

  • true

interfaces

列表 / 元素=字符串

指定要过滤的指定接口。

set

布尔值

设置 filter-interfaces。

选项

  • false

  • true

health_monitor

字典

指定运行状况监控配置。

falling_threshold

整数

应用于所有监控对象的下降阈值。

idp

布尔值

IDP 运行状况监控配置。

选项

  • false

  • true

interval

整数

样本之间的间隔。

rising_threshold

整数

应用于所有监控对象的上升阈值。

set

布尔值

设置 health-monitor 配置。

选项

  • false

  • true

if_count_with_filter_interfaces

布尔值

ifNumber 和 ipv6Interfaces 的过滤器接口配置。

选项

  • false

  • true

interfaces

列表 / 元素=字符串

将 SNMP 请求限制为接口。

location

字符串

指定系统的物理位置。

logical_system_trap_filter

布尔值

仅允许逻辑系统特定的陷阱。

选项

  • false

  • true

name

字符串

系统名称覆盖。

nonvolatile

字典

配置对非易失性 SNMP 设置请求的处理。

commit_delay

整数

肯定的 SNMP 设置回复和提交开始之间的延迟(秒)。

proxies

列表 / 元素=字典

SNMP 代理配置。

device_name

字符串

卫星/代理设备名称或 IP 地址。

logical_system

列表 / 元素=字符串

为 v1/v2c 客户端使用逻辑系统名称。

name

字符串

指定代理名称。

routing_instances

列表 / 元素=字典

为 v1/v2c 客户端使用路由实例名称。

client_list_name

字符串

指定客户端列表或前缀列表的名称。

clients

列表 / 元素=字典

指定要接受的源地址前缀范围列表。

address

字符串

指定地址或前缀。

restrict

布尔值

拒绝访问。

选项

  • false

  • true

name

字符串

指定路由实例。

version_v1

字典

为 v1 代理配置指定 snmp-community。

no_default_comm_to_v3_config

布尔值

指定无默认 snmp-community 和 v3 配置。

选项

  • false

  • true

snmp_community

字符串

指定社区名称。

version_v2c

字典

为 v2c 代理配置指定 snmp-community。

no_default_comm_to_v3_config

布尔值

指定无默认 snmp-community 和 v3 配置。

选项

  • false

  • true

snmp_community

字符串

指定社区名称。

version_v3

字典

为 v3 代理配置指定 security-name。

context

布尔值

指定与此 security-name 关联的上下文名称。

选项

  • false

  • true

security_name

字符串

指定 v3 security-name。

rmon

字典

指定远程监控配置。

alarms

列表 / 元素=字典

RMON 警报条目。

description

字符串

警报的常规描述(存储在 alarmOwner 中)。

falling_event_index

整数

越过下降阈值后触发的事件。

falling_threshold

整数

指定下降阈值。

falling_threshold_interval

整数

下降阈值测试期间样本之间的间隔。

id

字符串

指定警报 ID。

interval

整数

样本之间的间隔。

request_type

字符串

要为警报发出的 SNMP 请求的类型。

选项

  • "get-next-request"

  • "get-request"

  • "walk-request"

rising_event_index

整数

越过上升阈值后触发的事件。

rising_threshold

整数

上升阈值。

sample_type

字符串

采样所选变量的方法。

选项

  • "绝对值"

  • "增量值"

startup_alarm

字符串

启动时可能发送的警报。

选项

  • "下降警报"

  • "上升警报"

  • "上升或下降警报"

syslog_subtag

字符串

要添加到 syslog 消息的标签。

variable

字符串

要监控的 MIB 变量的 OID。

events

列表 / 元素=字典

RMON 事件条目。

community

字符串

用于传出陷阱的社区(陷阱组)。

description

字符串

事件的常规描述。

id

整数

指定事件 ID。

type

字符串

此事件的通知类型。

选项

  • "日志"

  • "日志和陷阱"

  • "无"

  • "snmptrap"

set

布尔值

设置远程监控配置。

选项

  • false

  • true

routing_instance_access

字典

SNMP 路由实例选项。

access_lists

列表 / 元素=字符串

允许/拒绝对路由实例的 SNMP 访问。

set

布尔值

设置 routing_instance_access。

选项

  • false

  • true

snmp_v3

字典

SNMPv3 配置信息。

notify

列表 / 元素=字典

用于选择通知的目标以及通知的类型。

name

字符串

指定通知名称。

tag

字符串

通知将发送到使用此标记配置的所有目标。

type

字符串

通知类型。

notify_filter

列表 / 元素=字典

应用于 SNMP 通知筛选器。

name

字符串

指定通知筛选器名称。

oids

列表 / 元素=字典

要包含/排除在通知筛选器中的 OID。

exclude

布尔值

从通知过滤器中排除此 OID。

选项

  • false

  • true

包含

布尔值

将此 OID 包含在通知过滤器中。

选项

  • false

  • true

OID

字符串

指定 OID。

snmp_community

列表 / 元素=字典

SNMP 社区和基于视图的访问控制模型配置。

community_index

字符串

此社区表条目中的唯一索引值。

community_name

字符串

SNMPv1/v2c 社区名称(默认为与 community-index 相同)。

context

字符串

执行访问控制时使用的上下文。

security_name

字符串

执行访问控制时使用的安全名称。

tag

字符串

允许使用此社区字符串的目标集的标签标识符。

target_addresses

列表 / 元素=字典

标识通知目标以及允许的管理站。

address

字符串

SNMP 目标地址。

address_mask

字符串

社区字符串访问控制的地址掩码范围。

logical_system

字符串

陷阱目标的逻辑系统名称。

name

字符串

SNMP 目标地址名称。

port

整数

SNMP 目标端口号。

retry_count

整数

已确认的 SNMP 通知最大重试次数。

routing_instance

字符串

陷阱目标的路由实例。

tag_list

字符串

用于选择目标地址的 SNMP 标签列表。

target_parameters

字符串

目标参数表中的 SNMPv3 目标参数名称。

timeout

整数

已确认的 SNMP 通知确认超时(秒)。

target_parameters

列表 / 元素=字典

目标参数表中的 SNMPv3 目标参数名称。

name

字符串

SNMPv3 目标参数名称。

notify_filter

字符串

带有要应用于通知的过滤器名称的通知过滤器。

parameters

字典

发送通知时使用的参数。

message_processing_model

字符串

生成 SNMP 通知时使用的消息处理模型。

选项

  • "v1"

  • "v2c"

  • "v3"

security_level

字符串

生成 SNMP 通知时使用的安全级别。

选项

  • "身份验证"

  • "无"

  • "隐私"

security_model

字符串

生成 SNMP 通知时使用的安全模型。

选项

  • "usm"

  • "v1"

  • "v2c"

security_name

字符串

生成 SNMP 通知时使用的安全名称。

usm

字典

基于用户的安全模型 (USM) 信息。

local_engine

字典

本地引擎用户配置。

users

列表 / 元素=字典

SNMPv3 USM 用户信息。

authentication_md5

字典

配置 MD5 身份验证。

key

字符串

用于用户身份验证的加密密钥。

password

字符串

用户的身份验证密码。

authentication_none

布尔值

为用户设置无身份验证。

选项

  • false

  • true

authentication_sha

字典

配置 SHA 身份验证。

key

字符串

用于用户身份验证的加密密钥。

password

字符串

用户的身份验证密码。

name

字符串

用户名。

privacy_3des

字典

配置三重 DES 隐私。

key

字符串

用于用户隐私的加密密钥。

password

字符串

用户的隐私密码。

privacy_aes128

字典

配置 AES128 隐私。

key

字符串

用于用户隐私的加密密钥。

password

字符串

用户的隐私密码。

privacy_des

字典

配置 DES 隐私。

key

字符串

用于用户隐私的加密密钥。

password

字符串

用户的隐私密码。

privacy_none

布尔值

为用户设置无隐私。

选项

  • false

  • true

remote_engine

列表 / 元素=字典

远程引擎用户配置。

id

字符串

远程引擎 ID。

users

列表 / 元素=字典

SNMPv3 USM 用户信息。

authentication_md5

字典

配置 MD5 身份验证。

key

字符串

用于用户身份验证的加密密钥。

password

字符串

用户的身份验证密码。

authentication_none

布尔值

为用户设置无身份验证。

选项

  • false

  • true

authentication_sha

字典

配置 SHA 身份验证。

key

字符串

用于用户身份验证的加密密钥。

password

字符串

用户的身份验证密码。

name

字符串

用户名。

privacy_3des

字典

配置三重 DES 隐私。

key

字符串

用于用户隐私的加密密钥。

password

字符串

用户的隐私密码。

privacy_aes128

字典

配置 AES128 隐私。

key

字符串

用于用户隐私的加密密钥。

password

字符串

用户的隐私密码。

privacy_des

字典

配置 DES 隐私。

key

字符串

用于用户隐私的加密密钥。

password

字符串

用户的隐私密码。

privacy_none

布尔值

为用户设置无隐私。

选项

  • false

  • true

subagent

字典

SNMP 子代理配置。

tcp

字典

允许 SNMP 子代理 TCP 连接。

routing_instances_default

布尔值

指定 TCP 连接的路由实例名称。

选项

  • false

  • true

set

布尔值

设置 SNMP 子代理 TCP。

选项

  • false

  • true

traceoptions

字典

配置 SNMP 的跟踪选项。

file

字典

指定跟踪文件选项。

files

整数

指定最大跟踪文件数量。

match

字符串

要记录的行对应的正则表达式。

no_world_readable

布尔值

不允许任何用户读取日志文件。

选项

  • false

  • true

size

整数

指定最大跟踪文件大小。

world_readable

布尔值

允许任何用户读取日志文件。

选项

  • false

  • true

flag

字典

指定标志 traceoptions。

all

布尔值

跟踪所有内容。

选项

  • false

  • true

general

布尔值

跟踪一般事件。

选项

  • false

  • true

interface_stats

布尔值

跟踪接口统计信息(逻辑和物理)。

选项

  • false

  • true

nonvolatile_sets

布尔值

非易失性 SNMP 设置请求处理。

选项

  • false

  • true

pdu

布尔值

转储 SNMP 请求/响应数据包。

选项

  • false

  • true

protocol_timeouts

布尔值

跟踪 SNMP 请求超时。

选项

  • false

  • true

routing_socket

布尔值

跟踪路由套接字调用。

选项

  • false

  • true

subagent

布尔值

跟踪主代理与子代理的交互。

选项

  • false

  • true

timer

布尔值

跟踪内部计时器事件。

选项

  • false

  • true

varbind_error

布尔值

跟踪 varbind 错误。

选项

  • false

  • true

memory_trace

字典

内存跟踪信息。

set

布尔值

设置内存跟踪选项。

选项

  • false

  • true

size

整数

指定为跟踪保留的内存大小。

no_remote_trace

布尔值

禁用远程跟踪。

选项

  • false

  • true

trap_groups

列表 / 元素=字典

指定 SNMP 陷阱选项。

categories

字典

指定陷阱类别。

authentication

布尔值

指定身份验证失败。

选项

  • false

  • true

chassis

布尔值

指定机箱或环境通知。

选项

  • false

  • true

chassis_cluster

布尔值

指定集群通知。

选项

  • false

  • true

configuration

布尔值

配置通知。

选项

  • false

  • true

dot3oam_events

布尔值

指定 802.3ah 通知。

选项

  • false

  • true

布尔值

链路上下转换。

选项

  • false

  • true

otn_alarms

字典

OTN 告警陷阱子类别。

oc_lof

布尔值

帧丢失告警通知。

选项

  • false

  • true

oc_lom

布尔值

多帧丢失告警通知。

选项

  • false

  • true

oc_los

布尔值

信号丢失告警通知。

选项

  • false

  • true

odu_ais

布尔值

ODU 告警指示信号告警通知。

选项

  • false

  • true

odu_bbe_threshold

布尔值

ODU 背景块错误阈值告警通知。

选项

  • false

  • true

odu_bdi

布尔值

ODU 反向缺陷指示告警通知。

选项

  • false

  • true

odu_bdodu_es_threshold

布尔值

ODU 错误秒阈值告警通知。

选项

  • false

  • true

odu_lck

布尔值

ODU 锁定告警通知。

选项

  • false

  • true

odu_oci

布尔值

ODU 开启连接指示器告警通知。

选项

  • false

  • true

odu_rx_aps_change

布尔值

ODU 接收 APS 更改通知。

选项

  • false

  • true

odu_sd

布尔值

ODU 信号降级告警通知。

选项

  • false

  • true

odu_ses_threshold

布尔值

ODU 严重错误秒阈值告警通知。

选项

  • false

  • true

odu_sf

布尔值

ODU 信号故障告警通知。

选项

  • false

  • true

odu_ttim

布尔值

ODU 跟踪标识不匹配告警通知。

选项

  • false

  • true

odu_uas_threshold

布尔值

ODU 不可用的秒阈值告警通知。

选项

  • false

  • true

opu_ptm

布尔值

ODU 负载类型不匹配告警通知。

选项

  • false

  • true

otu_ais

布尔值

OTU 告警指示信号告警通知。

选项

  • false

  • true

otu_bbe_threshold

布尔值

OTU 背景块错误阈值告警通知。

选项

  • false

  • true

otu_bdi

布尔值

OTU 反向缺陷指示告警通知。

选项

  • false

  • true

otu_es_threshold

布尔值

OTU 错误秒阈值告警通知。

选项

  • false

  • true

otu_fec_deg

布尔值

OTU FEC 降级错误告警通知。

选项

  • false

  • true

otu_fec_exe

布尔值

OTU FEC 过多错误告警通知。

选项

  • false

  • true

otu_iae

布尔值

OTU 输入对齐错误告警通知。

选项

  • false

  • true

otu_sd

布尔值

OTU 信号降级告警通知。

选项

  • false

  • true

otu_ses_threshold

布尔值

OTU 严重错误秒阈值告警通知。

选项

  • false

  • true

otu_sf

布尔值

OTU 信号故障告警通知。

选项

  • false

  • true

otu_ttim

布尔值

OTU 跟踪标识不匹配告警通知。

选项

  • false

  • true

otu_uas_threshold

布尔值

OTU 不可用的秒阈值告警通知。

选项

  • false

  • true

set

布尔值

设置 otn_alarms。

选项

  • false

  • true

wavelength_lock

布尔值

波长锁定告警通知。

选项

  • false

  • true

remote_operations

布尔值

远程操作。

选项

  • false

  • true

rmon_alarm

布尔值

RMON 上升和下降告警。

选项

  • false

  • true

routing

布尔值

路由协议通知。

选项

  • false

  • true

services

布尔值

服务通知。

选项

  • false

  • true

startup

布尔值

系统热启动和冷启动。

选项

  • false

  • true

vrrp_events

布尔值

VRRP 通知。

选项

  • false

  • true

destination_port

整数

SNMP 陷阱接收器端口号。

logical_system

列表 / 元素=字符串

为 v1/v2c 客户端使用逻辑系统名称。

name

字符串

指定陷阱组名称。

routing_instance

字符串

陷阱目标的路由实例。

targets

列表 / 元素=字符串

陷阱消息的目标。

version

字符串

SNMP 版本。

选项

  • "全部"

  • "v1"

  • "v2"

trap_options

字典

SNMP 陷阱选项。

agent_address

字典

v1 陷阱 PDU 的代理地址。

outgoing_interface

布尔值

使用出站接口上的地址。

选项

  • false

  • true

context_oid

布尔值

在所有陷阱的 varbind 末尾添加上下文 OID。

选项

  • false

  • true

enterprise_oid

布尔值

在所有陷阱的 varbind 中添加 snmpTrapEnterprise OID。

选项

  • false

  • true

logical_system

列表 / 元素=字符串

为 v1/v2c 客户端使用逻辑系统名称。

routing_instance

字符串

指定路由实例。

set

布尔值

设置陷阱选项。

选项

  • false

  • true

source_address

字典

陷阱 PDU 的 IPv4/IPv6 源地址。

address

字符串

使用指定的地址。

lowest_loopback

布尔值

使用环回接口上的最低地址。

选项

  • false

  • true

views

列表 / 元素=字典

定义 MIB 视图。

name

字符串

MIB 视图名称。

oids

列表 / 元素=字典

OID 包含/排除列表

exclude

布尔值

从视图中排除此 OID。

选项

  • false

  • true

包含

布尔值

从视图中包含此 OID。

选项

  • false

  • true

OID

字符串

要包含在视图中或从视图中排除的 OID。

running_config

字符串

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

此选项的值应为通过执行命令 **show system snmp** 从 Junos 设备接收到的输出。

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

state

字符串

配置应保留的状态。

有关更多详细信息,请参阅示例。

选项

  • "merged" ← (默认)

  • "replaced"

  • "deleted"

  • "overridden"

  • "parsed"

  • "gathered"

  • "rendered"

注释

注意

  • 此模块要求在被管理的设备上启用 netconf 系统服务。

  • 此模块可与连接 netconf 配合使用。

  • 请参阅 Junos OS 平台选项

  • 针对 JunOS v18.4R1 进行了测试。

示例

# Using merged
#
# Before state
# ------------
#
# vagrant@vsrx# show routing-instances
# clv1 {
#     description clv1;
# }
# clv2 {
#     description clv2;
# }
- name: Merge provided SNMP configuration into running configuration.
  junipernetworks.junos.junos_snmp_server:
    config:
      arp:
        set: true
        host_name_resolution: true
      client_lists:   # ATTR-----2
        - name: cl1
          addresses:
            - address: "192.16.1.0/24"
            - address: "192.16.2.0/24"
            - address: "11.11.11.11"
              restrict: true
        - name: cl2
          addresses:
            - address: "192.16.4.0/24"
      routing_instance_access:  # ATTR-----3
        set: true
        access_lists:
          - "clv1"
          - "clv2"
    state: merged
#
# -------------------------
# Module Execution Result
# -------------------------
#     "after": {
#         "arp": {
#             "host_name_resolution": true
#         },
#         "client_lists": [
#             {
#                 "addresses": [
#                     {
#                         "address": "192.16.1.0/24"
#                     },
#                     {
#                         "address": "192.16.2.0/24"
#                     },
#                     {
#                         "address": "11.11.11.11/32",
#                         "restrict": true
#                     }
#                 ],
#                 "name": "cl1"
#             },
#             {
#                 "addresses": [
#                     {
#                         "address": "192.16.4.0/24"
#                     }
#                 ],
#                 "name": "cl2"
#             }
#         ],
#         "routing_instance_access": {
#             "access_lists": [
#                 "clv1",
#                 "clv2"
#             ]
#         }
#     },
#     "before": {},
#     "changed": true,
#     "commands": [
#           "<nc:snmp xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"
#           "<nc:arp><nc:host-name-resolution/></nc:arp><nc:client-list><nc:name>cl1</nc:name>"
#           "<nc:client-address-list><nc:name>192.16.1.0/24</nc:name></nc:client-address-list>"
#           "<nc:client-address-list><nc:name>192.16.2.0/24</nc:name></nc:client-address-list><nc:client-address-list>"
#           "<nc:name>11.11.11.11</nc:name><nc:restrict/></nc:client-address-list></nc:client-list><nc:client-list>"
#           "<nc:name>cl2</nc:name><nc:client-address-list><nc:name>192.16.4.0/24</nc:name></nc:client-address-list>"
#           "</nc:client-list><nc:routing-instance-access><nc:access-list><nc:name>clv1</nc:name></nc:access-list>"
#           "<nc:access-list><nc:name>clv2</nc:name></nc:access-list></nc:routing-instance-access></nc:snmp>"
#     ]
# After state
# -----------
#
# vagrant@vsrx# show snmp
# client-list cl1 {
#     192.16.1.0/24;
#     192.16.2.0/24;
#     11.11.11.11/32 {
#         restrict;
#     }
# }
# client-list cl2 {
#     192.16.4.0/24;
# }
# routing-instance-access {
#     access-list {
#         clv1;
#         clv2;
#     }
# }
# arp {
#     host-name-resolution;
# }
# vagrant@vsrx# show routing-instances
# clv1 {
#     description clv1;
# }
# clv2 {
#     description clv2;
# }
#
# Using Replaced
# Before state
# ------------
#
# vagrant@vsrx# show snmp
# client-list cl1 {
#     192.16.1.0/24;
#     192.16.2.0/24;
#     11.11.11.11/32 {
#         restrict;
#     }
# }
# client-list cl2 {
#     192.16.4.0/24;
# }
# routing-instance-access {
#     access-list {
#         clv1;
#         clv2;
#     }
# }
# arp {
#     host-name-resolution;
# }
# vagrant@vsrx# show routing-instances
# clv1 {
#     description clv1;
# }
# clv2 {
#     description clv2;
# }

- name: Replaced running SNMP server configuration with provided configuration
  junipernetworks.junos.junos_snmp_server:
    config:
      contact: "[email protected]"
      customization:
        ether_stats_ifd_only: true
      description: "Local SNMP Server"
      engine_id:
        local: "local1"
        use_default_ip_address: true
        use_mac_address: true
      filter_duplicates: true
      filter_interfaces:
        set: true
        all_internal_interfaces: true
        interfaces:
          - "eth1"
          - "eth2"
    state: replaced
#
# -------------------------
# Module Execution Result
# -------------------------
#     "after": {
#         "contact": "[email protected]",
#         "customization": {
#             "ether_stats_ifd_only": true
#         },
#         "description": "Local SNMP Server",
#         "engine_id": {
#             "use_mac_address": true
#         },
#         "filter_duplicates": true,
#         "filter_interfaces": {
#             "all_internal_interfaces": true,
#             "interfaces": [
#                 "eth1",
#                 "eth2"
#             ]
#         }
#     },
#     "before":
#      {
#         "arp": {
#             "host_name_resolution": true
#         },
#         "client_lists": [
#             {
#                 "addresses": [
#                     {
#                         "address": "192.16.1.0/24"
#                     },
#                     {
#                         "address": "192.16.2.0/24"
#                     },
#                     {
#                         "address": "11.11.11.11/32",
#                         "restrict": true
#                     }
#                 ],
#                 "name": "cl1"
#             },
#             {
#                 "addresses": [
#                     {
#                         "address": "192.16.4.0/24"
#                     }
#                 ],
#                 "name": "cl2"
#             }
#         ],
#         "routing_instance_access": {
#             "access_lists": [
#                 "clv1",
#                 "clv2"
#             ]
#         }
#     },
#     "changed": true,
#     "commands": [
#         "<nc:snmp xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>",
#         "<nc:snmp xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" delete="delete"/>",
#         "<nc:snmp xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"
#         "<nc:contact>[email protected]</nc:contact><nc:customization>"
#         "<nc:ether-stats-ifd-only/></nc:customization><nc:description>Local SNMP Server</nc:description>"
#         "<nc:engine-id><nc:local>local1</nc:local><nc:use-default-ip-address/><nc:use-mac-address/>"
#         "</nc:engine-id><nc:filter-duplicates/><nc:filter-interfaces><nc:all-internal-interfaces/><nc:interfaces>"
#         "<nc:name>eth1</nc:name></nc:interfaces><nc:interfaces><nc:name>eth2</nc:name></nc:interfaces>"
#         "</nc:filter-interfaces></nc:snmp>"
#     ]
# After state
# -----------
#
# vagrant@vsrx# show routing-instances
# clv1 {
#     description clv1;
# }
# clv2 {
#     description clv2;
# }
# vagrant@vsrx# show snmp
# description "Local SNMP Server";
# contact "[email protected]";
# filter-interfaces {
#     interfaces {
#         eth1;
#         eth2;
#     }
#     all-internal-interfaces;
# }
# filter-duplicates;
# engine-id {
#     use-mac-address;
# }
# customization {
#     ether-stats-ifd-only;
# }

# Using overridden
#
# Before state
# ------------
#
# vagrant@vsrx# show snmp
# client-list cl1 {
#     192.16.1.0/24;
#     192.16.2.0/24;
#     11.11.11.11/32 {
#         restrict;
#     }
# }
# client-list cl2 {
#     192.16.4.0/24;
# }
# routing-instance-access {
#     access-list {
#         clv1;
#         clv2;
#     }
# }
# arp {
#     host-name-resolution;
# }
# vagrant@vsrx# show routing-instances
# clv1 {
#     description clv1;
# }
# clv2 {
#     description clv2;
# }
- name: Override running SNMP server configuration with provided configuration
  junipernetworks.junos.junos_snmp_server:
    config:
      contact: "[email protected]"
      customization:
        ether_stats_ifd_only: true
      description: "Local SNMP Server"
      engine_id:
        local: "local1"
        use_default_ip_address: true
        use_mac_address: true
      filter_duplicates: true
      filter_interfaces:
        set: true
        all_internal_interfaces: true
        interfaces:
          - "eth1"
          - "eth2"
    state: overridden
#
# -------------------------
# Module Execution Result
# -------------------------
#     "after": {
#         "contact": "[email protected]",
#         "customization": {
#             "ether_stats_ifd_only": true
#         },
#         "description": "Local SNMP Server",
#         "engine_id": {
#             "use_mac_address": true
#         },
#         "filter_duplicates": true,
#         "filter_interfaces": {
#             "all_internal_interfaces": true,
#             "interfaces": [
#                 "eth1",
#                 "eth2"
#             ]
#         }
#     },
#     "before":
#      {
#         "arp": {
#             "host_name_resolution": true
#         },
#         "client_lists": [
#             {
#                 "addresses": [
#                     {
#                         "address": "192.16.1.0/24"
#                     },
#                     {
#                         "address": "192.16.2.0/24"
#                     },
#                     {
#                         "address": "11.11.11.11/32",
#                         "restrict": true
#                     }
#                 ],
#                 "name": "cl1"
#             },
#             {
#                 "addresses": [
#                     {
#                         "address": "192.16.4.0/24"
#                     }
#                 ],
#                 "name": "cl2"
#             }
#         ],
#         "routing_instance_access": {
#             "access_lists": [
#                 "clv1",
#                 "clv2"
#             ]
#         }
#     },
#     "changed": true,
#     "commands": [
#         "<nc:snmp xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>",
#         "<nc:snmp xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" delete="delete"/>",
#         "<nc:snmp xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"
#         "<nc:contact>[email protected]</nc:contact><nc:customization>"
#         "<nc:ether-stats-ifd-only/></nc:customization><nc:description>Local SNMP Server</nc:description>"
#         "<nc:engine-id><nc:local>local1</nc:local><nc:use-default-ip-address/><nc:use-mac-address/>"
#         "</nc:engine-id><nc:filter-duplicates/><nc:filter-interfaces><nc:all-internal-interfaces/><nc:interfaces>"
#         "<nc:name>eth1</nc:name></nc:interfaces><nc:interfaces><nc:name>eth2</nc:name></nc:interfaces>"
#         "</nc:filter-interfaces></nc:snmp>"
#     ]
# After state
# -----------
#
# vagrant@vsrx# show routing-instances
# clv1 {
#     description clv1;
# }
# clv2 {
#     description clv2;
# }
# vagrant@vsrx# show snmp
# description "Local SNMP Server";
# contact "[email protected]";
# filter-interfaces {
#     interfaces {
#         eth1;
#         eth2;
#     }
#     all-internal-interfaces;
# }
# filter-duplicates;
# engine-id {
#     use-mac-address;
# }
# customization {
#     ether-stats-ifd-only;
# }
#
# Using deleted
#
# Before state
# ------------
#
# vagrant@vsrx# show routing-instances
# clv1 {
#     description clv1;
# }
# clv2 {
#     description clv2;
# }
# vagrant@vsrx# show snmp
# description "Local SNMP Server";
# contact "[email protected]";
# filter-interfaces {
#     interfaces {
#         eth1;
#         eth2;
#     }
#     all-internal-interfaces;
# }
# filter-duplicates;
# engine-id {
#     use-mac-address;
# }
# customization {
#     ether-stats-ifd-only;
# }
#
- name: Delete running SNMP server configuration
  junipernetworks.junos.junos_snmp_server:
    config:
    state: deleted
#
# -------------------------
# Module Execution Result
# -------------------------
#     "after": {},
#     "before": {
#         "contact": "[email protected]",
#         "customization": {
#             "ether_stats_ifd_only": true
#         },
#         "description": "Local SNMP Server",
#         "engine_id": {
#             "use_mac_address": true
#         },
#         "filter_duplicates": true,
#         "filter_interfaces": {
#             "all_internal_interfaces": true,
#             "interfaces": [
#                 "eth1",
#                 "eth2"
#             ]
#         }
#     },
#     "changed": true,
#     "commands": [
#               "<nc:snmp xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>",
#               "<nc:snmp xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" delete="delete"/>"
#     ]
# After state
# -----------
#
# vagrant@vsrx# show routing-instances
# clv1 {
#     description clv1;
# }
# clv2 {
#     description clv2;
# }
# vagrant@vsrx# show snmp
# description "Local SNMP Server";
# contact "[email protected]";
# filter-interfaces {
#     interfaces {
#         eth1;
#         eth2;
#     }
#     all-internal-interfaces;
# }
# filter-duplicates;
# engine-id {
#     use-mac-address;
# }
# customization {
#     ether-stats-ifd-only;
# }
#
- name: Gather running SNMP server configuration
  junipernetworks.junos.junos_snmp_server:
    state: gathered
#
# -------------------------
# Module Execution Result
# -------------------------
#     "gathered": {
#         "contact": "[email protected]",
#         "customization": {
#             "ether_stats_ifd_only": true
#         },
#         "description": "Local SNMP Server",
#         "engine_id": {
#             "use_mac_address": true
#         },
#         "filter_duplicates": true,
#         "filter_interfaces": {
#             "all_internal_interfaces": true,
#             "interfaces": [
#                 "eth1",
#                 "eth2"
#             ]
#         }
#     },
#     "changed": false,
# Using rendered
#
# Before state
# ------------
#
- name: Render xml for provided facts.
  junipernetworks.junos.junos_snmp_server:
    config:
      arp:
        set: true
        host_name_resolution: true
      routing_instance_access:  # ATTR-----3
        set: true
        access_lists:
          - "clv1"
          - "clv2"
    state: rendered
#
# -------------------------
# Module Execution Result
# -------------------------
#     "rendered": [
#           "<nc:snmp xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"
#           "<nc:arp><nc:host-name-resolution/></nc:arp><nc:routing-instance-access>"
#           "<nc:access-list><nc:name>clv1</nc:name></nc:access-list><nc:access-list><nc:name>clv2</nc:name>"
#           "</nc:access-list></nc:routing-instance-access></nc:snmp>"
#     ]
#
# 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">
#         <version>18.4R1-S2.4</version>
#         <system xmlns="http://yang.juniper.net/junos-es/conf/system">
#            <snmp>
#         <client-list>
#             <name>cl1</name>
#             <client-address-list>
#                 <name>192.16.1.0/24</name>
#             </client-address-list>
#             <client-address-list>
#                 <name>192.16.2.0/24</name>
#             </client-address-list>
#             <client-address-list>
#                 <name>11.11.11.11/32</name>
#                 <restrict/>
#             </client-address-list>
#         </client-list>
#         <client-list>
#             <name>cl2</name>
#             <client-address-list>
#                 <name>192.16.4.0/24</name>
#             </client-address-list>
#         </client-list>
#         <routing-instance-access>
#             <access-list>
#                 <name>clv1</name>
#             </access-list>
#             <access-list>
#                 <name>clv2</name>
#             </access-list>
#         </routing-instance-access>
#         <arp>
#             <host-name-resolution/>
#         </arp>
#     </snmp>
#     </system>
#     </configuration>
# </rpc-reply>
#
- name: Parse SNMP server running config
  junipernetworks.junos.junos_snmp_server:
    running_config: "{{ lookup('file', './parsed.cfg') }}"
    state: parsed
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "parsed":  {
#         "arp": {
#             "host_name_resolution": true
#         },
#         "client_lists": [
#             {
#                 "addresses": [
#                     {
#                         "address": "192.16.1.0/24"
#                     },
#                     {
#                         "address": "192.16.2.0/24"
#                     },
#                     {
#                         "address": "11.11.11.11/32",
#                         "restrict": true
#                     }
#                 ],
#                 "name": "cl1"
#             },
#             {
#                 "addresses": [
#                     {
#                         "address": "192.16.4.0/24"
#                     }
#                 ],
#                 "name": "cl2"
#             }
#         ],
#         "routing_instance_access": {
#             "access_lists": [
#                 "clv1",
#                 "clv2"
#             ]
#         }
#     }
#
#

返回值

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

描述

after

字典

生成的配置模型调用。

已返回:发生更改时

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

before

字典

模型调用之前的配置。

已返回:始终

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

commands

列表 / 元素=字符串

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

已返回:始终

示例: ["<nc:arp><nc:host-name-resolution/></nc:arp><nc:routing-instance-access>\"", "<nc:snmp xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"]

作者

  • Rohit Thakur (@rohitthakur2590)