cisco.iosxr.iosxr_snmp_server module – Manages snmp-server resource module

Note

This module is part of the cisco.iosxr collection (version 2.9.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install cisco.iosxr.

To use it in a playbook, specify: cisco.iosxr.iosxr_snmp_server.

New in version 2.6.0: of cisco.iosxr

Synopsis

  • This module configures and manages the attributes of snmp-server on Cisco IOSXR platforms.

Parameters

Parameter

Comments

config

dictionary

SNMP server configuration.

chassis_id

string

SNMP chassis identifier.

communities

list / elements=dictionary

Enable SNMP; set community string and access privileges.

acl_v4

string

Ipv4 access list.

acl_v6

string

IPv6 access list name.

name

string

Community name.

ro

boolean

Only reads are permitted.

Choices:

  • no

  • yes

rw

boolean

Read-write access.

Choices:

  • no

  • yes

sdrowner

boolean

SDR Owner permissions for MIB Objects.

Choices:

  • no

  • yes

systemowner

boolean

System Owner permissions for MIB objects.

Choices:

  • no

  • yes

v4_acl

string

V4 Access-list name.

community_maps

list / elements=dictionary

Community Mapping as per RFC-2576.

context

string

Context Name for the community mapping.

name

string

Community name

security_name

string

Security Name for the community mapping.

target_list

string

list of targets valid with this community.

contact

string

Person to contact about the syste,.

context

list / elements=string

Create/Delete a context apart from default

correlator

dictionary

Configure properties of the event correlator

buffer_size

integer

Configure size of the correlator buffer.

rule_sets

list / elements=dictionary

Configure a specified correlation ruleset.

name

string

Name of the ruleset

rules

list / elements=dictionary

Configure a specified correlation rule.

rule_name

string

name of rule.

timeout

integer

Specify timeout.

drop

dictionary

Silently drop SNMP packets

report_IPv4

string

Config to drop snmpv3 error reports matching Ipv4 ACL.

report_IPv6

string

Config to drop snmpv3 error reports matching Ipv4 ACL.

unknown_user

boolean

Silently drop unknown v3 user packets

Choices:

  • no

  • yes

engineid

dictionary

SNMPv3 engine ID configuration.

local

string

Local SNMP agent

groups

list / elements=dictionary

SNMP USM group

acl_v4

aliases: Ipv4_acl

string

Ipv4 Type of Access-list

acl_v6

aliases: Ipv6_acl

string

Ipv6 Type of Access-list

context

string

Specify a context to associate with the group

group

string

SNMP group for the user

notify

string

View to restrict notifications

read

string

View to restrict read access

v4_acl

string

V4 Access-list name

version

string

snmp security group version

Choices:

  • v1

  • v3

  • v2c

write

string

View to restrict write access

hosts

list / elements=dictionary

Notification destinations

community

string

community string.

host

string

Hostname or IP address of SNMP notification host.

informs

boolean

Use SNMP inform messages.

Choices:

  • no

  • yes

traps

boolean

Use SNMP trap messages

Choices:

  • no

  • yes

udp_port

integer

UDP destination port for notification messages.

version

string

Notification message SNMP version.

Choices:

  • 1

  • 2c

  • 3

ifindex

boolean

Enable ifindex persistence

Choices:

  • no

  • yes

ifmib

dictionary

IF-MIB configuration commands.

ifalias_long

boolean

Modify parameters for ifAlias object.

Choices:

  • no

  • yes

internal_cache_max_duration

integer

IFMIB internal lookahead cache.

ipsubscriber

boolean

Enable ipsubscriber interfaces in IFMIB.

Choices:

  • no

  • yes

stats

boolean

Modify IF-MIB statistics parameters.

Choices:

  • no

  • yes

inform

dictionary

Configure SNMP Informs options

pending

integer

Set number of unacked informs to hold

retries

integer

Set retry count for informs

timeout

integer

Set timeout for informs

interfaces

list / elements=dictionary

Enter the SNMP interface configuration commands.

index_persistent

boolean

Configure ifIndex attributes Persistency across system reloads.

Choices:

  • no

  • yes

name

string

Name of interface.

notification_linkupdown_disable

boolean

Disable linkUp and linkDown notification.

Choices:

  • no

  • yes

ipv4

dictionary

Mark the dscp/precedence bit for ipv4 packets.

dscp

string

Set IP DSCP (DiffServ CodePoint).Please refer vendor document for valid entries.

precedence

string

Set precedence Please refer vendor document for valid entries.

ipv6

dictionary

Mark the dscp/precedence bit for ipv4 packets.

dscp

string

Set IP DSCP (DiffServ CodePoint).Please refer vendor document for valid entries.

precedence

string

Set precedence Please refer vendor document for valid entries.

location

string

The sysLocation string.

logging_threshold_oid_processing

integer

Configure threshold to start logging slow OID requests processing.

logging_threshold_pdu_processing

integer

Configure threshold to start logging slow PDU requests processing.

mib_bulkstat_max_procmem_size

integer

per process memory limit in kilo bytes

mib_bulkstat_transfer_ids

list / elements=dictionary

mib bulkstat transfer ids.

buffer_size

integer

Bulkstat data file maximum size.

enable

boolean

Start Data Collection for this Configuration

Choices:

  • no

  • yes

format_schemaASCI

boolean

format

Choices:

  • no

  • yes

name

string

mib transfer-id name.

retain

integer

Retention period in Min.

retry

integer

Number of Retries.

schema

string

Schema that contains objects to be collected.

transfer_interval

integer

transfer-interval

mib_object_lists

list / elements=string

mib object lists

mib_schema

list / elements=dictionary

mib schema

name

string

mib schema name.

object_list

string

Name of an object List.

poll_interval

integer

Periodicity for polling of objects in this schema in Min.

mroutemib_send_all_vrf

boolean

Configurations related to IPMROUTE-MIB(cisco-support).

Choices:

  • no

  • yes

notification_log_mib

dictionary

notification log mib.

default

boolean

To create a default log

Choices:

  • no

  • yes

disable

boolean

disable, to disable the logging in default log.

Choices:

  • no

  • yes

GlobalSize

integer

GlobalSize, max number of notifications that can be logged in all logs.

size

integer

size, The max number of notifications that this log (default) can hold.

oid_poll_stats

boolean

Enable OID poll stats oper CLI

Choices:

  • no

  • yes

overload_control

dictionary

Set overload-control params for handling incoming messages in critical processing mode.

overload_drop_time

integer

Overload drop time (in seconds) for incoming queue (default 1 sec).

overload_throttle_rate

integer

Overload throttle rate for incoming queue (default 500 msec)

packetsize

integer

Largest SNMP packet size.

queue_length

integer

Queue length (default 100).

targets

list / elements=dictionary

targets

host

string

Specify host name.

name

string

Name of the target list.

vrf

string

Specify VRF name.

throttle_time

integer

Set throttle time for handling incoming messages.

timeouts

dictionary

SNMP timeouts

duplicate

integer

Duplicate request feature timeout

inQdrop

integer

incoming queue drop feature.

pdu_stats

integer

SNMP pdu statistics end to end.

subagent

integer

Sub-Agent Request timeout.

threshold

integer

threshold incoming queue drop feature.

trap

dictionary

MIB trap configurations.

authentication_vrf_disable

boolean

Disable authentication traps for packets on a vrf.

Choices:

  • no

  • yes

boolean

Link up/down trap configuratio.

Choices:

  • no

  • yes

throttle_time

integer

Set throttle time for handling more traps.

trap_source

string

Assign an interface for the source address of all traps

trap_timeout

integer

Set timeout for TRAP message retransmissions

traps

dictionary

Enable traps to all configured recipients.

addrpool

dictionary

Enable SNMP Address Pool traps.

high

boolean

Enable SNMP Address Pool High Threshold trap.

Choices:

  • no

  • yes

low

boolean

Enable SNMP Address Pool Low Threshold trap.

Choices:

  • no

  • yes

bfd

boolean

Enable BFD traps.

Choices:

  • no

  • yes

bgp

dictionary

Enable Bgp traps.

cbgp2

boolean

Enable CISCO-BGP4-MIB v2 traps.

Choices:

  • no

  • yes

updown

boolean

Enable CISCO-BGP4-MIB v2 up/down traps.

Choices:

  • no

  • yes

bridgemib

boolean

Enable SNMP Trap for Bridge MIB.

Choices:

  • no

  • yes

bulkstat_collection

boolean

Enable Data-Collection-MIB Collection notifications.

Choices:

  • no

  • yes

bulkstat_transfer

boolean

Enable Data-Collection-MIB Trnasfer notifications.

Choices:

  • no

  • yes

cisco_entity_ext

boolean

Enable SNMP entity traps

Choices:

  • no

  • yes

config

boolean

Enable SNMP config traps.

Choices:

  • no

  • yes

copy_complete

boolean

Enable CISCO-CONFIG-COPY-MIB ccCopyCompletion traps.

Choices:

  • no

  • yes

diameter

dictionary

Enable SNMP diameter traps.

peerdown

boolean

Enable peer connection down notification.

Choices:

  • no

  • yes

peerup

boolean

Enable peer connection up notification.

Choices:

  • no

  • yes

permanentfail

boolean

Enable permanent failure notification.

Choices:

  • no

  • yes

protocolerror

boolean

Enable protocol error notifications

Choices:

  • no

  • yes

transientfail

boolean

Enable transient failure notification.

Choices:

  • no

  • yes

entity

boolean

Enable SNMP entity traps.

Choices:

  • no

  • yes

entity_redundancy

dictionary

Enable SNMP CISCO-ENTITY-REDUNDANCY-MIB traps.

all

boolean

Enable all CISCO-ENTITY-REDUNDANCY-MIB traps

Choices:

  • no

  • yes

status

boolean

Enable status change traps

Choices:

  • no

  • yes

switchover

boolean

Enable switchover traps.

Choices:

  • no

  • yes

entity_state

dictionary

Enable SNMP entity-state traps.

operstatus

boolean

Enable entity oper status enable notification.

Choices:

  • no

  • yes

switchover

boolean

Enable entity state switchover notifications

Choices:

  • no

  • yes

flash

dictionary

Enable flash-mib traps.

insertion

boolean

Enable ciscoFlashDeviceInsertedNotif.

Choices:

  • no

  • yes

removal

boolean

Enable ciscoFlashDeviceRemovedNotif.

Choices:

  • no

  • yes

fru_ctrl

boolean

Enable SNMP entity FRU control traps.

Choices:

  • no

  • yes

hsrp

boolean

Enable SNMP hsrp traps.

Choices:

  • no

  • yes

ipsec

dictionary

Enable SNMP IPSec traps.

start

boolean

Enable SNMP IPsec Tunnel Start trap.

Choices:

  • no

  • yes

stop

boolean

Enable SNMP IPsec Tunnel Stop trap.

Choices:

  • no

  • yes

ipsla

boolean

Enable SNMP hipsla traps.

Choices:

  • no

  • yes

isakmp

dictionary

Enable SNMP isakmp traps.

start

boolean

Enable SNMP isakmp Tunnel Start trap.

Choices:

  • no

  • yes

stop

boolean

Enable SNMP isakmp Tunnel Stop trap.

Choices:

  • no

  • yes

isis

dictionary

Enable isis traps. If set to enabled , all the traps are set.

adjacency_change

boolean

adjacency-change

Choices:

  • no

  • yes

all

boolean

anable all is-is traps.

Choices:

  • no

  • yes

area_mismatch

boolean

area-mismatch

Choices:

  • no

  • yes

attempt_to_exceed_max_sequence

boolean

attempt-to-exceed-max-sequence

Choices:

  • no

  • yes

authentication_failure

boolean

authentication-failure.

Choices:

  • no

  • yes

authentication_type_failure

boolean

authentication-type-failure.

Choices:

  • no

  • yes

corrupted_lsp_detected

boolean

isisCorruptedLSPDetected

Choices:

  • no

  • yes

database_overload

boolean

database-overload

Choices:

  • no

  • yes

id_len_mismatch

boolean

isisIDLenMismatch

Choices:

  • no

  • yes

lsp_error_detected

boolean

lsp-error-detected.

Choices:

  • no

  • yes

lsp_too_large_to_propagate

boolean

lsp-too-large-to-propagate

Choices:

  • no

  • yes

manual_address_drops

boolean

manual_address_drops

Choices:

  • no

  • yes

max_area_addresses_mismatch

boolean

max_area_addresses_mismatch

Choices:

  • no

  • yes

orig_lsp_buff_size_mismatch

boolean

orig-lsp-buff-size-mismatch

Choices:

  • no

  • yes

own_lsp_purge

boolean

own-lsp-purge

Choices:

  • no

  • yes

protocols_supported_mismatch

boolean

protocols-supported-mismatch

Choices:

  • no

  • yes

rejected_adjacency

boolean

rejected-adjacency

Choices:

  • no

  • yes

sequence_number_skip

boolean

sequence-number-skip.

Choices:

  • no

  • yes

version_skew

boolean

version-skew

Choices:

  • no

  • yes

l2tun

dictionary

Enable L2TUN traps.

pseudowire_status

boolean

Enable L2TUN pseudowire status traps.

Choices:

  • no

  • yes

sessions

boolean

Enable L2TUN sessions traps.

Choices:

  • no

  • yes

tunnel_down

boolean

Enable L2TUN tunnel DOWN traps.

Choices:

  • no

  • yes

tunnel_up

boolean

Enable L2TUN tunnel UP traps.

Choices:

  • no

  • yes

l2vpn

dictionary

Enable L2VPN traps.

all

boolean

Enable L2VPN ALL traps.

Choices:

  • no

  • yes

cisco

boolean

Enable L2VPN CISCO traps.

Choices:

  • no

  • yes

vc_down

boolean

Enable L2VPN VC DOWN traps.

Choices:

  • no

  • yes

vc_up

boolean

Enable L2VPN VC UP traps.

Choices:

  • no

  • yes

msdp_peer_state_change

boolean

Enable SNMP MSDP traps

Choices:

  • no

  • yes

ntp

boolean

Enable SNMP Cisco Ntp traps.

Choices:

  • no

  • yes

ospf

dictionary

Enable Ospf traps. If set to enabled , all the traps are set.

errors

dictionary

error

authentication_failure

boolean

authentication-failure.

Choices:

  • no

  • yes

bad_packet

boolean

bad-packet

Choices:

  • no

  • yes

config_error

boolean

config-error

Choices:

  • no

  • yes

virt_authentication_failure

boolean

virt-authentication-failure

Choices:

  • no

  • yes

virt_bad_packet

boolean

virt-bad-packet

Choices:

  • no

  • yes

virt_config_error

boolean

virt_config_error

Choices:

  • no

  • yes

lsa

dictionary

lsa

lsa_maxage

boolean

lsa-maxage

Choices:

  • no

  • yes

lsa_originate

boolean

lsa-originate

Choices:

  • no

  • yes

retransmit

dictionary

retransmit

packets

boolean

packets

Choices:

  • no

  • yes

virt_packets

boolean

virt-packets

Choices:

  • no

  • yes

state_change

dictionary

state-change.

if_state_change

boolean

if-state-change

Choices:

  • no

  • yes

neighbor_state_change

boolean

neighbor-state-change

Choices:

  • no

  • yes

virtif_state_change

boolean

virtif-state-change

Choices:

  • no

  • yes

virtneighbor_state_change

boolean

virtneighbor-state-change

Choices:

  • no

  • yes

ospfv3

dictionary

Enable Ospfv3 traps. If set to enabled , all the traps are set.

errors

dictionary

error

bad_packet

boolean

bad-packet

Choices:

  • no

  • yes

config_error

boolean

config-error

Choices:

  • no

  • yes

virt_bad_packet

boolean

virt-bad-packet

Choices:

  • no

  • yes

virt_config_error

boolean

virt_config_error

Choices:

  • no

  • yes

state_change

dictionary

state-change.

if_state_change

boolean

if-state-change

Choices:

  • no

  • yes

neighbor_state_change

boolean

neighbor-state-change

Choices:

  • no

  • yes

nssa_state_change

boolean

nssa-state-change

Choices:

  • no

  • yes

restart_helper_status_change

boolean

restart-helper-status-change

Choices:

  • no

  • yes

restart_status_change

boolean

restart-status-change

Choices:

  • no

  • yes

restart_virtual_helper_status_change

boolean

restart-virtual-helper-status-change

Choices:

  • no

  • yes

virtif_state_change

boolean

virtif-state-change

Choices:

  • no

  • yes

virtneighbor_state_change

boolean

virtneighbor-state-change

Choices:

  • no

  • yes

pim

dictionary

Enable Pim traps. If set to enabled , all the traps are set.

interface_state_change

boolean

interface-state-change .

Choices:

  • no

  • yes

invalid_message_received

boolean

invalid-message-received

Choices:

  • no

  • yes

neighbor_change

boolean

neighbor-change.

Choices:

  • no

  • yes

rp_mapping_change

boolean

rp-mapping-change.

Choices:

  • no

  • yes

power

boolean

Enable SNMP entity power traps.

Choices:

  • no

  • yes

rf

boolean

Enable SNMP RF-MIB traps.

Choices:

  • no

  • yes

rsvp

dictionary

Enable rsvp traps. If set to enabled , all the traps are set.

all

boolean

enable all traps.

Choices:

  • no

  • yes

lost_flow

boolean

lost-flow

Choices:

  • no

  • yes

new_flow

boolean

new-flow

Choices:

  • no

  • yes

selective_vrf_download_role_change

boolean

Enable selective VRF download traps.

Choices:

  • no

  • yes

sensor

boolean

Enable SNMP entity sensor traps

Choices:

  • no

  • yes

snmp

dictionary

Enable snmp traps. If set to enabled , all the traps are set.

authentication

boolean

authentication

Choices:

  • no

  • yes

coldstart

boolean

coldstart.

Choices:

  • no

  • yes

linkdown

boolean

link-down

Choices:

  • no

  • yes

linkup

boolean

link-up

Choices:

  • no

  • yes

warmstart

boolean

warmstart.

Choices:

  • no

  • yes

subscriber

dictionary

Subscriber notification commands.

session_agg_access_interface

boolean

Subscriber notification at access interface level

Choices:

  • no

  • yes

session_agg_node

boolean

Subscriber notification at node level

Choices:

  • no

  • yes

syslog

boolean

syslog

Choices:

  • no

  • yes

system

boolean

Enable SNMP SYSTEMMIB-MIB traps.

Choices:

  • no

  • yes

vpls

dictionary

Enable VPLS traps

all

boolean

Enable all VPLS traps.

Choices:

  • no

  • yes

full_clear

boolean

Enable VPLS Full Clear traps.

Choices:

  • no

  • yes

full_raise

boolean

Enable VPLS Full Raise traps.

Choices:

  • no

  • yes

status

boolean

Enable VPLS Status traps

Choices:

  • no

  • yes

vrrp_events

boolean

vrrp

Choices:

  • no

  • yes

users

list / elements=dictionary

SNMP user configuration.

acl_v4

aliases: Ipv4_acl

string

Ipv4 Type of Access-list

acl_v6

aliases: Ipv6_acl

string

Ipv6 Type of Access-list

group

string

SNMP group for the user.

SDROwner

boolean

SDR Owner permissions for MIB Objects.

Choices:

  • no

  • yes

SystemOwner

boolean

System Owner permissions for MIB objects.

Choices:

  • no

  • yes

user

string

SNMP user name

v4_acl

string

V4 Access-list name

version

string

snmp security version

Choices:

  • v1

  • v2c

  • v3

vrfs

list / elements=dictionary

Specify the VRF in which the source address is used

context

list / elements=string

Configure the source interface for SNMP notifications

hosts

list / elements=dictionary

Notification destinations

community

string

community string.

host

string

Hostname or IP address of SNMP notification host.

informs

boolean

Use SNMP inform messages.

Choices:

  • no

  • yes

traps

boolean

Use SNMP trap messages

Choices:

  • no

  • yes

udp_port

integer

UDP destination port for notification messages.

version

string

Notification message SNMP version.

Choices:

  • 1

  • 2c

  • 3

vrf

string

vrf name.

running_config

string

This option is used only with state parsed.

The value of this option should be the output received from the IOSXR device by executing the command show running-config snmp-server.

The state parsed reads the configuration from running_config option and transforms it into Ansible structured data as per the resource module’s argspec and the value is then returned in the parsed key within the result.

state

string

The state the configuration should be left in.

The states replaced and overridden have identical behaviour for this module.

Please refer to examples for more details.

Choices:

  • deleted

  • merged ← (default)

  • overridden

  • replaced

  • gathered

  • rendered

  • parsed

Notes

Note

  • Tested against Cisco Iosxr 7.0.2

  • This module works with connection network_cli.

Examples

# Using state: merged
# Before state:
# -------------
# RP/0/RP0/CPU0:test2#show running-config snmp-server
# --------------------- EMPTY -----------------
# Merged play:
# ------------
- name: Merge the provided configuration with the existing running configuration
  cisco.iosxr.iosxr_snmp_server:
        config:
          vrfs:
            - hosts:
                - community: test1
                  host: 1.1.1.1
                  traps: true
              vrf: vrf1
          users:
            - Ipv4_acl: test1
              Ipv6_acl: test2
              group: test2
              user: u1
              version: v1
          timeouts:
            duplicate: 0
            inQdrop: 0
          trap:
            throttle_time: 12
          targets:
            - host: 1.1.1.2
              name: test

          ifmib:
            internal_cache_max_duration: 4
          inform:
            retries: 7
          chassis_id: test2
          packetsize: 490
          queue_length: 2
          throttle_time: 60
          trap_source: GigabitEthernet0/0/0/2
          trap_timeout: 3
          context:
            - c1
            - c2
          contact: t1
          correlator:
            buffer_size: 1024
          communities:
            - name: test2
              ro: true
              sdrowner: true
              acl_v4: test
              acl_v6: test1
          community_maps:
            - name: cm1
              context: c1
              target_list: t1
              security_name: s1
          drop:
            report_IPv4: test1
            unknown_user: true
          ipv6:
            precedence: routine
          ipv4:
            dscp: af11
          location: test1
          logging_threshold_oid_processing: 1
          logging_threshold_pdu_processing: 1
          mib_bulkstat_max_procmem_size: 101
          mroutemib_send_all_vrf: true
          overload_control:
            overload_drop_time: 4
            overload_throttle_rate: 6
          notification_log_mib:
            GlobalSize: 5
            size: 5
          traps:
            hsrp: true
            ipsla: true
            ipsec:
              start: true
              stop: true
            bridgemib: true
            bulkstat_collection: true
            cisco_entity_ext: true
            config: true
            copy_complete: true
            addrpool:
              high: true
              low: true
            bfd: true
            bgp:
              cbgp2: true
            l2tun:
              sessions: true
              tunnel_down: true
              tunnel_up: true
            l2vpn:
              all: true
              vc_down: true
              vc_up: true
            msdp_peer_state_change: true
#
# Commands Fired:
# ------------
# "commands": [
#         "snmp-server chassis-id test2",
#         "snmp-server correlator buffer-size 1024",
#         "snmp-server contact t1",
#         "snmp-server ipv4 dscp af11",
#         "snmp-server ipv6 precedence routine",
#         "snmp-server location test1",
#         "snmp-server logging threshold oid-processing 1",
#         "snmp-server logging threshold pdu-processing 1",
#         "snmp-server mib bulkstat max-procmem-size 101",
#         "snmp-server mroutemib send-all-vrf",
#         "snmp-server overload-control 4 6",
#         "snmp-server packetsize 490",
#         "snmp-server queue-length 2",
#         "snmp-server throttle-time 60",
#         "snmp-server trap-source GigabitEthernet0/0/0/2",
#         "snmp-server trap-timeout 3",
#         "snmp-server drop report acl IPv4 test1",
#         "snmp-server drop unknown-user",
#         "snmp-server ifmib internal cache max-duration 4",
#         "snmp-server inform retries 7",
#         "snmp-server notification-log-mib size 5",
#         "snmp-server notification-log-mib GlobalSize 5",
#         "snmp-server trap throttle-time 12",
#         "snmp-server timeouts inQdrop 0",
#         "snmp-server timeouts duplicate 0",
#         "snmp-server traps addrpool low",
#         "snmp-server traps addrpool high",
#         "snmp-server traps bfd",
#         "snmp-server traps bgp cbgp2",
#         "snmp-server traps bulkstat collection",
#         "snmp-server traps bridgemib",
#         "snmp-server traps copy-complete",
#         "snmp-server traps cisco-entity-ext",
#         "snmp-server traps config",
#         "snmp-server traps hsrp",
#         "snmp-server traps ipsla",
#         "snmp-server traps ipsec tunnel start",
#         "snmp-server traps ipsec tunnel stop",
#         "snmp-server traps l2tun sessions",
#         "snmp-server traps l2tun tunnel-up",
#         "snmp-server traps l2tun tunnel-down",
#         "snmp-server traps l2vpn all",
#         "snmp-server traps l2vpn vc-up",
#         "snmp-server traps l2vpn vc-down",
#         "snmp-server traps msdp peer-state-change",
#         "snmp-server community test2 RO SDROwner IPv4 test IPv6 test1",
#         "snmp-server community-map cm1 context c1 security-name s1 target-list t1",
#         "snmp-server context c1",
#         "snmp-server context c2",
#         "snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2",
#         "snmp-server target list test2 vrf vrf2",
#         "snmp-server target list test host 1.1.1.2",
#         "snmp-server vrf vrf1",
#         "host 1.1.1.1 traps test1"
#
#     ],
# After state:
# ------------
# RP/0/RP0/CPU0:test2#show running-config snmp-server
# Mon Nov 29 12:49:29.521 UTC
# snmp-server vrf vrf1
#  host 1.1.1.1 traps test1
# !
# snmp-server drop report acl IPv4 test1
# snmp-server drop unknown-user
# snmp-server ipv4 dscp af11
# snmp-server ipv6 precedence routine
# snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2
# snmp-server community test2 RO SDROwner IPv4 test IPv6 test1
# snmp-server queue-length 2
# snmp-server trap-timeout 3
# snmp-server trap throttle-time 12
# snmp-server traps bfd
# snmp-server traps bgp cbgp2
# snmp-server traps copy-complete
# snmp-server traps hsrp
# snmp-server traps ipsla
# snmp-server traps msdp peer-state-change
# snmp-server traps ipsec tunnel stop
# snmp-server traps ipsec tunnel start
# snmp-server traps config
# snmp-server traps l2tun sessions
# snmp-server traps l2tun tunnel-up
# snmp-server traps l2tun tunnel-down
# snmp-server traps bulkstat collection
# snmp-server traps l2vpn all
# snmp-server traps l2vpn vc-up
# snmp-server traps l2vpn vc-down
# snmp-server traps bridgemib
# snmp-server traps addrpool low
# snmp-server traps addrpool high
# snmp-server traps cisco-entity-ext
# snmp-server chassis-id test2
# snmp-server contact t1
# snmp-server location test1
# snmp-server target list test host 1.1.1.2
# snmp-server target list test2 vrf vrf2
# snmp-server context c1
# snmp-server context c2
# snmp-server logging threshold oid-processing 1
# snmp-server logging threshold pdu-processing 1
# snmp-server mib bulkstat max-procmem-size 101
# snmp-server timeouts duplicate 0
# snmp-server timeouts inQdrop 0
# snmp-server packetsize 490
# snmp-server correlator buffer-size 1024
# snmp-server trap-source GigabitEthernet0/0/0/2
# snmp-server throttle-time 60
# snmp-server community-map cm1 context c1 security-name s1 target-list t1
# snmp-server inform retries 7
# snmp-server overload-control 4 6
# snmp-server ifmib internal cache max-duration 4
# snmp-server mroutemib send-all-vrf
# snmp-server notification-log-mib size 5
# snmp-server notification-log-mib GlobalSize 5
#
#
# Using state: deleted
# Before state:
# -------------
# RP/0/RP0/CPU0:test2#show running-config snmp-server
# Mon Nov 29 12:49:29.521 UTC
# snmp-server vrf vrf1
#  host 1.1.1.1 traps test1
# !
# snmp-server drop report acl IPv4 test1
# snmp-server drop unknown-user
# snmp-server ipv4 dscp af11
# snmp-server ipv6 precedence routine
# snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2
# snmp-server community test2 RO SDROwner IPv4 test IPv6 test1
# snmp-server queue-length 2
# snmp-server trap-timeout 3
# snmp-server trap throttle-time 12
# snmp-server traps bfd
# snmp-server traps bgp cbgp2
# snmp-server traps copy-complete
# snmp-server traps hsrp
# snmp-server traps ipsla
# snmp-server traps msdp peer-state-change
# snmp-server traps ipsec tunnel stop
# snmp-server traps ipsec tunnel start
# snmp-server traps config
# snmp-server traps l2tun sessions
# snmp-server traps l2tun tunnel-up
# snmp-server traps l2tun tunnel-down
# snmp-server traps bulkstat collection
# snmp-server traps l2vpn all
# snmp-server traps l2vpn vc-up
# snmp-server traps l2vpn vc-down
# snmp-server traps bridgemib
# snmp-server traps addrpool low
# snmp-server traps addrpool high
# snmp-server traps cisco-entity-ext
# snmp-server chassis-id test2
# snmp-server contact t1
# snmp-server location test1
# snmp-server target list test host 1.1.1.2
# snmp-server target list test2 vrf vrf2
# snmp-server context c1
# snmp-server context c2
# snmp-server logging threshold oid-processing 1
# snmp-server logging threshold pdu-processing 1
# snmp-server mib bulkstat max-procmem-size 101
# snmp-server timeouts duplicate 0
# snmp-server timeouts inQdrop 0
# snmp-server packetsize 490
# snmp-server correlator buffer-size 1024
# snmp-server trap-source GigabitEthernet0/0/0/2
# snmp-server throttle-time 60
# snmp-server community-map cm1 context c1 security-name s1 target-list t1
# snmp-server inform retries 7
# snmp-server overload-control 4 6
# snmp-server ifmib internal cache max-duration 4
# snmp-server mroutemib send-all-vrf
# snmp-server notification-log-mib size 5
# snmp-server notification-log-mib GlobalSize 5
# Deleted play:
# -------------
- name: Remove all existing configuration
  cisco.iosxr.iosxr_snmp_server:
    state: deleted
# Commands Fired:
# ---------------
# "commands": [
#        "no snmp-server chassis-id test2",
#         "no snmp-server correlator buffer-size 1024",
#         "no snmp-server contact t1",
#         "no snmp-server ipv4 dscp af11",
#         "no snmp-server ipv6 precedence routine",
#         "no snmp-server location test1",
#         "no snmp-server logging threshold oid-processing 1",
#         "no snmp-server logging threshold pdu-processing 1",
#         "no snmp-server mib bulkstat max-procmem-size 101",
#         "no snmp-server mroutemib send-all-vrf",
#         "no snmp-server overload-control 4 6",
#         "no snmp-server packetsize 490",
#         "no snmp-server queue-length 2",
#         "no snmp-server throttle-time 60",
#         "no snmp-server trap-source GigabitEthernet0/0/0/2",
#         "no snmp-server trap-timeout 3",
#         "no snmp-server drop report acl IPv4 test1",
#         "no snmp-server drop unknown-user",
#         "no snmp-server ifmib internal cache max-duration 4",
#         "no snmp-server inform retries 7",
#         "no snmp-server notification-log-mib size 5",
#         "no snmp-server notification-log-mib GlobalSize 5",
#         "no snmp-server trap throttle-time 12",
#         "no snmp-server timeouts inQdrop 0",
#         "no snmp-server timeouts duplicate 0",
#         "no snmp-server traps addrpool low",
#         "no snmp-server traps addrpool high",
#         "no snmp-server traps bfd",
#         "no snmp-server traps bgp cbgp2",
#         "no snmp-server traps bulkstat collection",
#         "no snmp-server traps bridgemib",
#         "no snmp-server traps copy-complete",
#         "no snmp-server traps cisco-entity-ext",
#         "no snmp-server traps config",
#         "no snmp-server traps hsrp",
#         "no snmp-server traps ipsla",
#         "no snmp-server traps ipsec tunnel start",
#         "no snmp-server traps ipsec tunnel stop",
#         "no snmp-server traps l2tun sessions",
#         "no snmp-server traps l2tun tunnel-up",
#         "no snmp-server traps l2tun tunnel-down",
#         "no snmp-server traps l2vpn all",
#         "no snmp-server traps l2vpn vc-up",
#         "no snmp-server traps l2vpn vc-down",
#         "no snmp-server traps msdp peer-state-change",
#         "no snmp-server community test2 RO SDROwner IPv4 test IPv6 test1",
#         "no snmp-server community-map cm1 context c1 security-name s1 target-list t1",
#         "no snmp-server context c1",
#         "no snmp-server context c2",
#         "no snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2",
#         "no snmp-server target list test host 1.1.1.2",
#         "no snmp-server target list test2 vrf vrf2",
#         "no snmp-server vrf vrf1"
#     ],
# After state:
# ------------
# RP/0/0/CPU0:10#show running-config ntp
# --------------------- EMPTY -----------------
# Using state: overridden
# Before state:
# -------------
# RP/0/0/CPU0:10#show running-config snmp-server
# snmp-server vrf vrf1
#  host 1.1.1.1 traps test1
# !
# snmp-server drop report acl IPv4 test1
# snmp-server drop unknown-user
# snmp-server ipv4 dscp af11
# snmp-server ipv6 precedence routine
# snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2
# snmp-server community test2 RO SDROwner IPv4 test IPv6 test1
# snmp-server queue-length 2
# snmp-server trap-timeout 3
# snmp-server trap throttle-time 12
# snmp-server traps bfd
# snmp-server traps bgp cbgp2
# snmp-server traps copy-complete
# snmp-server traps hsrp
# snmp-server traps ipsla
# snmp-server traps msdp peer-state-change
# snmp-server traps ipsec tunnel stop
# snmp-server traps ipsec tunnel start
# snmp-server traps config
# snmp-server traps l2tun sessions
# snmp-server traps l2tun tunnel-up
# snmp-server traps l2tun tunnel-down
# snmp-server traps bulkstat collection
# snmp-server traps l2vpn all
# snmp-server traps l2vpn vc-up
# snmp-server traps l2vpn vc-down
# snmp-server traps bridgemib
# snmp-server traps addrpool low
# snmp-server traps addrpool high
# snmp-server traps cisco-entity-ext
# snmp-server chassis-id test2
# snmp-server contact t1
# snmp-server location test1
# snmp-server target list test host 1.1.1.2
# snmp-server target list test2 vrf vrf2
# snmp-server context c1
# snmp-server context c2
# snmp-server logging threshold oid-processing 1
# snmp-server logging threshold pdu-processing 1
# snmp-server mib bulkstat max-procmem-size 101
# snmp-server timeouts duplicate 0
# snmp-server timeouts inQdrop 0
# snmp-server packetsize 490
# snmp-server correlator buffer-size 1024
# snmp-server trap-source GigabitEthernet0/0/0/2
# snmp-server throttle-time 60
# snmp-server community-map cm1 context c1 security-name s1 target-list t1
# snmp-server inform retries 7
# snmp-server overload-control 4 6
# snmp-server ifmib internal cache max-duration 4
# snmp-server mroutemib send-all-vrf
# snmp-server notification-log-mib size 5
# snmp-server notification-log-mib GlobalSize 5
# Overridden play:
# ----------------
- name: Override Snmp-server configuration with provided configuration
  cisco.iosxr.iosxr_snmp_server:
        config:
          timeouts:
            duplicate: 0
            inQdrop: 0
          trap:
            throttle_time: 13
          targets:
            - host: 1.1.1.2
              name: test

          ifmib:
            internal_cache_max_duration: 5
          inform:
            retries: 7
          chassis_id: test
          packetsize: 491
          queue_length: 2
          throttle_time: 60
          trap_source: GigabitEthernet0/0/0/2
          trap_timeout: 3
          context:
            - c1
            - c2
          contact: t1
          correlator:
            buffer_size: 1025
          communities:
            - name: test1
              ro: true
              sdrowner: true
              acl_v4: test
              acl_v6: test1
          community_maps:
            - name: cm2
              context: c1
              target_list: t1
              security_name: s1
          drop:
            report_IPv4: test2
            unknown_user: true
          ipv6:
            precedence: routine
          ipv4:
            dscp: af11
          location: test1
          logging_threshold_oid_processing: 2
          logging_threshold_pdu_processing: 2
          mib_bulkstat_max_procmem_size: 101
          mroutemib_send_all_vrf: true
          overload_control:
            overload_drop_time: 4
            overload_throttle_rate: 6
          notification_log_mib:
            GlobalSize: 5
            size: 5
          traps:
            hsrp: true
            ipsla: true
            ipsec:
              start: true
              stop: true
            bridgemib: true
            bulkstat_collection: true
            cisco_entity_ext: true
            config: true
            copy_complete: true
            l2vpn:
              all: true
              vc_down: true
              vc_up: true
            msdp_peer_state_change: true
        state: overridden
# Commands Fired:
# ---------------
# "commands": [
#        "no snmp-server traps addrpool low",
#         "no snmp-server traps addrpool high",
#         "no snmp-server traps bfd",
#         "no snmp-server traps bgp cbgp2",
#         "no snmp-server traps l2tun sessions",
#         "no snmp-server traps l2tun tunnel-up",
#         "no snmp-server traps l2tun tunnel-down",
#         "no snmp-server community test2 RO SDROwner IPv4 test IPv6 test1",
#         "no snmp-server community-map cm1 context c1 security-name s1 target-list t1",
#         "no snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2",
#         "no snmp-server vrf vrf1",
#         "snmp-server chassis-id test",
#         "snmp-server correlator buffer-size 1025",
#         "snmp-server logging threshold oid-processing 2",
#         "snmp-server logging threshold pdu-processing 2",
#         "snmp-server packetsize 491",
#         "snmp-server drop report acl IPv4 test2",
#         "snmp-server ifmib internal cache max-duration 5",
#         "snmp-server trap throttle-time 13",
#         "snmp-server community test1 RO SDROwner IPv4 test IPv6 test1",
#         "snmp-server community-map cm2 context c1 security-name s1 target-list t1"
#     ],
# After state:
# ------------
# RP/0/RP0/CPU0:test2#show running-config snmp-server
# Mon Nov 29 12:57:34.182 UTC
# snmp-server drop report acl IPv4 test2
# snmp-server drop unknown-user
# snmp-server ipv4 dscp af11
# snmp-server ipv6 precedence routine
# snmp-server community test1 RO SDROwner IPv4 test IPv6 test1
# snmp-server queue-length 2
# snmp-server trap-timeout 3
# snmp-server trap throttle-time 13
# snmp-server traps copy-complete
# snmp-server traps hsrp
# snmp-server traps ipsla
# snmp-server traps msdp peer-state-change
# snmp-server traps ipsec tunnel stop
# snmp-server traps ipsec tunnel start
# snmp-server traps config
# snmp-server traps bulkstat collection
# snmp-server traps l2vpn all
# snmp-server traps l2vpn vc-up
# snmp-server traps l2vpn vc-down
# snmp-server traps bridgemib
# snmp-server traps cisco-entity-ext
# snmp-server chassis-id test
# snmp-server contact t1
# snmp-server location test1
# snmp-server target list test host 1.1.1.2
# snmp-server target list test2 vrf vrf2
# snmp-server context c1
# snmp-server context c2
# snmp-server logging threshold oid-processing 2
# snmp-server logging threshold pdu-processing 2
# snmp-server mib bulkstat max-procmem-size 101
# snmp-server timeouts duplicate 0
# snmp-server timeouts inQdrop 0
# snmp-server packetsize 491
# snmp-server correlator buffer-size 1025
# snmp-server trap-source GigabitEthernet0/0/0/2
# snmp-server throttle-time 60
# snmp-server community-map cm2 context c1 security-name s1 target-list t1
# snmp-server inform retries 7
# snmp-server overload-control 4 6
# snmp-server ifmib internal cache max-duration 5
# snmp-server mroutemib send-all-vrf
# snmp-server notification-log-mib size 5
# snmp-server notification-log-mib GlobalSize 5
#
# Using state: replaced
# Before state:
# -------------
# RP/0/0/CPU0:10#show running-config snmp-server
# snmp-server vrf vrf1
#  host 1.1.1.1 traps test1
# !
# snmp-server drop report acl IPv4 test1
# snmp-server drop unknown-user
# snmp-server ipv4 dscp af11
# snmp-server ipv6 precedence routine
# snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2
# snmp-server community test2 RO SDROwner IPv4 test IPv6 test1
# snmp-server queue-length 2
# snmp-server trap-timeout 3
# snmp-server trap throttle-time 12
# snmp-server traps bfd
# snmp-server traps bgp cbgp2
# snmp-server traps copy-complete
# snmp-server traps hsrp
# snmp-server traps ipsla
# snmp-server traps msdp peer-state-change
# snmp-server traps ipsec tunnel stop
# snmp-server traps ipsec tunnel start
# snmp-server traps config
# snmp-server traps l2tun sessions
# snmp-server traps l2tun tunnel-up
# snmp-server traps l2tun tunnel-down
# snmp-server traps bulkstat collection
# snmp-server traps l2vpn all
# snmp-server traps l2vpn vc-up
# snmp-server traps l2vpn vc-down
# snmp-server traps bridgemib
# snmp-server traps addrpool low
# snmp-server traps addrpool high
# snmp-server traps cisco-entity-ext
# snmp-server chassis-id test2
# snmp-server contact t1
# snmp-server location test1
# snmp-server target list test host 1.1.1.2
# snmp-server target list test2 vrf vrf2
# snmp-server context c1
# snmp-server context c2
# snmp-server logging threshold oid-processing 1
# snmp-server logging threshold pdu-processing 1
# snmp-server mib bulkstat max-procmem-size 101
# snmp-server timeouts duplicate 0
# snmp-server timeouts inQdrop 0
# snmp-server packetsize 490
# snmp-server correlator buffer-size 1024
# snmp-server trap-source GigabitEthernet0/0/0/2
# snmp-server throttle-time 60
# snmp-server community-map cm1 context c1 security-name s1 target-list t1
# snmp-server inform retries 7
# snmp-server overload-control 4 6
# snmp-server ifmib internal cache max-duration 4
# snmp-server mroutemib send-all-vrf
# snmp-server notification-log-mib size 5
# snmp-server notification-log-mib GlobalSize 5
#
#
# Replaced play:
# ----------------
- name: Replace Snmp-server configuration with provided configuration
  cisco.iosxr.iosxr_snmp_server:
        state: replaced
        config:
          timeouts:
            duplicate: 0
            inQdrop: 0
          trap:
            throttle_time: 13
          targets:
            - host: 1.1.1.2
              name: test

          ifmib:
            internal_cache_max_duration: 5
          inform:
            retries: 7
          chassis_id: test
          packetsize: 491
          queue_length: 2
          throttle_time: 60
          trap_source: GigabitEthernet0/0/0/2
          trap_timeout: 3
          context:
            - c1
            - c2
          contact: t1
          correlator:
            buffer_size: 1025
          communities:
            - name: test1
              ro: true
              sdrowner: true
              acl_v4: test
              acl_v6: test1
          community_maps:
            - name: cm2
              context: c1
              target_list: t1
              security_name: s1
          drop:
            report_IPv4: test2
            unknown_user: true
          ipv6:
            precedence: routine
          ipv4:
            dscp: af11
          location: test1
          logging_threshold_oid_processing: 2
          logging_threshold_pdu_processing: 2
          mib_bulkstat_max_procmem_size: 101
          mroutemib_send_all_vrf: true
          overload_control:
            overload_drop_time: 4
            overload_throttle_rate: 6
          notification_log_mib:
            GlobalSize: 5
            size: 5
          traps:
            hsrp: true
            ipsla: true
            ipsec:
              start: true
              stop: true
            bridgemib: true
            bulkstat_collection: true
            cisco_entity_ext: true
            config: true
            copy_complete: true
            l2vpn:
              all: true
              vc_down: true
              vc_up: true
            msdp_peer_state_change: true
#
# Commands Fired:
# ---------------
# "commands": [
#         "no snmp-server traps addrpool low",
#         "no snmp-server traps addrpool high",
#         "no snmp-server traps bfd",
#         "no snmp-server traps bgp cbgp2",
#         "no snmp-server traps l2tun sessions",
#         "no snmp-server traps l2tun tunnel-up",
#         "no snmp-server traps l2tun tunnel-down",
#         "no snmp-server community test2 RO SDROwner IPv4 test IPv6 test1",
#         "no snmp-server community-map cm1 context c1 security-name s1 target-list t1",
#         "no snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2",
#         "no snmp-server vrf vrf1",
#         "snmp-server chassis-id test",
#         "snmp-server correlator buffer-size 1025",
#         "snmp-server logging threshold oid-processing 2",
#         "snmp-server logging threshold pdu-processing 2",
#         "snmp-server packetsize 491",
#         "snmp-server drop report acl IPv4 test2",
#         "snmp-server ifmib internal cache max-duration 5",
#         "snmp-server trap throttle-time 13",
#         "snmp-server community test1 RO SDROwner IPv4 test IPv6 test1",
#         "snmp-server community-map cm2 context c1 security-name s1 target-list t1"
#     ],
# After state:
# ------------
# RP/0/RP0/CPU0:ios#show running-config snmp-server
# Mon Sep 13 10:38:22.690 UTC
# RP/0/0/CPU0:10#show running-config snmp-server
# snmp-server vrf vrf1
#  host 1.1.1.1 traps test1
# !
# snmp-server drop report acl IPv4 test1
# snmp-server drop unknown-user
# snmp-server ipv4 dscp af11
# snmp-server ipv6 precedence routine
# snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2
# snmp-server community test2 RO SDROwner IPv4 test IPv6 test1
# snmp-server queue-length 2
# snmp-server trap-timeout 3
# snmp-server trap throttle-time 12
# snmp-server traps bfd
# snmp-server traps bgp cbgp2
# snmp-server traps copy-complete
# snmp-server traps hsrp
# snmp-server traps ipsla
# snmp-server traps msdp peer-state-change
# snmp-server traps ipsec tunnel stop
# snmp-server traps ipsec tunnel start
# snmp-server traps config
# snmp-server traps l2tun sessions
# snmp-server traps l2tun tunnel-up
# snmp-server traps l2tun tunnel-down
# snmp-server traps bulkstat collection
# snmp-server traps l2vpn all
# snmp-server traps l2vpn vc-up
# snmp-server traps l2vpn vc-down
# snmp-server traps bridgemib
# snmp-server traps addrpool low
# snmp-server traps addrpool high
# snmp-server traps cisco-entity-ext
# snmp-server chassis-id test2
# snmp-server contact t1
# snmp-server location test1
# snmp-server target list test host 1.1.1.2
# snmp-server target list test2 vrf vrf2
# snmp-server context c1
# snmp-server context c2
# snmp-server logging threshold oid-processing 1
# snmp-server logging threshold pdu-processing 1
# snmp-server mib bulkstat max-procmem-size 101
# snmp-server timeouts duplicate 0
# snmp-server timeouts inQdrop 0
# snmp-server packetsize 490
# snmp-server correlator buffer-size 1024
# snmp-server trap-source GigabitEthernet0/0/0/2
# snmp-server throttle-time 60
# snmp-server community-map cm1 context c1 security-name s1 target-list t1
# snmp-server inform retries 7
# snmp-server overload-control 4 6
# snmp-server ifmib internal cache max-duration 4
# snmp-server mroutemib send-all-vrf
# snmp-server notification-log-mib size 5
# snmp-server notification-log-mib GlobalSize 5
#
#
# Using state: gathered
# Before state:
# -------------
# RP/0/RP0/CPU0:test2#show running-config snmp-server
# Mon Nov 29 12:49:29.521 UTC
# snmp-server vrf vrf1
#  host 1.1.1.1 traps test1
# !
# snmp-server drop report acl IPv4 test1
# snmp-server drop unknown-user
# snmp-server ipv4 dscp af11
# snmp-server ipv6 precedence routine
# snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2
# snmp-server community test2 RO SDROwner IPv4 test IPv6 test1
# snmp-server queue-length 2
# snmp-server trap-timeout 3
# snmp-server trap throttle-time 12
# snmp-server traps bfd
# snmp-server traps bgp cbgp2
# snmp-server traps copy-complete
# snmp-server traps hsrp
# snmp-server traps ipsla
# snmp-server traps msdp peer-state-change
# snmp-server traps ipsec tunnel stop
# snmp-server traps ipsec tunnel start
# snmp-server traps config
# snmp-server traps l2tun sessions
# snmp-server traps l2tun tunnel-up
# snmp-server traps l2tun tunnel-down
# snmp-server traps bulkstat collection
# snmp-server traps l2vpn all
# snmp-server traps l2vpn vc-up
# snmp-server traps l2vpn vc-down
# snmp-server traps bridgemib
# snmp-server traps addrpool low
# snmp-server traps addrpool high
# snmp-server traps cisco-entity-ext
# snmp-server chassis-id test2
# snmp-server contact t1
# snmp-server location test1
# snmp-server target list test host 1.1.1.2
# snmp-server target list test2 vrf vrf2
# snmp-server context c1
# snmp-server context c2
# snmp-server logging threshold oid-processing 1
# snmp-server logging threshold pdu-processing 1
# snmp-server mib bulkstat max-procmem-size 101
# snmp-server timeouts duplicate 0
# snmp-server timeouts inQdrop 0
# snmp-server packetsize 490
# snmp-server correlator buffer-size 1024
# snmp-server trap-source GigabitEthernet0/0/0/2
# snmp-server throttle-time 60
# snmp-server community-map cm1 context c1 security-name s1 target-list t1
# snmp-server inform retries 7
# snmp-server overload-control 4 6
# snmp-server ifmib internal cache max-duration 4
# snmp-server mroutemib send-all-vrf
# snmp-server notification-log-mib size 5
# snmp-server notification-log-mib GlobalSize 5
# Gathered play:
# --------------
- name: Gather listed snmp server
  cisco.iosxr.iosxr_snmp_server:
    state: gathered
# Module Execution Result:
# ------------------------
# "gathered": {
#         "chassis_id": "test2",
#         "communities": [
#             {
#                 "acl_v4": "test",
#                 "acl_v6": "test1",
#                 "name": "test2",
#                 "ro": true,
#                 "sdrowner": true
#             }
#         ],
#         "community_maps": [
#             {
#                 "context": "c1",
#                 "name": "cm1",
#                 "security_name": "s1",
#                 "target_list": "t1"
#             }
#         ],
#         "contact": "t1",
#         "context": [
#             "c1",
#             "c2"
#         ],
#         "correlator": {
#             "buffer_size": 1024
#         },
#         "drop": {
#             "report_IPv4": "test1",
#             "unknown_user": true
#         },
#         "ifmib": {
#             "internal_cache_max_duration": 4
#         },
#         "inform": {
#             "retries": 7
#         },
#         "ipv4": {
#             "dscp": "af11"
#         },
#         "ipv6": {
#             "precedence": "routine"
#         },
#         "location": "test1",
#         "logging_threshold_oid_processing": 1,
#         "logging_threshold_pdu_processing": 1,
#         "mib_bulkstat_max_procmem_size": 101,
#         "mroutemib_send_all_vrf": true,
#         "notification_log_mib": {
#             "GlobalSize": 5,
#             "size": 5
#         },
#         "overload_control": {
#             "overload_drop_time": 4,
#             "overload_throttle_rate": 6
#         },
#         "packetsize": 490,
#         "queue_length": 2,
#         "targets": [
#             {
#                 "host": "1.1.1.2",
#                 "name": "test"
#             },
#             {
#                 "name": "test2",
#                 "vrf": "vrf2"
#             }
#         ],
#         "throttle_time": 60,
#         "timeouts": {
#             "duplicate": 0,
#             "inQdrop": 0
#         },
#         "trap": {
#             "throttle_time": 12
#         },
#         "trap_source": "GigabitEthernet0/0/0/2",
#         "trap_timeout": 3,
#         "traps": {
#             "addrpool": {
#                 "high": true,
#                 "low": true
#             },
#             "bfd": true,
#             "bgp": {
#                 "cbgp2": true
#             },
#             "bridgemib": true,
#             "bulkstat_collection": true,
#             "cisco_entity_ext": true,
#             "config": true,
#             "copy_complete": true,
#             "hsrp": true,
#             "ipsec": {
#                 "start": true,
#                 "stop": true
#             },
#             "ipsla": true,
#             "l2tun": {
#                 "sessions": true,
#                 "tunnel_down": true,
#                 "tunnel_up": true
#             },
#             "l2vpn": {
#                 "all": true,
#                 "vc_down": true,
#                 "vc_up": true
#             },
#             "msdp_peer_state_change": true
#         },
#         "users": [
#             {
#                 "Ipv4_acl": "test1",
#                 "Ipv6_acl": "test2",
#                 "group": "test2",
#                 "user": "u1",
#                 "version": "v1"
#             }
#         ],
#         "vrfs": [
#             {
#                 "hosts": [
#                     {
#                         "community": "test1",
#                         "host": "1.1.1.1",
#                         "traps": true
#                     }
#                 ],
#                 "vrf": "vrf1"
#             }
#         ]
#     }
#
#
# Using state: rendered
# Rendered play:
# --------------
- name: Render platform specific configuration lines with state rendered (without connecting to the device)
  cisco.iosxr.iosxr_snmp_server:
    state: rendered
    config:
      vrfs:
        - hosts:
            - community: test1
              host: 1.1.1.1
              traps: true
          vrf: vrf1
      users:
        - Ipv4_acl: test1
          Ipv6_acl: test2
          group: test2
          user: u1
          version: v1
      timeouts:
        duplicate: 0
        inQdrop: 0
      trap:
        throttle_time: 12
      targets:
        - host: 1.1.1.2
          name: test

      ifmib:
        internal_cache_max_duration: 4
      inform:
        retries: 7
      chassis_id: test2
      packetsize: 490
      queue_length: 2
      throttle_time: 60
      trap_source: GigabitEthernet0/0/0/2
      trap_timeout: 3
      context:
        - c1
        - c2
      contact: t1
      correlator:
        buffer_size: 1024
      communities:
        - name: test2
          ro: true
          sdrowner: true
          acl_v4: test
          acl_v6: test1
      community_maps:
        - name: cm1
          context: c1
          target_list: t1
          security_name: s1
      drop:
        report_IPv4: test1
        unknown_user: true
      ipv6:
        precedence: routine
      ipv4:
        dscp: af11
      location: test1
      logging_threshold_oid_processing: 1
      logging_threshold_pdu_processing: 1
      mib_bulkstat_max_procmem_size: 101
      mroutemib_send_all_vrf: true
      overload_control:
        overload_drop_time: 4
        overload_throttle_rate: 6
      notification_log_mib:
        GlobalSize: 5
        size: 5
      traps:
        hsrp: true
        ipsla: true
        ipsec:
          start: true
          stop: true
        bridgemib: true
        bulkstat_collection: true
        cisco_entity_ext: true
        config: true
        copy_complete: true
        addrpool:
          high: true
          low: true
        bfd: true
        bgp:
          cbgp2: true
        l2tun:
          sessions: true
          tunnel_down: true
          tunnel_up: true
        l2vpn:
          all: true
          vc_down: true
          vc_up: true
        msdp_peer_state_change: true
  register: result
# Module Execution Result:
# ------------------------
# "rendered": [
#         "snmp-server chassis-id test2",
#         "snmp-server correlator buffer-size 1024",
#         "snmp-server contact t1",
#         "snmp-server ipv4 dscp af11",
#         "snmp-server ipv6 precedence routine",
#         "snmp-server location test1",
#         "snmp-server logging threshold oid-processing 1",
#         "snmp-server logging threshold pdu-processing 1",
#         "snmp-server mib bulkstat max-procmem-size 101",
#         "snmp-server mroutemib send-all-vrf",
#         "snmp-server overload-control 4 6",
#         "snmp-server packetsize 490",
#         "snmp-server queue-length 2",
#         "snmp-server throttle-time 60",
#         "snmp-server trap-source GigabitEthernet0/0/0/2",
#         "snmp-server trap-timeout 3",
#         "snmp-server drop report acl IPv4 test1",
#         "snmp-server drop unknown-user",
#         "snmp-server ifmib internal cache max-duration 4",
#         "snmp-server inform retries 7",
#         "snmp-server notification-log-mib size 5",
#         "snmp-server notification-log-mib GlobalSize 5",
#         "snmp-server trap throttle-time 12",
#         "snmp-server timeouts inQdrop 0",
#         "snmp-server timeouts duplicate 0",
#         "snmp-server traps addrpool low",
#         "snmp-server traps addrpool high",
#         "snmp-server traps bfd",
#         "snmp-server traps bgp cbgp2",
#         "snmp-server traps bulkstat collection",
#         "snmp-server traps bridgemib",
#         "snmp-server traps copy-complete",
#         "snmp-server traps cisco-entity-ext",
#         "snmp-server traps config",
#         "snmp-server traps hsrp",
#         "snmp-server traps ipsla",
#         "snmp-server traps ipsec tunnel start",
#         "snmp-server traps ipsec tunnel stop",
#         "snmp-server traps l2tun sessions",
#         "snmp-server traps l2tun tunnel-up",
#         "snmp-server traps l2tun tunnel-down",
#         "snmp-server traps l2vpn all",
#         "snmp-server traps l2vpn vc-up",
#         "snmp-server traps l2vpn vc-down",
#         "snmp-server traps msdp peer-state-change",
#         "snmp-server community test2 RO SDROwner IPv4 test IPv6 test1",
#         "snmp-server community-map cm1 context c1 security-name s1 target-list t1",
#         "snmp-server context c1",
#         "snmp-server context c2",
#         "snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2",
#         "snmp-server target list test2 vrf vrf2",
#         "snmp-server target list test host 1.1.1.2",
#         "snmp-server vrf vrf1",
#         "host 1.1.1.1 traps test1"
#     ],
# Using state: parsed
# File: parsed.cfg
# ----------------
# snmp-server vrf vrf1
#  host 1.1.1.1 traps test1
# !
# snmp-server drop report acl IPv4 test1
# snmp-server drop unknown-user
# snmp-server ipv4 dscp af11
# snmp-server ipv6 precedence routine
# snmp-server user u1 test2 v1 IPv4 test1 IPv6 test2
# snmp-server community test2 RO SDROwner IPv4 test IPv6 test1
# snmp-server queue-length 2
# snmp-server trap-timeout 3
# snmp-server trap throttle-time 12
# snmp-server traps bfd
# snmp-server traps bgp cbgp2
# snmp-server traps copy-complete
# snmp-server traps hsrp
# snmp-server traps ipsla
# snmp-server traps msdp peer-state-change
# snmp-server traps ipsec tunnel stop
# snmp-server traps ipsec tunnel start
# snmp-server traps config
# snmp-server traps l2tun sessions
# snmp-server traps l2tun tunnel-up
# snmp-server traps l2tun tunnel-down
# snmp-server traps bulkstat collection
# snmp-server traps l2vpn all
# snmp-server traps l2vpn vc-up
# snmp-server traps l2vpn vc-down
# snmp-server traps bridgemib
# snmp-server traps addrpool low
# snmp-server traps addrpool high
# snmp-server traps cisco-entity-ext
# snmp-server chassis-id test2
# snmp-server contact t1
# snmp-server location test1
# snmp-server target list test host 1.1.1.2
# snmp-server target list test2 vrf vrf2
# snmp-server context c1
# snmp-server context c2
# snmp-server logging threshold oid-processing 1
# snmp-server logging threshold pdu-processing 1
# snmp-server mib bulkstat max-procmem-size 101
# snmp-server timeouts duplicate 0
# snmp-server timeouts inQdrop 0
# snmp-server packetsize 490
# snmp-server correlator buffer-size 1024
# snmp-server trap-source GigabitEthernet0/0/0/2
# snmp-server throttle-time 60
# snmp-server community-map cm1 context c1 security-name s1 target-list t1
# snmp-server inform retries 7
# snmp-server overload-control 4 6
# snmp-server ifmib internal cache max-duration 4
# snmp-server mroutemib send-all-vrf
# snmp-server notification-log-mib size 5
# snmp-server notification-log-mib GlobalSize 5
# ------------
- name: Parse the provided configuration with the existing running configuration
  cisco.iosxr.iosxr_snmp_server:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed
# Module Execution Result:
# ------------------------
# "parsed":{
#         "chassis_id": "test2",
#         "communities": [
#             {
#                 "acl_v4": "test",
#                 "acl_v6": "test1",
#                 "name": "test2",
#                 "ro": true,
#                 "sdrowner": true
#             }
#         ],
#         "community_maps": [
#             {
#                 "context": "c1",
#                 "name": "cm1",
#                 "security_name": "s1",
#                 "target_list": "t1"
#             }
#         ],
#         "contact": "t1",
#         "context": [
#             "c1",
#             "c2"
#         ],
#         "correlator": {
#             "buffer_size": 1024
#         },
#         "drop": {
#             "report_IPv4": "test1",
#             "unknown_user": true
#         },
#         "ifmib": {
#             "internal_cache_max_duration": 4
#         },
#         "inform": {
#             "retries": 7
#         },
#         "ipv4": {
#             "dscp": "af11"
#         },
#         "ipv6": {
#             "precedence": "routine"
#         },
#         "location": "test1",
#         "logging_threshold_oid_processing": 1,
#         "logging_threshold_pdu_processing": 1,
#         "mib_bulkstat_max_procmem_size": 101,
#         "mroutemib_send_all_vrf": true,
#         "notification_log_mib": {
#             "GlobalSize": 5,
#             "size": 5
#         },
#         "overload_control": {
#             "overload_drop_time": 4,
#             "overload_throttle_rate": 6
#         },
#         "packetsize": 490,
#         "queue_length": 2,
#         "targets": [
#             {
#                 "host": "1.1.1.2",
#                 "name": "test"
#             },
#             {
#                 "name": "test2",
#                 "vrf": "vrf2"
#             }
#         ],
#         "throttle_time": 60,
#         "timeouts": {
#             "duplicate": 0,
#             "inQdrop": 0
#         },
#         "trap": {
#             "throttle_time": 12
#         },
#         "trap_source": "GigabitEthernet0/0/0/2",
#         "trap_timeout": 3,
#         "traps": {
#             "addrpool": {
#                 "high": true,
#                 "low": true
#             },
#             "bfd": true,
#             "bgp": {
#                 "cbgp2": true
#             },
#             "bridgemib": true,
#             "bulkstat_collection": true,
#             "cisco_entity_ext": true,
#             "config": true,
#             "copy_complete": true,
#             "hsrp": true,
#             "ipsec": {
#                 "start": true,
#                 "stop": true
#             },
#             "ipsla": true,
#             "l2tun": {
#                 "sessions": true,
#                 "tunnel_down": true,
#                 "tunnel_up": true
#             },
#             "l2vpn": {
#                 "all": true,
#                 "vc_down": true,
#                 "vc_up": true
#             },
#             "msdp_peer_state_change": true
#         },
#         "users": [
#             {
#                 "Ipv4_acl": "test1",
#                 "Ipv6_acl": "test2",
#                 "group": "test2",
#                 "user": "u1",
#                 "version": "v1"
#             }
#         ],
#         "vrfs": [
#             {
#                 "hosts": [
#                     {
#                         "community": "test1",
#                         "host": "1.1.1.1",
#                         "traps": true
#                     }
#                 ],
#                 "vrf": "vrf1"
#             }
#         ]
#     }

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

after

dictionary

The resulting configuration after module execution.

Returned: when changed

Sample: “This output will always be in the same format as the module argspec.\n”

before

dictionary

The configuration prior to the module execution.

Returned: when state is merged, replaced, overridden, deleted or purged

Sample: “This output will always be in the same format as the module argspec.\n”

commands

list / elements=string

The set of commands pushed to the remote device.

Returned: when state is merged, replaced, overridden, deleted or purged

Sample: [“sample command 1”, “sample command 2”, “sample command 3”]

gathered

list / elements=string

Facts about the network resource gathered from the remote device as structured data.

Returned: when state is gathered

Sample: “This output will always be in the same format as the module argspec.\n”

parsed

list / elements=string

The device native config provided in running_config option parsed into structured data as per module argspec.

Returned: when state is parsed

Sample: “This output will always be in the same format as the module argspec.\n”

rendered

list / elements=string

The provided configuration in the task rendered in device-native format (offline).

Returned: when state is rendered

Sample: [“sample command 1”, “sample command 2”, “sample command 3”]

Authors

  • Ashwini Mhatre (@amhatre)