Initial version of snmp module.
This commit is contained in:
parent
7bd26f33d3
commit
4ee0691e63
3 changed files with 88 additions and 0 deletions
8
snmp/files/snmptrapd.rc
Normal file
8
snmp/files/snmptrapd.rc
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
daemon="/usr/local/sbin/snmptrapd"
|
||||||
|
daemon_flags="-n -u snmptrapd -g snmptrapd -c /etc/snmptrapd.conf"
|
||||||
|
|
||||||
|
. /etc/rc.d/rc.subr
|
||||||
|
|
||||||
|
rc_cmd $1
|
71
snmp/manifests/init.pp
Normal file
71
snmp/manifests/init.pp
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
|
||||||
|
# Install net-snmp utilities
|
||||||
|
#
|
||||||
|
class snmp::utils {
|
||||||
|
|
||||||
|
package { "net-snmp":
|
||||||
|
name => $::operatingsystem ? {
|
||||||
|
"openbsd" => "net-snmp",
|
||||||
|
default => "net-snmp-utils",
|
||||||
|
},
|
||||||
|
ensure => installed,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install snmp trap daemon
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# $acl:
|
||||||
|
# Array containing list of allowed SNMP community names.
|
||||||
|
# Defaults is to allow all trap messages.
|
||||||
|
#
|
||||||
|
# === Sample usage
|
||||||
|
#
|
||||||
|
# class { "snmp::trapd":
|
||||||
|
# acl => [ "public", ],
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
class snmp::trapd($acl=NONE) {
|
||||||
|
|
||||||
|
require snmp::utils
|
||||||
|
include user::system
|
||||||
|
|
||||||
|
realize([ User["snmptrapd"], Group["snmptrapd"], ])
|
||||||
|
|
||||||
|
case $::operatingsystem {
|
||||||
|
"openbsd": {
|
||||||
|
file { "/etc/rc.d/snmptrapd":
|
||||||
|
ensure => present,
|
||||||
|
source => "puppet:///modules/snmp/snmptrapd.rc",
|
||||||
|
mode => "0755",
|
||||||
|
owner => "root",
|
||||||
|
group => "wheel",
|
||||||
|
notify => Service["snmptrapd"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
fail("snmp::trapd not supported in ${::operatingsystem}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file { "/etc/snmptrapd.conf":
|
||||||
|
ensure => present,
|
||||||
|
content => template("snmp/snmptrapd.conf.erb"),
|
||||||
|
mode => "0644",
|
||||||
|
owner => "root",
|
||||||
|
group => $::operatingsystem ? {
|
||||||
|
"openbsd" => "wheel",
|
||||||
|
default => "root",
|
||||||
|
},
|
||||||
|
notify => Service["snmptrapd"],
|
||||||
|
}
|
||||||
|
|
||||||
|
service { "snmptrapd":
|
||||||
|
ensure => running,
|
||||||
|
enable => true,
|
||||||
|
require => User["snmptrapd"],
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
9
snmp/templates/snmptrapd.conf.erb
Normal file
9
snmp/templates/snmptrapd.conf.erb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
pidFile /var/run/snmptrapd.pid
|
||||||
|
<% if acl == 'NONE' -%>
|
||||||
|
disableAuthorization yes
|
||||||
|
<% else -%>
|
||||||
|
<% acl.each do |rule| -%>
|
||||||
|
authCommunity log <%= rule %>
|
||||||
|
<% end -%>
|
||||||
|
<% end -%>
|
Loading…
Add table
Add a link
Reference in a new issue