Showing with 162 additions and 92 deletions.
  1. +0 −1 .gitignore
  2. +2 −2 .project
  3. +1 −0 .travis.yml
  4. +16 −4 Gemfile
  5. +0 −16 Modulefile
  6. +5 −2 README.md
  7. +11 −22 Rakefile
  8. +23 −8 manifests/init.pp
  9. +14 −4 manifests/params.pp
  10. +6 −6 manifests/snmpv3_user.pp
  11. +15 −0 .metadata.json → metadata.json
  12. +41 −24 spec/classes/snmp_init_spec.rb
  13. +24 −0 spec/spec_helper.rb
  14. +4 −3 templates/snmpd.conf.erb
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
metadata.json
pkg/
*.swp
4 changes: 2 additions & 2 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</projects>
<buildSpec>
<buildCommand>
<name>org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder</name>
<name>com.puppetlabs.geppetto.pp.dsl.ui.modulefileBuilder</name>
<arguments>
</arguments>
</buildCommand>
Expand All @@ -18,7 +18,7 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.cloudsmith.geppetto.pp.dsl.ui.puppetNature</nature>
<nature>com.puppetlabs.geppetto.pp.dsl.ui.puppetNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
<filteredResources>
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
- 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
matrix:
exclude:
Expand Down
20 changes: 16 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
source 'https://rubygems.org'
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :development, :test do
gem 'rake'
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', '~> 0.3.2'
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
end

if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
else
gem 'facter', :require => false
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
Expand Down
16 changes: 0 additions & 16 deletions Modulefile

This file was deleted.

7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ To install the SNMP service:
To install the SNMP service and the client:

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

If you just want to install the SNMP client:
Expand Down Expand Up @@ -120,6 +120,9 @@ 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
4.0.0 of this module.

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

Expand Down
33 changes: 11 additions & 22 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'

desc "Run visual spec tests on an existing fixtures directory"
RSpec::Core::RakeTask.new(:spec_standalonev) do |t|
t.rspec_opts = ['--color', '--format documentation']
t.pattern = 'spec/{classes,defines,unit}/**/*_spec.rb'
end

# https://github.com/stahnma/puppet-modules/blob/master/common/Rakefile
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
require 'puppet-lint/tasks/puppet-lint'
#PuppetLint.configuration.send("disable_80chars") # no warnings on lines over 80 chars.
PuppetLint.configuration.ignore_paths = ["spec/fixtures/**/*.pp", "pkg/**/*"]

PuppetLint.configuration.fail_on_warnings
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"]

