Skip to content

Latest commit

 

History

History
4474 lines (4374 loc) · 188 KB

cisco.nxos.nxos_snmp_server_module.rst

File metadata and controls

4474 lines (4374 loc) · 188 KB

cisco.nxos.nxos_snmp_server

SNMP Server resource module.

Version added: 2.8.0

  • This module manages SNMP server configuration on devices running Cisco NX-OS.
Parameter Choices/Defaults Comments
config
dictionary
A dict of SNMP server configuration
aaa_user
dictionary
Set duration for which aaa-cached snmp user exists.
cache_timeout
integer
Timeout for which aaa-cached user exists(in secs).
communities
list / elements=dictionary
Set community string and access privs.
group
string
Group to which the community belongs.
name
string
SNMP community string (Max Size 32).

aliases: community
ro
boolean
    Choices:
  • no
  • yes
Read-only access with this community string.
rw
boolean
    Choices:
  • no
  • yes
Read-write access with this community string.
use_ipv4acl
string
Specify IPv4 ACL, the ACL name specified must be IPv4 ACL.
This option is unsupported on MDS switches.
use_ipv6acl
string
Specify IPv6 ACL, the ACL name specified after must be IPv6 ACL.
This option is unsupported on MDS switches.
contact
string
Modify sysContact.
context
dictionary
SNMP context to be mapped.
instance
string
Name of the protocol instance (Max Size 32).
name
string
Name of the SNMP context (Max Size 32).
topology
string
Topology associated with the SNMP context.
vrf
string
VRF associated with the SNMP context.
This option is unsupported on MDS switches.
counter
dictionary
Configure port counter configuration.
This option is unsupported on MDS switches.
cache
dictionary
Port stats cache.
enable
boolean
    Choices:
  • no
  • yes
Enable port stats cache.
timeout
integer
Timeout for which cached port stats exists(in secs).
drop
dictionary
Silently drop unknown v3 user packets.
This option is unsupported on MDS switches.
unknown_engine_id
boolean
    Choices:
  • no
  • yes
Unknown v3 engine id.
unknown_user
boolean
    Choices:
  • no
  • yes
Unknown v3 user.
engine_id
dictionary
Configure a local SNMPv3 engineID.
This option is unsupported on MDS switches.
local
string
EngineID of the local agent.
global_enforce_priv
boolean
    Choices:
  • no
  • yes
Globally enforce privacy for all the users.
hosts
list / elements=dictionary
Specify hosts to receive SNMP notifications.
SNMP hosts config lines that appear separately in running-config must be added as individual dictionaries.
auth
string
Use the SNMPv3 authNoPriv Security Level.
community
string
SNMP community string or SNMPv3 user name (Max Size 32).
filter_vrf
string
Filters notifications to the notification host receiver based on the configured VRF.
This option is unsupported on MDS switches.
host
string
IPv4 or IPv6 address or DNS Name of SNMP notification host.
informs
boolean
    Choices:
  • no
  • yes
Send Inform messages to this host.
priv
string
Use the SNMPv3 authPriv Security Level.
source_interface
string
Source interface to be used for sending out SNMP notifications to this host.
traps
boolean
    Choices:
  • no
  • yes
Send Traps messages to this host.
udp_port
integer
The notification host's UDP port number.
use_vrf
string
Configures SNMP to use the selected VRF to communicate with the host receiver.
This option is unsupported on MDS switches.
version
string
    Choices:
  • 1
  • 2c
  • 3
SNMP version to use for notification messages.
location
string
Modify sysLocation.
mib
dictionary
Mib access parameters.
community_map
dictionary
SNMP community.
community
string
SNMP community string (Max Size 32).
context
string
Name of the SNMP context (Max Size 32).
packetsize
integer
Largest SNMP packet size
protocol
dictionary
Snmp protocol operations.
enable
boolean
    Choices:
  • no
  • yes
Enable/Disable snmp protocol operations.
source_interface
dictionary
Source interface to be used for sending out SNMP notifications.
This option is unsupported on MDS switches.
informs
string
SNMP Inform notifications for which this source interface needs to be used.
traps
string
SNMP Trap notifications for which this source interface needs to be used.
system_shutdown
boolean
    Choices:
  • no
  • yes
Configure snmp-server for reload(2).
tcp_session
dictionary
Enable one time authentication for snmp over tcp session.
auth
boolean
    Choices:
  • no
  • yes
Enable one time authentication for snmp over tcp session.
enable
boolean
    Choices:
  • no
  • yes
