Skip to content

Commit

Permalink
Merge branch 'feature/ubuntu_support' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
razorsedge committed Jun 16, 2013
2 parents 8186518 + fd1c5b8 commit 3a46f4b
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ OS Support:
* RedHat family - tested on CentOS 5.8 and CentOS 6.2
* Fedora - not yet supported
* SuSE family - presently unsupported (patches welcome)
* Debian family - presently unsupported (patches welcome)
* Debian family - initial Ubuntu suport (patches welcome)
* Solaris family - presently unsupported (patches welcome)

Class documentation is available via puppetdoc.
Expand Down
22 changes: 22 additions & 0 deletions files/snmpd.sysconfig-Debian-12
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file controls the activity of snmpd and snmptrapd

# Don't load any MIBs by default.
# You might comment this lines once you have the MIBs downloaded.
export MIBS=

# snmpd control (yes means start daemon).
SNMPDRUN=yes

# snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'

# snmptrapd control (yes means start daemon). As of net-snmp version
# 5.0, master agentx support must be enabled in snmpd before snmptrapd
# can be run. See snmpd.conf(5) for how to do this.
TRAPDRUN=no

# snmptrapd options (use syslog).
TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'

# create symlink on Debian legacy location to official RFC path
SNMPDCOMPAT=yes
14 changes: 14 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@
'Fedora': {
fail("Module snmp is not yet supported on ${::operatingsystem}")
}
'Ubuntu': {
$package_name = 'snmpd'
$service_config = '/etc/snmp/snmpd.conf'
$service_name = 'snmpd'
$sysconfig = '/etc/default/snmp'
$var_net_snmp = '/var/lib/snmp'
$varnetsnmp_perms = '0700'

$client_package_name = 'snmp'
$client_config = '/etc/snmp/snmp.conf'

$trap_service_config = '/etc/snmp/snmptrapd.conf'
$trap_service_name = 'snmptrapd'
}
default: {
fail("Module snmp is not supported on ${::operatingsystem}")
}
Expand Down
28 changes: 15 additions & 13 deletions manifests/trapd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,21 @@
notify => Service['snmptrapd'],
}

file { 'snmptrapd.sysconfig':
ensure => $file_ensure,
mode => '0644',
owner => 'root',
group => 'root',
path => $snmp::params::trap_sysconfig,
source => [
"puppet:///modules/snmp/snmptrapd.sysconfig-${::fqdn}",
"puppet:///modules/snmp/snmptrapd.sysconfig-${::osfamily}-${::lsbmajdistrelease}",
'puppet:///modules/snmp/snmptrapd.sysconfig',
],
require => Package['snmpd'],
notify => Service['snmptrapd'],
if $::osfamily != 'Debian' {
file { 'snmptrapd.sysconfig':
ensure => $file_ensure,
mode => '0644',
owner => 'root',
group => 'root',
path => $snmp::params::trap_sysconfig,
source => [
"puppet:///modules/snmp/snmptrapd.sysconfig-${::fqdn}",
"puppet:///modules/snmp/snmptrapd.sysconfig-${::osfamily}-${::lsbmajdistrelease}",
'puppet:///modules/snmp/snmptrapd.sysconfig',
],
require => Package['snmpd'],
notify => Service['snmptrapd'],
}
}

service { 'snmptrapd':
Expand Down
53 changes: 53 additions & 0 deletions spec/classes/snmp_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
end

redhatish = ['RedHat']
debianish = ['Ubuntu']

describe 'on a supported operatingsystem, with default settings' do
redhatish.each do |os|
Expand Down Expand Up @@ -45,6 +46,29 @@
)}
end
end

debianish.each do |os|
describe "for operating system #{os}" do
let(:params) {{}}
let :facts do {
:operatingsystem => os
}
end
it { should contain_file('snmpd.conf').with(
:ensure => 'present',
:path => '/etc/snmp/snmpd.conf'
)}
it { should contain_file('snmpd.sysconfig').with(
:ensure => 'present',
:path => '/etc/default/snmp'
)}
it { should contain_service('snmpd').with(
:ensure => 'running',
:enable => true,
:name => 'snmpd'
)}
end
end
end

