arista.eos.eos_snmp_server 模块 – 管理 snmp_server 资源模块

注意

此模块是 arista.eos 集合 (版本 10.0.1) 的一部分。

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

要安装它,请使用: ansible-galaxy collection install arista.eos

要在剧本中使用它,请指定: arista.eos.eos_snmp_server

arista.eos 3.2.0 中的新增功能

概要

  • 此模块配置和管理 Arista EOS 平台上 snmp_server 的属性。

参数

参数

注释

config

字典

SNMP 服务器配置。

acls

列表 / 元素=字典

IPv4/IPv6 访问列表

acl

字符串

acl 名称

afi

字符串

ipv4/ipv6

选项

  • "ipv4"

  • "ipv6"

vrf

字符串

vrf 名称

chassis_id

字符串

SNMP 底盘标识符。

communities

列表 / 元素=字典

社区名称配置。

acl_v4

字符串

标准访问列表名称

acl_v6

字符串

IPv6 访问列表名称。

name

字符串

社区名称

ro

布尔值

仅允许读取。

选项

  • false

  • true

rw

布尔值

读写访问

选项

  • false

  • true

view

字符串

MIB 视图名称

contact

字符串

联系系统的人员。

engineid

字典

SNMPv3 引擎 ID 配置。

local

字符串

本地 SNMP 代理

remote

字典

远程 SNMP 代理

host

字符串

远程 SNMP 通知主机的 hostname 或 IP 地址

id

字符串

引擎 ID 八位字节字符串

udp_port

整数

远程 SNMP 通知主机的 UDP 端口号。

extension

字典

配置扩展脚本以服务 OID 范围

oneshot

布尔值

使用低效的 one_shot 接口

选项

  • false

  • true

root_oid

字符串

扩展根 OID

script_location

字符串

脚本位置

groups

列表 / 元素=字典

SNMP USM 组

auth_privacy

字符串

身份验证和隐私配置。当 version = v3 时有效。

选项

  • "auth"

  • "noauth"

  • "priv"

context

字符串

指定与组关联的上下文

group

字符串

用户的 SNMP 组

notify

字符串

限制通知的视图

read

字符串

限制读取访问的视图

version

字符串

snmp 安全组版本

选项

  • "v1"

  • "v3"

  • "v2c"

write

字符串

限制写入访问的视图

hosts

列表 / 元素=字典

通知目标

host

字符串

SNMP 通知主机的 hostname 或 IP 地址。

informs

布尔值

使用 SNMP inform 消息。

选项

  • false

  • true

traps

布尔值

使用 SNMP trap 消息

选项

  • false

  • true

udp_port

整数

通知消息的 UDP 目的端口。

user

字符串

社区或用户名。

version

字符串

通知消息 SNMP 版本。

选项

  • "1"

  • "2c"

  • "3 auth"

  • "3 noauth"

  • "3 priv"

vrf

字符串

指定配置主机的 VRF

local_interface

字符串

配置 SNMP 通知的消息源接口。

location

字符串

sysLocation 字符串。

notification

整数

日志中通知的最大数量

objects

字典

为 true 时禁用一组对象的实现

mac_address_tables

布尔值

dot1dTpFdbTable, dot1qTpFdbTable

选项

  • false

  • true

route_tables

布尔值

ipCidrRouteTable, ipCidrRouteNumber, aristaFIBStats*

选项

  • false

  • true

qos

整数

配置 QoS 参数。

qosmib

整数

设置 QOS_MIB 计数器更新间隔

transmit

整数

SNMP 消息中的最大字节数(UDP/TCP 负载)

transport

字符串

启用 snmpd 传输层协议

traps

字典

启用对所有已配置接收者的陷阱。

bgp

字典

启用 Bgp 陷阱。如果设置为启用,则所有陷阱都将设置。

arista_backward_transition

布尔值

arista_backward_transition

选项

  • false

  • true

arista_established

布尔值

arista_established

选项

  • false

  • true

backward_transition

布尔值

backward_transition

选项

  • false

  • true

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

established

布尔值

已建立。

选项

  • false

  • true

bridge

字典

启用 Bridge 陷阱。如果设置为启用,则所有陷阱都将设置。

arista_mac_age

布尔值

arista_mac_age

选项

  • false

  • true

arista_mac_learn

布尔值

arista_mac_learn

选项

  • false

  • true

arista_mac_move

布尔值

arista_mac_move

选项

  • false

  • true

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

capacity

字典

启用 Capacity 陷阱。如果设置为启用,则所有陷阱都将设置。

arista_hardware_utilization_alert

布尔值

arista_hardware_utilization_alert

选项

  • false

  • true

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

entity

字典