Enable tcp-session.
This option is unsupported on MDS switches.
traps
dictionary
Enable SNMP Traps
aaa
dictionary
AAA traps
enable
boolean
    Choices:
  • no
  • yes
Enable AAA traps.
server_state_change
boolean
    Choices:
  • no
  • yes
AAA server state change notification.
bgp
dictionary
SNMP BGP traps.
enable
boolean
    Choices:
  • no
  • yes
Enable SNMP BGP traps.
bridge
dictionary
Bridge traps.
This option is unsupported on MDS switches.
enable
boolean
    Choices:
  • no
  • yes
Enable bridge traps.
newroot
boolean
    Choices:
  • no
  • yes
Enable SNMP STP Bridge MIB newroot traps.
topologychange
boolean
    Choices:
  • no
  • yes
Enable SNMP STP Bridge MIB topologychange traps.
callhome
dictionary
Callhome traps.
enable
boolean
    Choices:
  • no
  • yes
Enable callhome traps.
This option is unsupported on MDS switches.
event_notify
boolean
    Choices:
  • no
  • yes
Callhome External Event Notification.
smtp_send_fail
boolean
    Choices:
  • no
  • yes
SMTP Message Send Fail notification.
cfs
dictionary
CFS traps.
enable
boolean
    Choices:
  • no
  • yes
Enable cfs traps.
This option is unsupported on MDS switches.
merge_failure
boolean
    Choices:
  • no
  • yes
Merge failure notification.
state_change_notif
boolean
    Choices:
  • no
  • yes
State change notification.
config
dictionary
Config traps.
ccmCLIRunningConfigChanged
boolean
    Choices:
  • no
  • yes
Running config change trap.
enable
boolean
    Choices:
  • no
  • yes
Enable config traps.
This option is unsupported on MDS switches.
entity
dictionary
Entity traps.
cefcMIBEnableStatusNotification
boolean
    Choices:
  • no
  • yes
CefcMIBEnableStatusNotification.
enable
boolean
    Choices:
  • no
  • yes
Enable entity traps.
entity_fan_status_change
boolean
    Choices:
  • no
  • yes
Entity Fan Status Change.
entity_mib_change
boolean
    Choices:
  • no
  • yes
Entity MIB change.
entity_module_inserted
boolean
    Choices:
  • no
  • yes
Entity Module Inserted.
entity_module_removed
boolean
    Choices:
  • no
  • yes
Entity Module Removed.
entity_module_status_change
boolean
    Choices:
  • no
  • yes
Entity Module Status Change.
entity_power_out_change
boolean
    Choices:
  • no
  • yes
Entity Power Out Change.
entity_power_status_change
boolean
    Choices:
  • no
  • yes
Entity Power Status Change.
entity_sensor
boolean
    Choices:
  • no
  • yes
Entity sensor.
entity_unrecognised_module
boolean
    Choices:
  • no
  • yes
Entity Unrecognised Module.
feature_control
dictionary
Feature-Control traps.
ciscoFeatOpStatusChange
boolean
    Choices:
  • no
  • yes
Feature operation status change Notification.
enable
boolean
    Choices:
  • no
  • yes
Enable feature-control traps.
This option is unsupported on MDS switches.
featureOpStatusChange
boolean
    Choices:
  • no
  • yes
Feature operation status change notification.
generic
dictionary
Generic traps.
coldStart
boolean
    Choices:
  • no
  • yes
Generic coldStart trap.
enable
boolean
    Choices:
  • no
  • yes
Enable generic traps.
This option is unsupported on MDS switches.
warmStart
boolean
    Choices:
  • no
  • yes
Generic warmStart trap.
license
dictionary
License traps.
enable
boolean
    Choices:
  • no
  • yes
Enable license traps.
This option is unsupported on MDS switches.
notify_license_expiry
boolean
    Choices:
  • no
  • yes
License Expiry Notification.
notify_license_expiry_warning
boolean
    Choices:
  • no
  • yes
License Expiry Warning Notification.
notify_licensefile_missing
boolean
    Choices:
  • no
  • yes
License File Missing Notification.
notify_no_license_for_feature
boolean
    Choices:
  • no
  • yes
No License installed for feature Notification.
link
dictionary
Link traps.
cErrDisableInterfaceEventRev1
boolean
    Choices:
  • no
  • yes
Err-disable state notification.
This option is unsupported on MDS switches.
cieLinkDown
boolean
    Choices:
  • no
  • yes
Cisco extended link state down notification.
cieLinkUp
boolean
    Choices:
  • no
  • yes