describe 'on a supported operatingsystem, with custom settings' do
Expand Down Expand Up @@ -82,5 +106,34 @@
)}
end
end
debianish.each do |os|
describe "for operating system #{os}" do
let(:params) {
{
:autoupgrade => true,
:package_name => 'snmp-server',
:service_ensure => 'stopped',
:service_enable => false
}
}
let :facts do {
:operatingsystem => os
}
end
it { should contain_file('snmpd.conf').with(
:ensure => 'present',
:path => '/etc/snmp/snmpd.conf'
)}
it { should contain_file('snmpd.sysconfig').with(
:ensure => 'present',
:path => '/etc/default/snmp'
)}
it { should contain_service('snmpd').with(
:ensure => 'stopped',
:enable => false,
:name => 'snmpd'
)}
end
end
end
end
56 changes: 56 additions & 0 deletions spec/classes/snmp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
end

redhatish = ['RedHat']
debianish = ['Ubuntu']

describe 'on a supported operatingsystem, with default settings' do
redhatish.each do |os|
Expand Down Expand Up @@ -44,6 +45,31 @@
)}
end
end
debianish.each do |os|
describe "for operating system #{os}" do
let(:params) {{}}
let :facts do {
:operatingsystem => os
}
end
it { should contain_package('snmpd').with(
:ensure => 'present',
:name => 'snmpd'
)}
it { should contain_package('snmp-client').with(
:ensure => 'present',
:name => 'snmp'
)}
it { should contain_file('snmp.conf').with(
:ensure => 'present',
:path => '/etc/snmp/snmp.conf'
)}
it { should contain_file('var-net-snmp').with(
:ensure => 'directory',
:path => '/var/lib/snmp'
)}
end
end
end

describe 'on a supported operatingsystem, with custom settings' do
Expand Down Expand Up @@ -78,5 +104,35 @@
)}
end
end
debianish.each do |os|
describe "for operating system #{os}" do
let(:params) {
{
:ensure => 'present',
:autoupgrade => true,
}
}
let :facts do {
:operatingsystem => os
}
end
it { should contain_package('snmpd').with(
:ensure => 'latest',
:name => 'snmpd'
)}
it { should contain_package('snmp-client').with(
:ensure => 'latest',
:name => 'snmp'
)}
it { should contain_file('snmp.conf').with(
:ensure => 'present',
:path => '/etc/snmp/snmp.conf'
)}
it { should contain_file('var-net-snmp').with(
:ensure => 'directory',
:path => '/var/lib/snmp'
)}
end
end
end
end
51 changes: 51 additions & 0 deletions spec/classes/snmp_trapd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
end

redhatish = ['RedHat']
debianish = ['Ubuntu']

describe 'on a supported operatingsystem, with default settings' do
redhatish.each do |os|
Expand All @@ -41,6 +42,28 @@
)}
end
end
debianish.each do |os|
describe "for operating system #{os}" do
let(:params) {{}}
let :facts do {
:operatingsystem => os
}
end
it { should contain_file('snmptrapd.conf').with(
:ensure => 'present',
:path => '/etc/snmp/snmptrapd.conf'
)}
# it { should contain_file('snmptrapd.sysconfig').with(
# :ensure => 'present',
# :path => '/etc/default/snmptrapd'
# )}
it { should contain_service('snmptrapd').with(
:ensure => 'running',
:enable => true,
:name => 'snmptrapd'
)}
end
end
end

describe 'on a supported operatingsystem, with custom settings' do
Expand Down Expand Up @@ -73,6 +96,34 @@
)}
end
end
debianish.each do |os|
describe "for operating system #{os}" do
let(:params) {
{
:service_name => 'snmp-trapserver',
:service_ensure => 'stopped',
:service_enable => false
}
}
let :facts do {
:operatingsystem => os
}
end
it { should contain_file('snmptrapd.conf').with(
:ensure => 'present',
:path => '/etc/snmp/snmptrapd.conf'
)}
# it { should contain_file('snmptrapd.sysconfig').with(
# :ensure => 'present',
# :path => '/etc/default/snmptrapd'
# )}
it { should contain_service('snmptrapd').with(
:ensure => 'stopped',
:enable => false,
:name => 'snmp-trapserver'
)}
end
end
end
end

0 comments on commit 3a46f4b

Please sign in to comment.