启用 Entity 陷阱。如果设置为启用,则所有陷阱都将设置。

arista_ent_sensor_alarm

布尔值

arista_ent_sensor_alarm

选项

  • false

  • true

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

ent_config_change

布尔值

ent_config_change

选项

  • false

  • true

ent_state_oper

布尔值

ent_state_oper

选项

  • false

  • true

ent_state_oper_disabled

布尔值

ent_state_oper_disabled。

选项

  • false

  • true

ent_state_oper_enabled

布尔值

ent_state_oper_enabled。

选项

  • false

  • true

external_alarm

字典

启用外部警报陷阱。如果设置为启用,则所有陷阱都将设置。

arista_external_alarm_asserted_notif

布尔值

arista_external_alarm_asserted_notif

选项

  • false

  • true

arista_external_alarm_deasserted_notif

布尔值

arista_external_alarm_deasserted_notif

选项

  • false

  • true

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

isis

字典

启用 isis 陷阱。如果设置为启用,则所有陷阱都将设置。

adjacency_change

布尔值

adjacency_change

选项

  • false

  • true

area_mismatch

布尔值

area_mismatch

选项

  • false

  • true

attempt_to_exceed_max_sequence

布尔值

attempt_to_exceed_max_sequence

选项

  • false

  • true

authentication_type_failure

布尔值

authentication_type_failure。

选项

  • false

  • true

database_overload

布尔值

database_overload

选项

  • false

  • true

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

own_lsp_purge

布尔值

own_lsp_purge

选项

  • false

  • true

rejected_adjacency

布尔值

rejected_adjacency

选项

  • false

  • true

sequence_number_skip

布尔值

sequence_number_skip。

选项

  • false

  • true

lldp

字典

启用 Lldp 陷阱。如果设置为启用,则所有陷阱都将设置。

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

rem_tables_change

布尔值

rem_tables_change

选项

  • false

  • true

mpls_ldp

字典

启用 mpls_ldp 陷阱。如果设置为启用,则所有陷阱都将设置。

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

mpls_ldp_session_down

布尔值

mpls_ldp_session_down

选项

  • false

  • true

mpls_ldp_session_up

布尔值

mpls_ldp_session_up

选项

  • false

  • true

msdp

字典

启用 msdp 陷阱。如果设置为启用,则所有陷阱都将设置。

backward_transition

布尔值

backward_transition。

选项

  • false

  • true

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

established

布尔值

已建立。

选项

  • false

  • true

ospf

字典

启用 OSPF 陷阱。如果设置为启用,则设置所有陷阱。

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

if_auth_failure

布尔值

if_auth_failure

选项

  • false

  • true

if_config_error

布尔值

if_config_error

选项

  • false

  • true

if_state_change

布尔值

if_state_change

选项

  • false

  • true

nbr_state_change

布尔值

nbr_state_change。

选项

  • false

  • true

ospfv3

字典

启用 OSPFv3 陷阱。如果设置为启用,则设置所有陷阱。

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

if_config_error

布尔值

if_config_error

选项

  • false

  • true

if_rx_bad_packet

布尔值

if_rx_bad_packet

选项

  • false

  • true

if_state_change

布尔值

if_state_change

选项

  • false

  • true

nbr_restart_helper_status_change

布尔值

启用 ospfv3NbrRestartHelperStatusChange 陷阱

选项

  • false

  • true

nbr_state_change

布尔值

nbr_state_change。

选项

  • false

  • true

nssa_translator_status_change

布尔值

启用 ospfv3NssaTranslatorStatusChange 陷阱

选项

  • false

  • true

restart_status_change

布尔值

restart_status_change

选项

  • false

  • true

pim

字典

启用 PIM 陷阱。如果设置为启用,则设置所有陷阱。

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

neighbor_loss

布尔值

neighbor_loss

选项

  • false

  • true

snmp

字典

启用 SNMP 陷阱。如果设置为启用,则设置所有陷阱。

authentication

布尔值

authentication

选项

  • false

  • true

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

布尔值

link_down

选项

  • false

  • true

布尔值

link_up

选项

  • false

  • true

snmpConfigManEvent

字典

启用 snmpConfigManEvent 陷阱。如果设置为启用,则设置所有陷阱。

arista_config_man_event

布尔值

arista_config_man_event

选项

  • false

  • true

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

switchover

字典

启用切换陷阱。如果设置为启用,则设置所有陷阱。

arista_redundancy_switch_over_notif

布尔值

arista_redundancy_switch_over_notif

选项

  • false

  • true

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

test

字典

启用测试陷阱。如果设置为启用,则设置所有陷阱。

arista_test_notification

布尔值

arista_test_notification

选项

  • false

  • true

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