Cisco extended link state up notification.
cisco_xcvr_mon_status_chg
boolean
    Choices:
  • no
  • yes
Cisco interface transceiver monitor status change notification.
cmn_mac_move_notification
boolean
    Choices:
  • no
  • yes
Mac addr move trap.
This option is unsupported on MDS switches.
delayed_link_state_change
boolean
    Choices:
  • no
  • yes
Delayed link state change.
enable
boolean
    Choices:
  • no
  • yes
Enable link traps.
This option is unsupported on MDS switches.
extended_linkDown
boolean
    Choices:
  • no
  • yes
IETF extended link state down notification.
extended_linkUp
boolean
    Choices:
  • no
  • yes
IETF extended link state up notification.
linkDown
boolean
    Choices:
  • no
  • yes
IETF Link state down notification.
linkUp
boolean
    Choices:
  • no
  • yes
IETF Link state up notification.
mmode
dictionary
MMode traps.
This option is unsupported on MDS switches.
cseMaintModeChangeNotify
boolean
    Choices:
  • no
  • yes
Maint Mode Change Notification.
cseNormalModeChangeNotify
boolean
    Choices:
  • no
  • yes
Normal Mode Change Notification.
enable
boolean
    Choices:
  • no
  • yes
Enable mmode traps.
ospf
dictionary
SNMP OSPF traps.
enable
boolean
    Choices:
  • no
  • yes
Enable SNMP OSPF traps.
ospfv3
dictionary
SNMP OSPFv3 traps.
enable
boolean
    Choices:
  • no
  • yes
Enable SNMP OSPFv3 traps.
rf
dictionary
RF traps.
enable
boolean
    Choices:
  • no
  • yes
Enable rf traps.
This option is unsupported on MDS switches.
redundancy_framework
boolean
    Choices:
  • no
  • yes
Redundancy_Framework (RF) Sup switchover MIB.
rmon
dictionary
RMON traps.
enable
boolean
    Choices:
  • no
  • yes
Enable rmon traps.
This option is unsupported on MDS switches.
fallingAlarm
boolean
    Choices:
  • no
  • yes
Rmon falling alarm.
hcFallingAlarm
boolean
    Choices:
  • no
  • yes
High capacity Rmon falling alarm.
hcRisingAlarm
boolean
    Choices:
  • no
  • yes
High capacity Rmon rising alarm.
risingAlarm
boolean
    Choices:
  • no
  • yes
Rmon rising alarm.
snmp
dictionary
SNMP traps.
authentication
boolean
    Choices:
  • no
  • yes
SNMP authentication trap.
enable
boolean
    Choices:
  • no
  • yes
Enable snmp traps.
This option is unsupported on MDS switches.
storm_control
dictionary
Storm-Control traps.
cpscEventRev1
boolean
    Choices:
  • no
  • yes
Port-Storm-Control-Event.
This option is unsupported on MDS switches.
enable
boolean
    Choices:
  • no
  • yes
Enable storm-control traps.
This option is unsupported on MDS switches.
trap_rate
boolean
    Choices:
  • no
  • yes
Number of traps per minute.
stpx
dictionary
Stpx traps.
This option is unsupported on MDS switches.
enable
boolean
    Choices:
  • no
  • yes
Enable stpx traps.
inconsistency
boolean
    Choices:
  • no
  • yes
Enable SNMP STPX MIB InconsistencyUpdate traps.
loop_inconsistency
boolean
    Choices:
  • no
  • yes
Enable SNMP STPX MIB LoopInconsistencyUpdate traps.
root_inconsistency
boolean
    Choices:
  • no
  • yes
Enable SNMP STPX MIB RootInconsistencyUpdate traps.
syslog
dictionary
Enable syslog traps.
enable
boolean
    Choices:
  • no
  • yes
Enable syslog traps.
This option is unsupported on MDS switches.
message_generated
boolean
    Choices:
  • no
  • yes
Message Generated Notification.
sysmgr
dictionary
Sysmgr traps.
cseFailSwCoreNotifyExtended
boolean
    Choices:
  • no
  • yes
Software Core Notification.
enable
boolean
    Choices:
  • no
  • yes
Enable sysmgr traps.
This option is unsupported on MDS switches.
system
dictionary
System traps.
clock_change_notification
boolean
    Choices:
  • no
  • yes
Clock-change-notification traps.
enable
boolean
    Choices:
  • no
  • yes
