scathatheworm.net-snmp
ansible-netsnmp
Ansible Role for setting up and configuring a simple SNMP daemon for versions v1/v2c.
Explanation of Variables in defaults/main.yml
Default Log Level
Set the log level to control how much detail is logged. The levels are:
- 0: emergency
- 1: alert
- 2: critical
- 3: error
- 4: warning
- 5: notice
- 6: info
- 7: debug
The default is 6, which provides a lot of information and can clutter the logs.
snmpd_loglevel: 4
Listening Port
Specify the port for listening.
snmpd_port: 161
Disable IPv6 by Default
Turn off IPv6 use by default.
snmpd_ipv6_enabled: false
sysLocation, sysContact, and sysName
These are defined but empty by default.
# snmpd_sysLocation:
# snmpd_sysContact:
# snmpd_sysName:
Fallback for sysName
Use the name from the Ansible inventory if sysName is not set.
snmpd_sysName_ansible_inventory_hostname: true
Building Views
systemview
is set up to show common OIDs for host resources, while all
shows everything. This is optional.
snmpd_views:
- name: systemview
tree_object: .1.3.6.1.2.1.1
- name: systemview
tree_object: .1.3.6.1.2.1.25
- name: all
tree_object: .1
Access Control
Defines the public
and private
communities, accessible only from localhost. view
and network
are optional. If using a trapcommunity
, do not define view and network.
snmpd_community_acl:
- type: rocommunity
community_name: public
view: systemview
network: 127.0.0.1
- type: rwcommunity
community_name: private
view: systemview
network: 127.0.0.1
- type: trapcommunity
community_name: trapcommunity
Define Trap Destinations
Specify where to send SNMP traps. Choose either SNMPv1 (trapsink
) or SNMPv2 (trap2sink
). You can set a port (default is 162) and a community (if defined, it must be set in Access Control).
snmpd_trap_destionation:
- type: trapsink
host: 127.0.0.1
community: trapcommunity
port: 162
- type: trap2sink
host: 127.0.0.1
community: trapcommunity
port: 162
Send Trap Notification on Authentication Failure
Enable sending a trap if SNMP authentication fails.
snmpd_auth_traps: true
Enable AgentX for Extensibility
Allow AgentX expansion.
snmpd_enable_agentx: true
Additional SNMP Configuration
Define extra custom settings as needed.
snmpd_additional_config: |
sysServices 72
proc mountd
proc ntalkd 4
proc sendmail 10 1
disk / 10000
disk /var 5%
includeAllDisks 10%
load 12 10 5
trapsink localhost public
iquerySecName internalUser
rouser internalUser
defaultMonitors yes
linkUpDownNotifications yes
extend test1 /bin/echo Hello, world!
extend-sh test2 echo Hello, world! ; echo Hi there ; exit 35
Ansible Role for deploying a simple snmp v1/2c configuration
ansible-galaxy install scathatheworm.net-snmp