vrrp

字典

启用 VRRP 陷阱。如果设置为启用,则设置所有陷阱。

enabled

布尔值

所有陷阱都已设置。

选项

  • false

  • true

trap_new_master

布尔值

vrrp

选项

  • false

  • true

users

列表 / 元素=字典

SNMP 用户配置。

auth

字典

用户身份验证设置

algorithm

字符串

身份验证算法

auth_passphrase

字符串

身份验证密码十六进制字符串

encryption

字符串

加密算法。

priv_passphrase

字符串

隐私密码十六进制字符串

group

字符串

用户的 SNMP 组。

localized

字典

本地化身份验证和隐私密码。

algorithm

字符串

身份验证算法

auth_passphrase

字符串

身份验证密码十六进制字符串

encryption

字符串

加密算法。

engineid

字符串

引擎ID

priv_passphrase

字符串

隐私密码十六进制字符串

remote

字符串

托管 SNMPv3 用户的系统

udp_port

整数

远程 SNMP 系统使用的 UDP 端口

user

字符串

SNMP 用户名

version

字符串

SNMP 安全版本

选项

  • "v1"

  • "v2c"

  • "v3"

views

列表 / 元素=字典

SNMPv2 MIB 视图配置

action

字符串

要执行的操作。

选项

  • "excluded"

  • "included"

mib

字符串

SNMP MIB 名称

view

字符串

SNMP 视图名称

vrfs

列表 / 元素=字典

指定使用源地址的 VRF

local_interface

字符串

配置 SNMP 通知源接口

vrf

字符串

VRF 名称。

running_config

字符串

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

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

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

state

字符串

配置应保留的状态。

对于此模块,状态 *replaced* 和 *overridden* 的行为相同。

请参阅示例了解更多详情。

选项

  • "deleted"

  • "merged" ← (默认)

  • "overridden"

  • "replaced"

  • "gathered"

  • "rendered"

  • "parsed"

注释

注意

  • 针对 Arista EOS 4.24.6F 测试

  • 此模块可与连接 network_clihttpapi 一起使用。

示例

# Using merged:

# Before State
# eos#show running-config | section snmp-server
# eos#

- name: merge given snmp_server configuration
  arista.eos.eos_snmp_server:
    config:
      communities:
        - name: "comm3"
          acl_v6: "list1"
          view: "view1"
        - name: "comm4"
          acl_v4: "list3"
          view: "view1"
        - name: "comm5"
          acl_v4: "list4"
          ro: true
      contact: "admin"
      engineid:
        remote:
          host: 1.1.1.1
          id: "1234567"
      groups:
        - group: "group1"
          version: "v1"
          read: "view1"
        - group: "group2"
          version: "v3"
          auth_privacy: "priv"
          notify: "view1"
          write: "view2"
      hosts:
        - host: "host02"
          user: "user01"
          udp_port: 23
          version: "2c"
        - host: "host01"
          user: "user01"
          udp_port: 23
          version: "3 priv"
      traps:
        capacity:
          arista_hardware_utilization_alert: true
        bgp:
          enabled: true
        external_alarm:
          arista_external_alarm_deasserted_notif: true
          arista_external_alarm_asserted_notif: true
      vrfs:
        - vrf: "vrf01"
          local_interface: "Ethernet1"