Enable system traps.
This option is unsupported on MDS switches.
upgrade
dictionary
Upgrade traps.
enable
boolean
    Choices:
  • no
  • yes
Enable upgrade traps.
This option is unsupported on MDS switches.
upgradeJobStatusNotify
boolean
    Choices:
  • no
  • yes
Upgrade Job Status Notification.
upgradeOpNotifyOnCompletion
boolean
    Choices:
  • no
  • yes
Upgrade Global Status Notification.
vtp
dictionary
VTP traps.
This option is unsupported on MDS switches.
enable
boolean
    Choices:
  • no
  • yes
Enable VTP traps.
notifs
boolean
    Choices:
  • no
  • yes
Enable vtpConfigRevNumberError vtpConfigDigestEnable vtpConfigRevNumberError vtpConfigDigestError vtpServerDisabled vtpVersionOneDeviceDetected vlanTrunkPortDynamicStatusChange vtpLocalModeChanged vtpVersionInUseChanged notification.
vlancreate
boolean
    Choices:
  • no
  • yes
Enable vtpVlanCreated notification.
vlandelete
boolean
    Choices:
  • no
  • yes
Enable vtpVlanDeleted notification.
users
dictionary
Define users who can access the SNMP engine.
auth
list / elements=dictionary
SNMP User authentication related settings
authentication
dictionary
Authentication parameters for the user.
algorithm
string
    Choices:
  • md5
  • sha
  • sha-256
Select algorithm for authentication.
engine_id
string
EngineID for configuring notif target user (for V3 informs).
This value needs to be enclosed in quotes in the task.
localized_key
boolean
    Choices:
  • no
  • yes
Specifies whether the passwords are in localized key format.
localizedv2_key
boolean
    Choices:
  • no
  • yes
Specifies whether the passwords are in localized V2 key format.
password
string
Authentication password for user (Max Size 127).
If this value is localized, it has to be enclosed in quotes in the task.
priv
dictionary
Encryption parameters for the user.
aes_128
boolean
    Choices:
  • no
  • yes
Use 128-bit AES algorithm for privacy.
privacy_password
string
Privacy password for user (Max Size 130).
If this value is localized, it has to be enclosed in quotes in the task.
group
string
Group name (ignored for notif target user) (Max Size 28).
user
string
Name of the user (Max Size 28).
use_acls
list / elements=dictionary
Set IPv4 and IPv6 ACL to use.
ipv4
string
Specify IPv4 ACL, the ACL name specified after must be IPv4 ACL.
ipv6
string
Specify IPv6 ACL, the ACL name specified after must be IPv6 ACL.
user
string
Name of the user (Max Size 28).
running_config
string
This option is used only with state parsed.
The value of this option should be the output received from the NX-OS device by executing the command show running-config | section '^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
    Choices:
  • merged ←
  • replaced
  • overridden
  • deleted
  • parsed
  • gathered
  • rendered
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.

Note

  • Tested against NX-OS 9.3.6 on Cisco Nexus Switches.
  • This module works with connection network_cli and httpapi.
  • Tested against Cisco MDS NX-OS 9.2(2) with connection network_cli.
# Using merged

# Before state:
# -------------
# nxos-9k-rdo# show running-config | section "^snmp-server"
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey

- name: Merge the provided configuration with the existing running configuration
  cisco.nxos.nxos_snmp_server:
    config:
      aaa_user:
        cache_timeout: 36000
      communities:
        - community: public
          group: network-operator
        - community: private
          group: network-admin
      contact: nxosswitchadmin@localhost
      location: serverroom-1
      traps:
        aaa:
          server_state_change: true
        system:
          clock_change_notification: true
      hosts:
        - host: 192.0.2.1
          traps: true
          version: '1'
          community: public
        - host: 192.0.2.1
          source_interface: Ethernet1/1
        - host: 192.0.2.2
          informs: true
          version: '3'
          auth: NMS
      users:
        auth:
          - user: snmp_user_1
            group: network-operator
            authentication:
              algorithm: md5
              password: '0x5632724fb8ac3699296af26281e1d0f1'
              localized_key: true
          - user: snmp_user_2
            group: network-operator
            authentication:
              algorithm: md5
              password: '0x5632724fb8ac3699296af26281e1d0f1'
              localized_key: true
              priv:
                privacy_password: '0x5632724fb8ac3699296af26281e1d0f1'
                aes_128: true
        use_acls:
          - user: snmp_user_1
            ipv4: acl1
            ipv6: acl2
          - user: snmp_user_2
            ipv4: acl3
            ipv6: acl4

