Showing with 2,138 additions and 879 deletions.
  1. +1 −4 .fixtures.yml
  2. +0 −6 .gemfile
  3. +0 −1 .project
  4. +30 −17 .travis.yml
  5. +15 −0 Gemfile
  6. +7 −6 Modulefile
  7. +61 −17 README.md
  8. +4 −1 Rakefile
  9. +0 −3 files/snmp.conf
  10. +0 −3 files/snmpd.sysconfig
  11. +0 −6 files/snmpd.sysconfig-RedHat-5
  12. +0 −3 files/snmptrapd.sysconfig
  13. +0 −5 files/snmptrapd.sysconfig-RedHat-6
  14. +94 −0 manifests/client.pp
  15. +359 −22 manifests/init.pp
  16. +241 −61 manifests/params.pp
  17. +0 −173 manifests/server.pp
  18. +27 −6 manifests/snmpv3_user.pp
  19. +0 −133 manifests/trapd.pp
  20. +193 −0 samples/snmpd.conf-Debian
  21. +12 −8 files/snmpd.conf → samples/snmpd.conf-RedHat
  22. +19 −0 samples/snmpd.conf-Suse
  23. +18 −0 samples/snmptrapd.conf-Debian
  24. +0 −3 files/snmptrapd.conf → samples/snmptrapd.conf-RedHat
  25. +148 −0 spec/classes/snmp_client_spec.rb
  26. +521 −35 spec/classes/snmp_init_spec.rb
  27. +0 −174 spec/classes/snmp_server_spec.rb
  28. +0 −146 spec/classes/snmp_trapd_spec.rb
  29. +224 −24 spec/defines/snmp_snmpv3_user_spec.rb
  30. +6 −0 templates/snmp.conf.erb
  31. +51 −9 templates/snmpd.conf.erb
  32. +7 −4 files/snmpd.sysconfig-Debian-12 → templates/snmpd.sysconfig-Debian.erb
  33. +1 −1 files/snmpd.sysconfig-RedHat-6 → templates/snmpd.sysconfig-RedHat.erb
  34. +39 −0 templates/snmpd.sysconfig-Suse.erb
  35. +30 −3 templates/snmptrapd.conf.erb
  36. +1 −1 files/snmptrapd.sysconfig-RedHat-5 → templates/snmptrapd.sysconfig-RedHat.erb
  37. +1 −0 tests/client.pp
  38. +7 −0 tests/client_class.pp
  39. +0 −2 tests/server.pp
  40. +10 −0 tests/snmpd-snmptrapd.pp
  41. +11 −2 tests/trapd.pp
5 changes: 1 addition & 4 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
fixtures:
repositories:
stdlib:
repo: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
ref: "2.6.0"
lsb: "git://github.com/razorsedge/puppet-lsb.git"
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
symlinks:
snmp: "#{source_dir}"
6 changes: 0 additions & 6 deletions .gemfile

This file was deleted.

1 change: 0 additions & 1 deletion .project
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<name>snmp</name>
<comment></comment>
<projects>
<project>lsb</project>
<project>stdlib</project>
</projects>
<buildSpec>
Expand Down
47 changes: 30 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
language: ruby
rvm:
- 1.8.7
#before_script:
# - 'git clone git://github.com/puppetlabs/puppetlabs-stdlib.git spec/fixtures/modules/stdlib'
script: "rake spec"
branches:
only:
- master
- develop
language: ruby
bundler_args: --without development
script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
env:
matrix:
- PUPPET_GEM_VERSION="~> 2.6.0"
- PUPPET_GEM_VERSION="~> 2.7.0"
- PUPPET_GEM_VERSION="~> 3.0.0"
- PUPPET_GEM_VERSION="~> 3.1.0"
- PUPPET_GEM_VERSION="~> 3.2.0"
matrix:
exclude:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.6.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.6.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.2.0"
notifications:
email:
- github@razorsedge.org
gemfile: .gemfile
env:
# - PUPPET_VERSION=2.6.4 # PE 1.1
- PUPPET_VERSION=2.6.9 # PE 1.2
- PUPPET_VERSION=2.6.18 # latest 2.6
- PUPPET_VERSION=2.7.6 # PE 2.0
- PUPPET_VERSION=2.7.9 # PE 2.0.1+
- PUPPET_VERSION=2.7.12 # PE 2.5
- PUPPET_VERSION=2.7.19 # PE 2.6.0+
- PUPPET_VERSION=2.7.20 # PE 2.7.0+
- PUPPET_VERSION=2.7.21 # latest 2.7; PE 2.8.0+
15 changes: 15 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
source 'https://rubygems.org'