# After state
# eos#show running-config | section snmp-server
# snmp-server community comm3 view view1 ipv6 list1
# snmp-server community comm4 view view1 list3
# snmp-server community comm5 ro list4
# snmp-server group group1 v1 read view1
# snmp-server group group2 v3 priv write view2 notify view1
# snmp-server host host02 version 2c user01 udp-port 23
# snmp-server host host01 version 3 priv user01 udp-port 23
# snmp-server vrf vrf01 local-interface Ethernet1
# snmp-server contact admin
# snmp-server enable traps bgp
# snmp-server enable traps capacity arista-hardware-utilization-alert
# snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif
#
# Module Execution
#
# "after": {
#         "communities": [
#             {
#                 "acl_v6": "list1",
#                 "name": "comm3",
#                 "ro": true,
#                 "view": "view1"
#             },
#             {
#                 "acl_v4": "list3",
#                 "name": "comm4",
#                 "ro": true,
#                 "view": "view1"
#             },
#             {
#                 "acl_v4": "list4",
#                 "name": "comm5",
#                 "ro": true
#             }
#         ],
#         "contact": "admin",
#         "groups": [
#             {
#                 "group": "group1",
#                 "read": "view1",
#                 "version": "v1"
#             },
#             {
#                 "auth_privacy": "priv",
#                 "group": "group2",
#                 "notify": "view1",
#                 "version": "v3",
#                 "write": "view2"
#             }
#         ],
#         "hosts": [
#             {
#                 "host": "host01",
#                 "udp_port": 23,
#                 "user": "user01",
#                 "version": "3 priv"
#             },
#             {
#                 "host": "host02",
#                 "udp_port": 23,
#                 "user": "user01",
#                 "version": "2c"
#             }
#         ],
#         "traps": {
#             "bgp": {
#                 "enabled": true
#             },
#             "capacity": {
#                 "arista_hardware_utilization_alert": true
#             },
#             "external_alarm": {
#                 "arista_external_alarm_asserted_notif": true,
#                 "arista_external_alarm_deasserted_notif": true
#             }
#         },
#         "vrfs": [
#             {
#                 "local_interface": "Ethernet1",
#                 "vrf": "vrf01"
#             }
#         ]
#     },
#     "before": {},
#     "changed": true,
#     "commands": [
#         "snmp-server community comm3 view view1 ipv6 list1",
#         "snmp-server community comm4 view view1 list3",
#         "snmp-server community comm5 ro list4",
#         "snmp-server group group1 v1 read view1",
#         "snmp-server group group2 v3 priv write view2 notify view1",
#         "snmp-server host host02 version 2c user01 udp-port 23",
#         "snmp-server host host01 version 3 priv user01 udp-port 23",
#         "snmp-server vrf vrf01 local-interface Ethernet1",
#         "snmp-server contact admin",
#         "snmp-server engineID remote 1.1.1.1 1234567",
#         "snmp-server enable traps bgp",
#         "snmp-server enable traps capacity arista-hardware-utilization-alert",
#         "snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif"
#     ],
#

# Using replaced:

# Before State:
# eos#show running-config | section snmp-server
# snmp-server community comm3 view view1 ipv6 list1
# snmp-server community comm4 view view1 list3
# snmp-server community comm5 ro list4
# snmp-server group group1 v1 read view1
# snmp-server group group2 v3 priv write view2 notify view1
# snmp-server host host02 version 2c user01 udp-port 23
# snmp-server host host01 version 3 priv user01 udp-port 23
# snmp-server vrf vrf01 local-interface Ethernet1
# snmp-server contact admin
# snmp-server enable traps bgp
# snmp-server enable traps capacity arista-hardware-utilization-alert
# snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif

- name: Replace given snmp_server configuration
  become: true
  register: result
  arista.eos.eos_snmp_server: &replaced
    state: replaced
    config:
      communities:
        - name: "comm3"
          acl_v6: "list1"
          view: "view1"
        - name: "replacecomm"
          acl_v4: "list4"
      extension:
        root_oid: "123456"
        script_location: "flash:"
      traps:
        test:
          arista_test_notification: true
        bgp:
          enabled: true
      vrfs:
        - vrf: "vrf_replace"
          local_interface: "Ethernet1"

# After State:

# eos#show running-config | section snmp-server
# snmp-server community comm3 view view1 ipv6 list1
# snmp-server community replacecomm list4
# snmp-server vrf vrf_replace local-interface Ethernet1
# snmp-server extension 123456 flash:
# snmp-server enable traps test arista-test-notification
# snmp-server enable traps bgp