# Task output
# -------------
# before:
#   users:
#     auth:
#       - user: admin
#         group: network-admin
#         authentication:
#           algorithm: md5
#           password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
#           localized_key: true
#           priv:
#             privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
#
# commands:
#   - snmp-server contact nxosswitchadmin@localhost
#   - snmp-server location serverroom-1
#   - snmp-server aaa-user cache-timeout 36000
#   - snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
#   - snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
#   - snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2
#   - snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4
#   - snmp-server host 192.0.2.1 traps version 1 public
#   - snmp-server host 192.0.2.1 source-interface Ethernet1/1
#   - snmp-server host 192.0.2.2 informs version 3 auth NMS
#   - snmp-server community private group network-admin
#   - snmp-server community public group network-operator
#   - snmp-server enable traps aaa server-state-change
#   - snmp-server enable traps system Clock-change-notification
#
# after:
#   aaa_user:
#      cache_timeout: 36000
#    communities:
#      - community: private
#        group: network-admin
#      - community: public
#        group: network-operator
#    contact: nxosswitchadmin@localhost
#    location: serverroom-1
#    traps:
#      aaa:
#        server_state_change: true
#      system:
#        clock_change_notification: true
#    hosts:
#      - host: 192.0.2.1
#        traps: true
#        version: "1"
#        community: public
#
#      - host: 192.0.2.1
#        source_interface: Ethernet1/1
#
#      - host: 192.0.2.2
#        informs: true
#        version: "3"
#        auth: NMS
#    users:
#      auth:
#        - user: admin
#          group: network-admin
#          authentication:
#            algorithm: md5
#            password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
#            localized_key: true
#            priv:
#              privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
#
#        - user: snmp_user_1
#          group: network-operator
#          authentication:
#            algorithm: md5
#            password: "0x5632724fb8ac3699296af26281e1d0f1"
#            localized_key: true
#
#        - authentication:
#            algorithm: md5
#            localized_key: true
#            password: "0x5632724fb8ac3699296af26281e1d0f1"
#            priv:
#              aes_128: true
#              privacy_password: "0x5632724fb8ac3699296af26281e1d0f1"
#          group: network-operator
#          user: snmp_user_2
#
#      use_acls:
#        - user: snmp_user_1
#          ipv4: acl1
#          ipv6: acl2
#        - user: snmp_user_2
#          ipv4: acl3
#          ipv6: acl4

# After state:
# ------------
# nxos-9k-rdo# show running-config | section "^snmp-server"
# snmp-server contact nxosswitchadmin@localhost
# snmp-server location serverroom-1
# snmp-server aaa-user cache-timeout 36000
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey
# snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
# snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
# snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2
# snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4
# snmp-server host 192.0.2.1 traps version 1 public
# snmp-server host 192.0.2.1 source-interface Ethernet1/1
# snmp-server host 192.0.2.2 informs version 3 auth NMS
# snmp-server community private group network-admin
# snmp-server community public group network-operator
# snmp-server enable traps aaa server-state-change
# snmp-server enable traps system Clock-change-notification

# Using replaced

# Before state:
# ------------
# nxos-9k-rdo# show running-config | section "^snmp-server"
# snmp-server contact nxosswitchadmin@localhost
# snmp-server location serverroom-1
# snmp-server aaa-user cache-timeout 36000
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey
# snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
# snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
# snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2
# snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4
# snmp-server host 192.0.2.1 traps version 1 public
# snmp-server host 192.0.2.1 source-interface Ethernet1/1
# snmp-server host 192.0.2.2 informs version 3 auth NMS
# snmp-server community private group network-admin
# snmp-server community public group network-operator
# snmp-server enable traps aaa server-state-change
# snmp-server enable traps system Clock-change-notification

- name: Replace snmp-server configurations of listed snmp-server with provided configurations
  cisco.nxos.nxos_snmp_server:
    config:
      aaa_user:
        cache_timeout: 36000
      communities:
        - community: public
          group: network-operator
        - community: secret
          group: network-operator
      contact: nxosswitchadmin2@localhost
      location: serverroom-2
      traps:
        aaa:
          server_state_change: true
      hosts:
        - host: 192.0.2.1
          traps: true
          version: '1'
          community: public
        - host: 192.0.2.1
          source_interface: Ethernet1/1
        - host: 192.0.3.2
          informs: true
          version: '3'
          auth: NMS
      users:
        auth:
          - user: admin
            group: network-admin
            authentication:
              algorithm: md5
              password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
              localized_key: true
              priv:
                privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"

          - user: snmp_user_1
            group: network-operator
            authentication:
              algorithm: md5
              password: '0x5632724fb8ac3699296af26281e1d0f1'
              localized_key: true

          - user: snmp_user_2
            group: network-operator
            authentication:
              algorithm: md5
              password: '0x5632724fb8ac3699296af26281e1d0f1'
              localized_key: true
              priv:
                privacy_password: '0x5632724fb8ac3699296af26281e1d0f1'
                aes_128: true
        use_acls:
          - user: snmp_user_1
            ipv4: acl1
            ipv6: acl2
    state: replaced