group :development, :test do
gem 'rake'
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', '~> 0.3.2'
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end

# vim:ft=ruby
13 changes: 7 additions & 6 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name 'razorsedge-snmp'
version '2.0.0'
version '3.0.0'

author 'razorsedge'
license 'Apache License, Version 2.0'
project_page 'https://github.com/razorsedge/puppet-snmp'
source 'git://github.com/razorsedge/puppet-snmp.git'
summary 'Install and manage SNMP services.'
description 'This module manages the installation of the SNMP server, SNMP client, and SNMP trap server. It also can create a SNMPv3 user with authentication and privacy passwords.'
summary 'Install and manage Net-SNMP services.'
description 'This module manages the installation of the SNMP server, SNMP
client, and SNMP trap server. It also can create a SNMPv3 user with
authentication and privacy passwords.'
dependency 'puppetlabs/stdlib', '>=2.3.0'
dependency 'razorsedge/lsb', '>=1.0.0'

# Generate the changelog file
system("git-log-to-changelog > CHANGELOG")
$? == 0 or fail "changelog generation #{$?}!"
#system("git-log-to-changelog > CHANGELOG")
#$? == 0 or fail "changelog generation #{$?}!"
78 changes: 61 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Net-SNMP installation.
Puppet Net-SNMP Module
======================