# Module Execution:
#    "after": {
#        "communities": [
#            {
#                "acl_v6": "list1",
#                "name": "comm3",
#                "ro": true,
#                "view": "view1"
#            },
#            {
#                "acl_v4": "list4",
#                "name": "replacecomm",
#                "ro": true
#            }
#        ],
#        "extension": {
#            "root_oid": "0.123456",
#            "script_location": "flash:"
#        },
#        "traps": {
#            "bgp": {
#                "enabled": true
#            },
#            "test": {
#                "arista_test_notification": true
#            }
#        },
#        "vrfs": [
#            {
#                "local_interface": "Ethernet1",
#                "vrf": "vrf_replace"
#            }
#        ]
#    },
#    "before": {
#        "communities": [
#            {
#                "acl_v6": "list1",
#                "name": "comm3",
#                "ro": true,
#                "view": "view1"
#            },
#            {
#                "acl_v4": "list3",
#                "name": "comm4",
#                "ro": true,
#                "view": "view1"
#            },
#            {
#                "acl_v4": "list4",
#                "name": "comm5",
#                "ro": true
#            }
#        ],
#        "contact": "admin",
#        "groups": [
#            {
#                "group": "group1",
#                "read": "view1",
#                "version": "v1"
#            },
#            {
#                "auth_privacy": "priv",
#                "group": "group2",
#                "notify": "view1",
#                "version": "v3",
#                "write": "view2"
#            }
#        ],
#        "hosts": [
#            {
#                "host": "host01",
#                "udp_port": 23,
#                "user": "user01",
#                "version": "3 priv"
#            },
#            {
#                "host": "host02",
#                "udp_port": 23,
#                "user": "user01",
#                "version": "2c"
#            }
#        ],
#        "traps": {
#            "bgp": {
#                "enabled": true
#            },
#            "capacity": {
#                "arista_hardware_utilization_alert": true
#            },
#            "external_alarm": {
#                "arista_external_alarm_asserted_notif": true,
#                "arista_external_alarm_deasserted_notif": true
#            }
#        },
#        "vrfs": [
#            {
#                "local_interface": "Ethernet1",
#                "vrf": "vrf01"
#            }
#        ]
#    },
#    "changed": true,
#    "commands": [
#        "snmp-server community comm3 view view1 ipv6 list1",
#        "snmp-server community replacecomm list4",
#        "no snmp-server community comm4 view view1 ro list3",
#        "no snmp-server community comm5 ro list4",
#        "no snmp-server group group1 v1 read view1",
#        "no snmp-server group group2 v3 priv write view2 notify view1",
#        "no snmp-server host host01 version 3 priv user01 udp-port 23",
#        "no snmp-server host host02 version 2c user01 udp-port 23",
#        "snmp-server vrf vrf_replace local-interface Ethernet1",
#        "no snmp-server vrf vrf01 local-interface Ethernet1",
#        "snmp-server extension 123456 flash:",
#        "default snmp-server enable traps capacity arista-hardware-utilization-alert",
#        "default snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif",
#        "snmp-server enable traps test arista-test-notification",
#        "no snmp-server contact admin"
#    ],

# Using overridden:
# Before State:
# eos#show running-config | section snmp-server
# snmp-server community comm3 view view1 ipv6 list1
# snmp-server community comm4 view view1 list3
# snmp-server community comm5 ro list4
# snmp-server group group1 v1 read view1
# snmp-server group group2 v3 priv write view2 notify view1
# snmp-server host host02 version 2c user01 udp-port 23
# snmp-server host host01 version 3 priv user01 udp-port 23
# snmp-server vrf vrf01 local-interface Ethernet1
# snmp-server contact admin
# snmp-server enable traps bgp
# snmp-server enable traps capacity arista-hardware-utilization-alert
# snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif

- name: Override given snmp_server configuration
  arista.eos.eos_snmp_server:
    state: overridden
    config:
      communities:
        - name: "comm3"
          acl_v6: "list1"
          view: "view1"
        - name: "replacecomm"
          acl_v4: "list4"
      extension:
        root_oid: "123456"
        script_location: "flash:"
      traps:
        test:
          arista_test_notification: true
        bgp:
          enabled: true
      vrfs:
        - vrf: "vrf_replace"
          local_interface: "Ethernet1"

# After State:

# eos#show running-config | section snmp-server
# snmp-server community comm3 view view1 ipv6 list1
# snmp-server community replacecomm list4
# snmp-server vrf vrf_replace local-interface Ethernet1
# snmp-server extension 123456 flash:
# snmp-server enable traps test arista-test-notification
# snmp-server enable traps bgp