# Task output
# -------------
# before:
#   aaa_user:
#      cache_timeout: 36000
#    communities:
#      - community: private
#        group: network-admin
#      - community: public
#        group: network-operator
#    contact: nxosswitchadmin@localhost
#    location: serverroom-1
#    traps:
#      aaa:
#        server_state_change: true
#      system:
#        clock_change_notification: true
#    hosts:
#      - host: 192.0.2.1
#        traps: true
#        version: "1"
#        community: public
#
#      - host: 192.0.2.1
#        source_interface: Ethernet1/1
#
#      - host: 192.0.2.2
#        informs: true
#        version: "3"
#        auth: NMS
#    users:
#      auth:
#        - user: admin
#          group: network-admin
#          authentication:
#            algorithm: md5
#            password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
#            localized_key: true
#            priv:
#              privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
#
#        - user: snmp_user_1
#          group: network-operator
#          authentication:
#            algorithm: md5
#            password: "0x5632724fb8ac3699296af26281e1d0f1"
#            localized_key: true
#
#        - authentication:
#            algorithm: md5
#            localized_key: true
#            password: "0x5632724fb8ac3699296af26281e1d0f1"
#            priv:
#              aes_128: true
#              privacy_password: "0x5632724fb8ac3699296af26281e1d0f1"
#          group: network-operator
#          user: snmp_user_2
#
#      use_acls:
#        - user: snmp_user_1
#          ipv4: acl1
#          ipv6: acl2
#        - user: snmp_user_2
#          ipv4: acl3
#          ipv6: acl4
#
# commands:
#   - snmp-server contact nxosswitchadmin2@localhost
#   - no snmp-server enable traps system Clock-change-notification
#   - snmp-server location serverroom-2
#   - no snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4
#   - no snmp-server host 192.0.2.2 informs version 3 auth NMS
#   - snmp-server host 192.0.3.2 informs version 3 auth NMS
#   - no snmp-server community private group network-admin
#   - snmp-server community secret group network-operator
#
# after:
#   aaa_user:
#      cache_timeout: 36000
#    communities:
#      - community: public
#        group: network-operator
#      - community: secret
#        group: network-operator
#    contact: nxosswitchadmin2@localhost
#    location: serverroom-2
#    traps:
#      aaa:
#        server_state_change: true
#    hosts:
#      - host: 192.0.2.1
#        traps: true
#        version: '1'
#        community: public
#      - host: 192.0.2.1
#        source_interface: Ethernet1/1
#      - host: 192.0.3.2
#        informs: true
#        version: '3'
#        auth: NMS
#    users:
#      auth:
#        - user: admin
#          group: network-admin
#          authentication:
#            algorithm: md5
#            password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
#            localized_key: true
#            priv:
#              privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
#
#        - user: snmp_user_1
#          group: network-operator
#          authentication:
#            algorithm: md5
#            password: '0x5632724fb8ac3699296af26281e1d0f1'
#            localized_key: true
#
#        - user: snmp_user_2
#          group: network-operator
#          authentication:
#            algorithm: md5
#            password: '0x5632724fb8ac3699296af26281e1d0f1'
#            localized_key: true
#            priv:
#              privacy_password: '0x5632724fb8ac3699296af26281e1d0f1'
#              aes_128: true
#
#      use_acls:
#        - user: snmp_user_1
#          ipv4: acl1
#          ipv6: acl2
#

# After state:
# ------------
# nxos-9k-rdo# show running-config | section "^snmp-server"
# snmp-server contact nxosswitchadmin2@localhost
# snmp-server location serverroom-2
# snmp-server aaa-user cache-timeout 36000
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey
# snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
# snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
# snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2
# snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4
# snmp-server host 192.0.2.1 traps version 1 public
# snmp-server host 192.0.2.1 source-interface Ethernet1/1
# snmp-server host 192.0.2.2 informs version 3 auth NMS
# snmp-server community secret group network-operator
# snmp-server community public group network-operator
# snmp-server enable traps aaa server-state-change
# snmp-server enable traps system Clock-change-notification