PuppetSyntax.exclude_paths = ["pkg/**/*"]
PuppetSyntax.hieradata_paths = ["**/data/**/*.yaml", "hieradata/**/*.yaml", "hiera*.yaml"]
31 changes: 23 additions & 8 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
# Location of the SNMP system.
# Default: Unknown
#
# [*sysname*]
# Name of the system (hostname).
# Default: ${::fqdn}
#
# [*com2sec*]
# An array of VACM com2sec mappings.
# Must provide SECNAME, SOURCE and COMMUNITY.
Expand Down Expand Up @@ -106,7 +110,7 @@
# Default: []
#
#
# [*install_client*]
# [*manage_client*]
# Whether to install the Net-SNMP client package. (true|false)
# Default: false
#
Expand Down Expand Up @@ -195,8 +199,8 @@
#
# # Configure and run the snmp daemon and install the client:
# class { 'snmp':
# ro_community => 'SeCrEt',
# install_client => true,
# ro_community => 'SeCrEt',
# manage_client => true,
# }
#
# # Only configure and run the snmptrap daemon:
Expand Down Expand Up @@ -227,6 +231,7 @@
$rw_network = $snmp::params::rw_network,
$contact = $snmp::params::contact,
$location = $snmp::params::location,
$sysname = $snmp::params::sysname,
$services = $snmp::params::services,
$com2sec = $snmp::params::com2sec,
$groups = $snmp::params::groups,
Expand All @@ -240,6 +245,7 @@
$trap_forwards = $snmp::params::trap_forwards,
$snmptrapd_config = $snmp::params::snmptrapd_config,
$install_client = $snmp::params::install_client,
$manage_client = $snmp::params::safe_manage_client,
$snmp_config = $snmp::params::snmp_config,
$ensure = $snmp::params::ensure,
$autoupgrade = $snmp::params::safe_autoupgrade,
Expand All @@ -258,7 +264,7 @@
$trap_service_hasrestart = $snmp::params::trap_service_hasrestart
) inherits snmp::params {
# Validate our booleans
validate_bool($install_client)
validate_bool($manage_client)
validate_bool($autoupgrade)
validate_bool($service_enable)
validate_bool($service_hasstatus)
Expand All @@ -280,6 +286,15 @@
validate_re($disable_authorization, $states, '$disable_authorization must be either yes or no.')
validate_re($do_not_log_traps, $states, '$do_not_log_traps must be either yes or no.')

# Deprecated backwards-compatibility
if $install_client != undef {
validate_bool($install_client)
warning('snmp: parameter install_client is deprecated; please use manage_client')
$real_manage_client = $install_client
} else {
$real_manage_client = $manage_client
}

case $ensure {
/(present)/: {
if $autoupgrade == true {
Expand Down Expand Up @@ -338,11 +353,11 @@
$snmptrapd_conf_notify = Service['snmpd']
}

if $install_client {
if $real_manage_client {
class { 'snmp::client':
ensure => $ensure,
autoupgrade => $autoupgrade,
snmp_config => $snmp_config,
ensure => $ensure,
autoupgrade => $autoupgrade,
snmp_config => $snmp_config,
}
}

Expand Down
18 changes: 14 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
default => $::snmp_location,
}

$sysname = $::snmp_sysname ? {
undef => $::fqdn,
default => $::snmp_sysname,
}

$com2sec = $::snmp_com2sec ? {
undef => [
"notConfigUser default ${ro_community}",
Expand Down Expand Up @@ -161,13 +166,18 @@
}

$install_client = $::snmp_install_client ? {
undef => false,
undef => undef,
default => $::snmp_install_client,
}
if is_string($install_client) {
$safe_install_client = str2bool($install_client)

$manage_client = $::snmp_manage_client ? {
undef => false,
default => $::snmp_manage_client,
}
if is_string($manage_client) {
$safe_manage_client = str2bool($manage_client)
} else {
$safe_install_client = $install_client
$safe_manage_client = $manage_client
}

$service_enable = $::snmp_service_enable ? {
Expand Down
12 changes: 6 additions & 6 deletions manifests/snmpv3_user.pp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
$daemon = 'snmpd'
) {
# Validate our regular expressions
$Aoptions = [ '^SHA$', '^MD5$' ]
validate_re($authtype, $Aoptions, '$authtype must be either SHA or MD5.')
$Poptions = [ '^AES$', '^DES$' ]
validate_re($privtype, $Poptions, '$privtype must be either AES or DES.')
$Doptions = [ '^snmpd$', '^snmptrapd$' ]
validate_re($daemon, $Doptions, '$daemon must be either snmpd or snmptrapd.')
$hash_options = [ '^SHA$', '^MD5$' ]
validate_re($authtype, $hash_options, '$authtype must be either SHA or MD5.')
$enc_options = [ '^AES$', '^DES$' ]
validate_re($privtype, $enc_options, '$privtype must be either AES or DES.')
$daemon_options = [ '^snmpd$', '^snmptrapd$' ]
validate_re($daemon, $daemon_options, '$daemon must be either snmpd or snmptrapd.')

include snmp

Expand Down
15 changes: 15 additions & 0 deletions .metadata.json → metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
{
"name": "razorsedge-snmp",
"version": "3.2.0",
"author": "razorsedge",
"summary": "Install and manage Net-SNMP services.",
"license": "Apache License, Version 2.0",
"project_page": "https://github.com/razorsedge/puppet-snmp",
"issues_url": "https://github.com/razorsedge/puppet-snmp/issues",
"source": "https://github.com/razorsedge/puppet-snmp.git",
"tags": [ "RHEL", "rhel", "OEL", "CentOS", "snmp", "monitoring", "debian", "ubuntu", "SuSE", "OpenSUSE", "FreeBSD" ],
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">=2.3.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
Expand Down
Loading