# Module Execution:
#    "after": {
#        "communities": [
#            {
#                "acl_v6": "list1",
#                "name": "comm3",
#                "ro": true,
#                "view": "view1"
#            },
#            {
#                "acl_v4": "list4",
#                "name": "replacecomm",
#                "ro": true
#            }
#        ],
#        "extension": {
#            "root_oid": "0.123456",
#            "script_location": "flash:"
#        },
#        "traps": {
#            "bgp": {
#                "enabled": true
#            },
#            "test": {
#                "arista_test_notification": true
#            }
#        },
#        "vrfs": [
#            {
#                "local_interface": "Ethernet1",
#                "vrf": "vrf_replace"
#            }
#        ]
#    },
#    "before": {
#        "communities": [
#            {
#                "acl_v6": "list1",
#                "name": "comm3",
#                "ro": true,
#                "view": "view1"
#            },
#            {
#                "acl_v4": "list3",
#                "name": "comm4",
#                "ro": true,
#                "view": "view1"
#            },
#            {
#                "acl_v4": "list4",
#                "name": "comm5",
#                "ro": true
#            }
#        ],
#        "contact": "admin",
#        "groups": [
#            {
#                "group": "group1",
#                "read": "view1",
#                "version": "v1"
#            },
#            {
#                "auth_privacy": "priv",
#                "group": "group2",
#                "notify": "view1",
#                "version": "v3",
#                "write": "view2"
#            }
#        ],
#        "hosts": [
#            {
#                "host": "host01",
#                "udp_port": 23,
#                "user": "user01",
#                "version": "3 priv"
#            },
#            {
#                "host": "host02",
#                "udp_port": 23,
#                "user": "user01",
#                "version": "2c"
#            }
#        ],
#        "traps": {
#            "bgp": {
#                "enabled": true
#            },
#            "capacity": {
#                "arista_hardware_utilization_alert": true
#            },
#            "external_alarm": {
#                "arista_external_alarm_asserted_notif": true,
#                "arista_external_alarm_deasserted_notif": true
#            }
#        },
#        "vrfs": [
#            {
#                "local_interface": "Ethernet1",
#                "vrf": "vrf01"
#            }
#        ]
#    },
#    "changed": true,
#    "commands": [
#        "snmp-server community comm3 view view1 ipv6 list1",
#        "snmp-server community replacecomm list4",
#        "no snmp-server community comm4 view view1 ro list3",
#        "no snmp-server community comm5 ro list4",
#        "no snmp-server group group1 v1 read view1",
#        "no snmp-server group group2 v3 priv write view2 notify view1",
#        "no snmp-server host host01 version 3 priv user01 udp-port 23",
#        "no snmp-server host host02 version 2c user01 udp-port 23",
#        "snmp-server vrf vrf_replace local-interface Ethernet1",
#        "no snmp-server vrf vrf01 local-interface Ethernet1",
#        "snmp-server extension 123456 flash:",
#        "default snmp-server enable traps capacity arista-hardware-utilization-alert",
#        "default snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif",
#        "snmp-server enable traps test arista-test-notification",
#        "no snmp-server contact admin"
#    ],

# Using deleted:
# Before State:
# eos#show running-config | section snmp-server
# snmp-server community comm3 view view1 ipv6 list1
# snmp-server community comm4 view view1 list3
# snmp-server community comm5 ro list4
# snmp-server group group1 v1 read view1
# snmp-server group group2 v3 priv write view2 notify view1
# snmp-server host host02 version 2c user01 udp-port 23
# snmp-server host host01 version 3 priv user01 udp-port 23
# snmp-server vrf vrf01 local-interface Ethernet1
# snmp-server contact admin
# snmp-server enable traps bgp
# snmp-server enable traps capacity arista-hardware-utilization-alert
# snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif

- name: Delete given snmp_server configuration
  arista.eos.eos_snmp_server:
    state: deleted

# After State:
# eos#show running-config | section snmp-server
#

# Module Execution:
#   "after": {},
#    "before": {
#        "communities": [
#            {
#                "acl_v6": "list1",
#                "name": "comm3",
#                "ro": true,
#                "view": "view1"
#            },
#            {
#                "acl_v4": "list3",
#                "name": "comm4",
#                "ro": true,
#                "view": "view1"
#            },
#            {
#                "acl_v4": "list4",
#                "name": "comm5",
#                "ro": true
#            }
#        ],
#        "contact": "admin",
#        "groups": [
#            {
#                "group": "group1",
#                "read": "view1",
#                "version": "v1"
#            },
#            {
#                "auth_privacy": "priv",
#                "group": "group2",
#                "notify": "view1",
#                "version": "v3",
#                "write": "view2"
#            }
#        ],
#        "hosts": [
#            {
#                "host": "host01",
#                "udp_port": 23,
#                "user": "user01",
#                "version": "3 priv"
#            },
#            {
#                "host": "host02",
#                "udp_port": 23,
#                "user": "user01",
#                "version": "2c"
#            }
#        ],
#        "traps": {
#            "bgp": {
#                "enabled": true
#            },
#            "capacity": {
#                "arista_hardware_utilization_alert": true
#            },
#            "external_alarm": {
#                "arista_external_alarm_asserted_notif": true,
#                "arista_external_alarm_deasserted_notif": true
#            }
#        },
#        "vrfs": [
#            {
#                "local_interface": "Ethernet1",
#                "vrf": "vrf01"
#            }
#        ]
#    },
#    "changed": true,
#    "commands": [
#        "no snmp-server community comm3 view view1 ro ipv6 list1",
#        "no snmp-server community comm4 view view1 ro list3",
#        "no snmp-server community comm5 ro list4",
#        "no snmp-server group group1 v1 read view1",
#        "no snmp-server group group2 v3 priv write view2 notify view1",
#        "no snmp-server host host01 version 3 priv user01 udp-port 23",
#        "no snmp-server host host02 version 2c user01 udp-port 23",
#        "no snmp-server vrf vrf01 local-interface Ethernet1",
#        "no snmp-server contact admin",
#        "default snmp-server enable traps bgp",
#        "default snmp-server enable traps capacity arista-hardware-utilization-alert",
#        "default snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif"
#    ],
#