# Using deleted

# Before state:
# ------------
# nxos-9k-rdo# show running-config | section "^snmp-server"
# snmp-server contact nxosswitchadmin@localhost
# snmp-server location serverroom-1
# snmp-server aaa-user cache-timeout 36000
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey
# snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
# snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
# snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2
# snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4
# snmp-server host 192.0.2.1 traps version 1 public
# snmp-server host 192.0.2.1 source-interface Ethernet1/1
# snmp-server host 192.0.2.2 informs version 3 auth NMS
# snmp-server community private group network-admin
# snmp-server community public group network-operator
# snmp-server enable traps aaa server-state-change
# snmp-server enable traps system Clock-change-notification

- name: Delete SNMP Server configurations from the device (admin user will not be deleted)
  cisco.nxos.nxos_snmp_server:
    state: deleted

# Task output
# -------------
# before:
#   aaa_user:
#      cache_timeout: 36000
#    communities:
#      - community: private
#        group: network-admin
#      - community: public
#        group: network-operator
#    contact: nxosswitchadmin@localhost
#    location: serverroom-1
#    traps:
#      aaa:
#        server_state_change: true
#      system:
#        clock_change_notification: true
#    hosts:
#      - host: 192.0.2.1
#        traps: true
#        version: "1"
#        community: public
#
#      - host: 192.0.2.1
#        source_interface: Ethernet1/1
#
#      - host: 192.0.2.2
#        informs: true
#        version: "3"
#        auth: NMS
#    users:
#      auth:
#        - user: admin
#          group: network-admin
#          authentication:
#            algorithm: md5
#            password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
#            localized_key: true
#            priv:
#              privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
#
#        - user: snmp_user_1
#          group: network-operator
#          authentication:
#            algorithm: md5
#            password: "0x5632724fb8ac3699296af26281e1d0f1"
#            localized_key: true
#
#        - authentication:
#            algorithm: md5
#            localized_key: true
#            password: "0x5632724fb8ac3699296af26281e1d0f1"
#            priv:
#              aes_128: true
#              privacy_password: "0x5632724fb8ac3699296af26281e1d0f1"
#          group: network-operator
#          user: snmp_user_2
#
#      use_acls:
#        - user: snmp_user_1
#          ipv4: acl1
#          ipv6: acl2
#        - user: snmp_user_2
#          ipv4: acl3
#          ipv6: acl4
#
# commands:
#   - no snmp-server contact nxosswitchadmin@localhost
#   - no snmp-server location serverroom-1
#   - no snmp-server aaa-user cache-timeout 36000
#   - no snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey
#   - no snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
#   - no snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
#   - no snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2
#   - no snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4
#   - no snmp-server host 192.0.2.1 traps version 1 public
#   - no snmp-server host 192.0.2.1 source-interface Ethernet1/1
#   - no snmp-server host 192.0.2.2 informs version 3 auth NMS
#   - no snmp-server community private group network-admin
#   - no snmp-server community public group network-operator
#   - no snmp-server enable traps aaa server-state-change
#   - no snmp-server enable traps system Clock-change-notification
#
# after:
#   users:
#     auth:
#       - user: admin
#         group: network-admin
#         authentication:
#           algorithm: md5
#           password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"
#           localized_key: true
#           priv:
#             privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9"

# After state:
# ------------
# nxos-9k-rdo# show running-config | section "^snmp-server"
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey

# Using rendered
# ---------------

- name: Render platform specific configuration lines with state rendered (without connecting to the device)
  cisco.nxos.nxos_snmp_server:
    config:
      aaa_user:
        cache_timeout: 36000
      communities:
        - community: public
          group: network-operator
        - community: private
          group: network-admin
      contact: nxosswitchadmin@localhost
      location: serverroom-1
      traps:
        aaa:
          server_state_change: true
        system:
          clock_change_notification: true
      hosts:
        - host: 192.0.2.1
          traps: true
          version: '1'
          community: public
        - host: 192.0.2.1
          source_interface: Ethernet1/1
        - host: 192.0.2.2
          informs: true
          version: '3'
          auth: NMS
      users:
        auth:
          - user: snmp_user_1
            group: network-operator
            authentication:
              algorithm: md5
              password: '0x5632724fb8ac3699296af26281e1d0f1'
              localized_key: true
          - user: snmp_user_2
            group: network-operator
            authentication:
              algorithm: md5
              password: '0x5632724fb8ac3699296af26281e1d0f1'
              localized_key: true
              priv:
                privacy_password: '0x5632724fb8ac3699296af26281e1d0f1'
                aes_128: true
        use_acls:
          - user: snmp_user_1
            ipv4: acl1
            ipv6: acl2
          - user: snmp_user_2
            ipv4: acl3
            ipv6: acl4
    state: rendered