master branch: [![Build Status](https://secure.travis-ci.org/razorsedge/puppet-snmp.png?branch=master)](http://travis-ci.org/razorsedge/puppet-snmp)
Expand All @@ -20,57 +20,101 @@ Actions:

OS Support:

* RedHat family - tested on CentOS 5.8 and CentOS 6.2
* SuSE family - presently unsupported (patches welcome)
* Debian family - initial Debian & Ubuntu suport (patches welcome)
* Solaris family - presently unsupported (patches welcome)
* RedHat family - tested on CentOS 5.9 and CentOS 6.4
* SuSE family - tested on SLES 11 SP1
* Debian family - tested on Ubuntu 12.04.2 LTS, Debian 6.0.7, and Debian 7.0

Class documentation is available via puppetdoc.

Examples
--------

class { 'snmp': }
To install the SNMP service:

class { 'snmp::server':
class { 'snmp':
agentaddress => [ 'udp:161', ],
ro_community => 'notpublic',
ro_network => '10.20.30.40/32',
contact => 'root@yourdomain.org',
location => 'Phoenix, AZ',
}

class { 'snmp::trapd':
ro_community => 'public',
To install the SNMP service and the client:

class { 'snmp':
install_client => true,
snmp_config => [ 'defVersion 2c', 'defCommunity public', ],
}

If you just want to install the SNMP client:

class { 'snmp::client':
snmp_config => [ 'mibdirs +/usr/local/share/snmp/mibs', ],
}

Only configure and run the snmptrap daemon:

class { 'snmp':
snmptrapdaddr => [ 'udp:162', ],
ro_community => 'SeCrEt',
service_ensure => 'stopped',
trap_service_ensure => 'running',
trap_service_enable => true,
trap_handlers => [
'default /usr/bin/perl /usr/bin/traptoemail me@somewhere.local',
'TRAP-TEST-MIB::demo-trap /home/user/traptest.sh demo-trap',
],
trap_forwards => [ 'default udp:55.55.55.55:162' ],
}

To install a SNMP version 3 user for snmpd:

snmp::snmpv3_user { 'myuser':
authpass => '1234auth',
privpass => '5678priv',
}

To install a SNMP version 3 user for snmptrapd:

snmp::snmpv3_user { 'myuser':
authpass => 'SeCrEt',
privpass => 'PhRaSe',
daemon => 'snmptrapd',
}

Notes
-----

* Only tested on CentOS 5.8, CentOS 6.2 x86_64, and Debian squeeze.
* SNMPv3 user auth is not tested on Debian.
* Only tested on CentOS 5.9, CentOS 6.4, Ubuntu 12.04.2 LTS, Debian squeeze, and
Debian wheezy x86_64.
* SNMPv3 user auth is not yet tested on Debian or Suse osfamilies.
* There is a bug on Debian squeeze of net-snmp's status script. If snmptrapd is
not running the status script returns 'not running' so puppet restarts the
snmpd service. The following is a workaround: `class { 'snmp::server':
service_hasstatus => false, }`
snmpd service. The following is a workaround: `class { 'snmp':
service_hasstatus => false, trap_service_hasstatus => false, }`
* For security reasons, the SNMP daemons are configured to listen on the loopback
interface (127.0.0.1). Use `agentaddress` and `snmptrapdaddr` to change this
configuration.

Issues
------

* Debian will not support the use of non-numeric OIDs. Something about [rabid
freedom](http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=561578).
* On osfamily Debian, starting the snmptrap service does not work. This will
be fixed in the upcomming refactor of this module.

TODO
----

* Figure out how to install the RFC-standard MIBS on Debian so that `snmpwalk
-v 2c -c public localhost system` will function.
* Possibly support USM and VACM?

Deprecation Warning
-------------------

The classes `snmp::server` and `snmp::trapd` will be merged into class `snmp`.
All of their class parameters will be made available in the `snmp` class.
The classes `snmp::server` and `snmp::trapd` will be merged into class `snmp` in
version 3.0.0 of this module. All of their class parameters will be made
available in the `snmp` class.

License
-------
Expand Down
5 changes: 4 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ RSpec::Core::RakeTask.new(:spec_standalonev) do |t|
end

# https://github.com/stahnma/puppet-modules/blob/master/common/Rakefile
desc "Run puppet in noop mode and check for syntax errors."
desc "Check puppet and ERB for syntax errors."
task :validate do
Dir['manifests/**/*.pp'].each do |path|
sh "puppet parser validate --noop #{path}"
end
Dir['templates/**/*.erb'].each do |path|
sh "erb -P -x -T '-' #{path} | ruby -c"
end
end

# Enable puppet-lint for all manifests: rake lint
Expand Down
3 changes: 0 additions & 3 deletions files/snmp.conf

This file was deleted.

3 changes: 0 additions & 3 deletions files/snmpd.sysconfig

This file was deleted.

6 changes: 0 additions & 6 deletions files/snmpd.sysconfig-RedHat-5

This file was deleted.

3 changes: 0 additions & 3 deletions files/snmptrapd.sysconfig

This file was deleted.

5 changes: 0 additions & 5 deletions files/snmptrapd.sysconfig-RedHat-6

This file was deleted.

94 changes: 94 additions & 0 deletions manifests/client.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# == Class: snmp::client
#
# This class handles installing the Net-SNMP client.
#
# === Parameters:
#
# [*snmp_config*]
# Array of lines to add to the client's global snmp.conf file.
# See http://www.net-snmp.org/docs/man/snmp.conf.html for all options.
# Default: []
#
# [*ensure*]
# Ensure if present or absent.
# Default: present
#
# [*autoupgrade*]
# Upgrade package automatically, if there is a newer version.
# Default: false
#
# [*package_name*]
# Name of the package.
# Only set this if your platform is not supported or you know what you are
# doing.
# Default: auto-set, platform specific
#
# === Actions:
#
# Installs the Net-SNMP client package and configuration.
#
# === Requires:
#
# Nothing.
#
# === Sample Usage:
#
# class { 'snmp::client':
# snmp_config => [ 'defVersion 2c', 'defCommunity public', ],
# }
#
# === Authors:
#
# Mike Arnold <mike@razorsedge.org>
#
# === Copyright:
#
# Copyright (C) 2012 Mike Arnold, unless otherwise noted.
#
class snmp::client (
$snmp_config = $snmp::params::snmp_config,
$ensure = $snmp::params::ensure,
$autoupgrade = $snmp::params::safe_autoupgrade,
$package_name = $snmp::params::client_package_name
) inherits snmp::params {
# Validate our booleans
validate_bool($autoupgrade)

case $ensure {
/(present)/: {
if $autoupgrade == true {
$package_ensure = 'latest'
} else {
$package_ensure = 'present'
}
$file_ensure = 'present'
}
/(absent)/: {
$package_ensure = 'absent'
$file_ensure = 'absent'
}
default: {
fail('ensure parameter must be present or absent')
}
}

if $::osfamily != 'Suse' {
package { 'snmp-client':
ensure => $package_ensure,
name => $package_name,
}
$req = Package['snmp-client']
} else {
$req = undef
}

file { 'snmp.conf':
ensure => $file_ensure,
mode => '0644',
owner => 'root',
group => 'root',
path => $snmp::params::client_config,
content => template('snmp/snmp.conf.erb'),
require => $req,
}
}
Loading