# Using parsed:

# _parsed.cfg
# snmp-server contact admin
# snmp-server vrf vrf01 local-interface Ethernet1
# snmp-server community comm3 view view1 ro ipv6 list1
# snmp-server community comm4 view view1 ro list3
# snmp-server community comm5 ro list4
# snmp-server group group1 v1 read view1
# snmp-server group group2 v3 priv write view2 notify view1
# snmp-server host host01 version 3 priv user01 udp-port 23
# snmp-server host host02 version 2c user01 udp-port 23
# snmp-server enable traps bgp
# snmp-server enable traps capacity arista-hardware-utilization-alert
# snmp-server enable traps external-alarm arista-external-alarm-asserted-notif
# snmp-server enable traps external-alarm arista-external-alarm-deasserted-notif

- name: Provide the running configuration for parsing (config to be parsed)
  arista.eos.eos_snmp_server:
    running_config: "{{ lookup('file', '_parsed.cfg') }}"
    state: parsed

# Module Execution:
#     "parsed": {
#         "communities": [
#             {
#                 "acl_v6": "list1",
#                 "name": "comm3",
#                 "ro": true,
#                 "view": "view1"
#             },
#             {
#                 "acl_v4": "list3",
#                 "name": "comm4",
#                 "ro": true,
#                 "view": "view1"
#             },
#             {
#                 "acl_v4": "list4",
#                 "name": "comm5",
#                 "ro": true
#             }
#         ],
#         "contact": "admin",
#         "groups": [
#             {
#                 "group": "group1",
#                 "read": "view1",
#                 "version": "v1"
#             },
#             {
#                 "auth_privacy": "priv",
#                 "group": "group2",
#                 "notify": "view1",
#                 "version": "v3",
#                 "write": "view2"
#             }
#         ],
#         "hosts": [
#             {
#                 "host": "host01",
#                 "udp_port": 23,
#                 "user": "user01",
#                 "version": "3 priv"
#             },
#             {
#                 "host": "host02",
#                 "udp_port": 23,
#                 "user": "user01",
#                 "version": "2c"
#             }
#         ],
#         "traps": {
#             "bgp": {
#                 "enabled": true
#             },
#             "capacity": {
#                 "arista_hardware_utilization_alert": true
#             },
#             "external_alarm": {
#                 "arista_external_alarm_asserted_notif": true,
#                 "arista_external_alarm_deasserted_notif": true
#             }
#         },
#         "vrfs": [
#             {
#                 "local_interface": "Ethernet1",
#                 "vrf": "vrf01"
#             }
#         ]
#   }

# Using rendered:
- name: Render given snmp_server configuration
  arista.eos.eos_snmp_server:
    state: "rendered"
    config:
      communities:
        - name: "comm3"
          acl_v6: "list1"
          view: "view1"
        - name: "comm4"
          acl_v4: "list3"
          view: "view1"
        - name: "comm5"
          acl_v4: "list4"
          ro: true
      contact: "admin"
      engineid:
        remote:
          host: 1.1.1.1
          id: "1234567"
      groups:
        - group: "group1"
          version: "v1"
          read: "view1"
        - group: "group2"
          version: "v3"
          auth_privacy: "priv"
          notify: "view1"
          write: "view2"
      hosts:
        - host: "host02"
          user: "user01"
          udp_port: 23
          version: "2c"
        - host: "host01"
          user: "user01"
          udp_port: 23
          version: "3 priv"
      traps:
        capacity:
          arista_hardware_utilization_alert: true
        bgp:
          enabled: true
        external_alarm:
          arista_external_alarm_deasserted_notif: true
          arista_external_alarm_asserted_notif: true
      vrfs:
        - vrf: "vrf01"
          local_interface: "Ethernet1"

# Module Execution:
#    "rendered": [
#        "snmp-server community comm3 view view1 ipv6 list1",
#        "snmp-server community comm4 view view1 list3",
#        "snmp-server community comm5 ro list4",
#        "snmp-server group group1 v1 read view1",
#        "snmp-server group group2 v3 priv write view2 notify view1",
#        "snmp-server host host02 version 2c user01 udp-port 23",
#        "snmp-server host host01 version 3 priv user01 udp-port 23",
#        "snmp-server vrf vrf01 local-interface Ethernet1",
#        "snmp-server contact admin",
#        "snmp-server engineID remote 1.1.1.1 1234567",
#        "snmp-server enable traps bgp",
#        "snmp-server enable traps capacity arista-hardware-utilization-alert",
#        "snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif"
#    ]

# using gathered:

# eos#show running-config | section snmp-server
# snmp-server community comm3 view view1 ipv6 list1
# snmp-server community comm4 view view1 list3
# snmp-server community comm5 ro list4
# snmp-server group group1 v1 read view1
# snmp-server group group2 v3 priv write view2 notify view1
# snmp-server host host02 version 2c user01 udp-port 23
# snmp-server host host01 version 3 priv user01 udp-port 23
# snmp-server vrf vrf01 local-interface Ethernet1
# snmp-server contact admin
# snmp-server enable traps bgp
# snmp-server enable traps capacity arista-hardware-utilization-alert
# snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif

- name: Gathered the provided configuration with the exisiting running configuration
  arista.eos.eos_snmp_server:
    config:
    state: gathered

# Module Execution:
#     "gathered": {
#         "communities": [
#             {
#                 "acl_v6": "list1",
#                 "name": "comm3",
#                 "ro": true,
#                 "view": "view1"
#             },
#             {
#                 "acl_v4": "list3",
#                 "name": "comm4",
#                 "ro": true,
#                 "view": "view1"
#             },
#             {
#                 "acl_v4": "list4",
#                 "name": "comm5",
#                 "ro": true
#             }
#         ],
#         "contact": "admin",
#         "groups": [
#             {
#                 "group": "group1",
#                 "read": "view1",
#                 "version": "v1"
#             },
#             {
#                 "auth_privacy": "priv",
#                 "group": "group2",
#                 "notify": "view1",
#                 "version": "v3",
#                 "write": "view2"
#             }
#         ],
#         "hosts": [
#             {
#                 "host": "host01",
#                 "udp_port": 23,
#                 "user": "user01",
#                 "version": "3 priv"
#             },
#             {
#                 "host": "host02",
#                 "udp_port": 23,
#                 "user": "user01",
#                 "version": "2c"
#             }
#         ],
#         "traps": {
#             "bgp": {
#                 "enabled": true
#             },
#             "capacity": {
#                 "arista_hardware_utilization_alert": true
#             },
#             "external_alarm": {
#                 "arista_external_alarm_asserted_notif": true,
#                 "arista_external_alarm_deasserted_notif": true
#             }
#         },
#         "vrfs": [
#             {
#                 "local_interface": "Ethernet1",
#                 "vrf": "vrf01"
#             }
#         ]
#     },

返回值

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

描述

after

字典

模块执行后的最终配置。

返回:发生更改时

示例: "This output will always be in the same format as the module argspec.\n"

before

字典

模块执行之前的配置。

返回:当 *state* 为 mergedreplacedoverriddendeletedpurged

示例: "This output will always be in the same format as the module argspec.\n"

commands

列表 / 元素=字符串

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

返回:当 *state* 为 mergedreplacedoverriddendeletedpurged

示例: ["snmp-server community comm3 view view1 ipv6 list1", "snmp-server community comm4 view view1 list3", "snmp-server community comm5 ro list4", "snmp-server group group1 v1 read view1", "snmp-server group group2 v3 priv write view2 notify view1", "snmp-server host host02 version 2c user01 udp-port 23", "snmp-server host host01 version 3 priv user01 udp-port 23", "snmp-server vrf vrf01 local-interface Ethernet1", "snmp-server contact admin", "snmp-server engineID remote 1.1.1.1 1234567", "snmp-server enable traps bgp", "snmp-server enable traps capacity arista-hardware-utilization-alert", "snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif"]

gathered

列表 / 元素=字符串

从远程设备收集的网络资源事实,作为结构化数据。

返回:当 *state* 为 gathered

示例: ["This output will always be in the same format as the module argspec.\n"]

parsed

列表 / 元素=字符串

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

返回:当 *state* 为 parsed

示例: ["This output will always be in the same format as the module argspec.\n"]

rendered

列表 / 元素=字符串

以设备原生格式呈现的任务中提供的配置(脱机)。

返回:当 *state* 为 rendered

示例: ["snmp-server community comm3 view view1 ipv6 list1", "snmp-server community comm4 view view1 list3", "snmp-server community comm5 ro list4", "snmp-server group group1 v1 read view1", "snmp-server group group2 v3 priv write view2 notify view1", "snmp-server host host02 version 2c user01 udp-port 23", "snmp-server host host01 version 3 priv user01 udp-port 23", "snmp-server vrf vrf01 local-interface Ethernet1", "snmp-server contact admin", "snmp-server engineID remote 1.1.1.1 1234567", "snmp-server enable traps bgp", "snmp-server enable traps capacity arista-hardware-utilization-alert", "snmp-server enable traps external-alarm arista-external-alarm-asserted-notif arista-external-alarm-deasserted-notif"]

作者

  • Gomathi Selvi Srinivasan (@GomathiselviS)