# Task Output (redacted)
# -----------------------
#  rendered:
#    - snmp-server contact nxosswitchadmin@localhost
#    - snmp-server location serverroom-1
#    - snmp-server aaa-user cache-timeout 36000
#    - snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
#    - snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
#    - snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2
#    - snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4
#    - snmp-server host 192.0.2.1 traps version 1 public
#    - snmp-server host 192.0.2.1 source-interface Ethernet1/1
#    - snmp-server host 192.0.2.2 informs version 3 auth NMS
#    - snmp-server community private group network-admin
#    - snmp-server community public group network-operator
#    - snmp-server enable traps aaa server-state-change
#    - snmp-server enable traps system Clock-change-notification

# Using parsed

# parsed.cfg
# ------------
# snmp-server contact nxosswitchadmin@localhost
# snmp-server location serverroom-1
# snmp-server aaa-user cache-timeout 36000
# snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
# snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey
# snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2
# snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4
# snmp-server host 192.0.2.1 traps version 1 public
# snmp-server host 192.0.2.1 source-interface Ethernet1/1
# snmp-server host 192.0.2.2 informs version 3 auth NMS
# snmp-server community private group network-admin
# snmp-server community public group network-operator
# snmp-server enable traps aaa server-state-change
# snmp-server enable traps system Clock-change-notification

- name: Parse externally provided snmp-server configuration
  cisco.nxos.nxos_snmp_server:
    running_config: "{{ lookup('file', './parsed.cfg') }}"
    state: parsed

# Task output (redacted)
# -----------------------
#  parsed:
#   aaa_user:
#      cache_timeout: 36000
#    communities:
#      - community: private
#        group: network-admin
#      - community: public
#        group: network-operator
#    contact: nxosswitchadmin@localhost
#    location: serverroom-1
#    traps:
#      aaa:
#        server_state_change: true
#      system:
#        clock_change_notification: true
#    hosts:
#      - host: 192.0.2.1
#        traps: true
#        version: "1"
#        community: public
#
#      - host: 192.0.2.1
#        source_interface: Ethernet1/1
#
#      - host: 192.0.2.2
#        informs: true
#        version: "3"
#        auth: NMS
#    users:
#      auth:
#        - user: snmp_user_1
#          group: network-operator
#          authentication:
#            algorithm: md5
#            password: "0x5632724fb8ac3699296af26281e1d0f1"
#            localized_key: true
#
#        - authentication:
#            algorithm: md5
#            localized_key: true
#            password: "0x5632724fb8ac3699296af26281e1d0f1"
#            priv:
#              aes_128: true
#              privacy_password: "0x5632724fb8ac3699296af26281e1d0f1"
#          group: network-operator
#          user: snmp_user_2
#
#      use_acls:
#        - user: snmp_user_1
#          ipv4: acl1
#          ipv6: acl2
#        - user: snmp_user_2
#          ipv4: acl3
#          ipv6: acl4
#

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

Key Returned Description
after
dictionary
when changed
The resulting configuration after module execution.

Sample:
This output will always be in the same format as the module argspec.
before
dictionary
when state is merged, replaced, overridden, deleted or purged
The configuration prior to the module execution.

Sample:
This output will always be in the same format as the module argspec.
commands
list
when state is merged, replaced, overridden, deleted or purged
The set of commands pushed to the remote device.

Sample:
['sample command 1', 'sample command 2', 'sample command 3']
gathered
list
when state is gathered
Facts about the network resource gathered from the remote device as structured data.

Sample:
This output will always be in the same format as the module argspec.
parsed
list
when state is parsed
The device native config provided in running_config option parsed into structured data as per module argspec.

Sample:
This output will always be in the same format as the module argspec.
rendered
list
when state is rendered
The provided configuration in the task rendered in device-native format (offline).

Sample:
['sample command 1', 'sample command 2', 'sample command 3']


Authors

  • Nilashish Chakraborty (@NilashishC)