Showing with 286 additions and 134 deletions.
  1. +7 −0 .gitignore
  2. +26 −37 .travis.yml
  3. +9 −5 Gemfile
  4. +69 −44 README.md
  5. +8 −4 Rakefile
  6. +50 −9 manifests/init.pp
  7. +40 −3 manifests/params.pp
  8. +3 −3 metadata.json
  9. +43 −4 spec/classes/snmp_init_spec.rb
  10. +6 −0 spec/spec.opts
  11. +0 −25 spec/spec_helper.rb
  12. +25 −0 templates/snmpd.conf.erb
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
pkg/
Gemfile.lock
vendor/
spec/fixtures/
.vagrant/
.bundle/
coverage/
*.swp
.vendor/
63 changes: 26 additions & 37 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,34 @@
---
language: ruby
cache:
directories:
- vendor/bundle
- spec/fixtures/modules
sudo: false
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
- 2.1.0
env:
matrix:
- PUPPET_GEM_VERSION="~> 2.7.0"
- PUPPET_GEM_VERSION="~> 3.2.0"
- PUPPET_GEM_VERSION="~> 3.3.0"
- PUPPET_GEM_VERSION="~> 3.4.0"
- PUPPET_GEM_VERSION="~> 3.5.0"
- PUPPET_GEM_VERSION="~> 3.6.0"
- PUPPET_GEM_VERSION="~> 3.7.0"
# https://docs.puppetlabs.com/guides/platforms.html#ruby-versions
bundler_args: --without system_tests
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
matrix:
exclude:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.2.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.4.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.2.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.4.0"
fast_finish: true
include:
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
allow_failures:
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
notifications:
email:
- github@razorsedge.org
14 changes: 9 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :development, :test do
group :development, :unit_tests do
gem 'rake', :require => false
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'serverspec', :require => false
gem 'puppet-lint', :require => false
gem 'beaker', :require => false
gem 'beaker-rspec', :require => false
gem 'pry', :require => false
gem 'simplecov', :require => false
gem 'puppet_facts', :require => false
gem 'json', :require => false
gem 'metadata-json-lint', :require => false
end

group :system_tests do
gem 'beaker-rspec', :require => false
gem 'serverspec', :require => false
end

if facterversion = ENV['FACTER_GEM_VERSION']
Expand Down
113 changes: 69 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Actions:

OS Support:

* RedHat family - tested on CentOS 5.9 and CentOS 6.4
* RedHat family - tested on CentOS 5.9, CentOS 6.6, and CentOS 7.0
* SuSE family - tested on SLES 11 SP1
* Debian family - tested on Ubuntu 12.04.2 LTS, Debian 6.0.7, and Debian 7.0
* FreeBSD family - tested on FreeBSD 9.2-RELEASE, FreeBSD 10.0-RELEASE
Expand All @@ -30,75 +30,96 @@ Class documentation is available via puppetdoc.
Examples
--------

To install the SNMP service:
To install the SNMP service listening on all IPv4 and IPv6 interfaces:

class { 'snmp':
agentaddress => [ 'udp:161', ],
ro_community => 'notpublic',
ro_network => '10.20.30.40/32',
contact => 'root@yourdomain.org',
location => 'Phoenix, AZ',
}
```puppet
class { 'snmp':
agentaddress => [ 'udp:161', 'udp6:161' ],
com2sec => [ 'notConfigUser 10.20.30.40/32 SeCrEt' ],
come2sec6 => [ 'notConfiguser fd48:45d7:f49b:cb0f::1/128 SeCrEt' ],
contact => 'root@yourdomain.org',
location => 'Phoenix, AZ',
}
```

To install the SNMP service and the client:

class { 'snmp':
manage_client => true,
snmp_config => [ 'defVersion 2c', 'defCommunity public', ],
}
```puppet
class { 'snmp':
manage_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', ],
}
```puppet
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' ],
}
```puppet
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',
}
class { 'snmp':
snmpd_config => [ 'rouser myuser authPriv' ],
}
```puppet
snmp::snmpv3_user { 'myuser':
authpass => '1234auth',
privpass => '5678priv',
}
class { 'snmp':
snmpd_config => [ 'rouser myuser authPriv' ],
}
```

To install a SNMP version 3 user for snmptrapd:

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

Notes
-----

* Only tested on CentOS 5.9, CentOS 6.4, Ubuntu 12.04.2 LTS, Debian squeeze, and
Debian wheezy x86_64.
* By default the SNMP service now listens on BOTH the IPv4 and IPv6 loopback
addresses.
* Only tested on CentOS 5.9, CentOS 6.6, CentOS 7.0, 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':
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
interfaces (127.0.0.1 and [::1]). Use `agentaddress` and `snmptrapdaddr` to change this
configuration.
* [Traditional Access
Control](http://www.net-snmp.org/docs/man/snmpd.conf.html#lbAK) is not fully
supported in this module. The parameters ro_community, rw_community,
ro_network, and rw_network will end up commented out in the snmpd.conf.
Instead use [VACM
Configuration](http://www.net-snmp.org/docs/man/snmpd.conf.html#lbAL) via
parameters com2sec, groups, views, and accesses.

Issues
------
Expand All @@ -120,9 +141,13 @@ 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.

The paramter `install_client` will be renamed to `manage_client` in version
The parameter `install_client` will be renamed to `manage_client` in version
4.0.0 of this module.

The parameters `ro_community`, `rw_community`, `ro_network`, and `rw_network`
will be removed in version 4.0.0 of this module. The snmptrapd parameter name
will become `authcommunity`.

Contributing
------------

Expand Down
12 changes: 8 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'

PuppetLint.configuration.fail_on_warnings
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('relative')
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_class_parameter_defaults')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vender/**/*.pp"]

PuppetSyntax.exclude_paths = ["pkg/**/*"]
PuppetSyntax.exclude_paths = ["spec/**/*", "pkg/**/*", "vender/**/*"]
PuppetSyntax.hieradata_paths = ["**/data/**/*.yaml", "hieradata/**/*.yaml", "hiera*.yaml"]

desc "Check puppet metadata.json with metadata-json-lint."
task :metadata do
sh "metadata-json-lint metadata.json"
end
Loading