Skip to content

Commit

Permalink
Merge branch 'buzzdeee-develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
razorsedge committed Apr 22, 2017
2 parents 68a4cda + d587826 commit b574017
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.markdown
Expand Up @@ -497,6 +497,7 @@ Net-SNMP module support is available with these operating systems:
* 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
* OpenBSD family - tested on OpenBSD 5.9

### Notes:

Expand Down
4 changes: 2 additions & 2 deletions manifests/init.pp
Expand Up @@ -451,7 +451,7 @@
notify => Service['snmpd'],
}

if $::osfamily != 'FreeBSD' {
if $::osfamily != 'FreeBSD' and $::osfamily != 'OpenBSD' {
file { 'snmpd.sysconfig':
ensure => $file_ensure,
mode => '0644',
Expand Down Expand Up @@ -514,7 +514,7 @@
Exec['install /etc/init.d/snmptrapd'],
],
}
} elsif $::osfamily == 'FreeBSD' {
} elsif $::osfamily == 'FreeBSD' or $::osfamily == 'OpenBSD' {
service { 'snmptrapd':
ensure => $trap_service_ensure_real,
name => $trap_service_name,
Expand Down
22 changes: 22 additions & 0 deletions manifests/params.pp
Expand Up @@ -400,6 +400,28 @@
$trap_service_name = 'snmptrapd'
$snmptrapd_options = undef
}
'OpenBSD': {
$package_name = 'net-snmp'
$service_config_dir_path = '/etc/snmp'
$service_config_dir_perms = '0755'
$service_config_dir_owner = 'root'
$service_config_dir_group = 'wheel'
$service_config = '/etc/snmp/snmpd.conf'
$service_config_perms = '0755'
$service_name = 'netsnmpd'
$snmpd_options = undef
$var_net_snmp = '/var/net-snmp'
$varnetsnmp_perms = '0600'
$varnetsnmp_owner = '_netsnmp'
$varnetsnmp_group = 'wheel'

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

$trap_service_config = '/etc/snmp/snmptrapd.conf'
$trap_service_name = 'netsnmptrapd'
$snmptrapd_options = undef
}
default: {
fail("Module ${::module} is not supported on ${::operatingsystem}")
}
Expand Down
4 changes: 4 additions & 0 deletions metadata.json
Expand Up @@ -31,6 +31,10 @@
"operatingsystem": "FreeBSD",
"operatingsystemrelease": [ "9.2", "10.0" ]
},
{
"operatingsystem": "OpenBSD",
"operatingsystemrelease": [ "5.9" ]
},
{
"operatingsystem": "SLES",
"operatingsystemrelease": [ "11 SP1" ]
Expand Down
25 changes: 25 additions & 0 deletions spec/classes/snmp_client_spec.rb
Expand Up @@ -24,6 +24,7 @@
#debianish = ['Debian', 'Ubuntu']
suseish = ['Suse']
freebsdish = ['FreeBSD']
openbsdish = ['OpenBSD']

context 'on a supported osfamily, default parameters' do
redhatish.each do |os|
Expand Down Expand Up @@ -118,6 +119,30 @@
)}
end
end

openbsdish.each do |os|
describe "for osfamily OpenBSD, operatingsystem #{os}" do
let(:params) {{}}
let :facts do {
:osfamily => 'OpenBSD',
:operatingsystem => os,
:operatingsystemrelease => '5.9'
}
end
it { should contain_package('snmp-client').with(
:ensure => 'present',
:name => 'net-snmp'
)}
it { should_not contain_file('snmp.conf').with(
:ensure => 'present',
:mode => '0755',
:owner => 'root',
:group => 'wheel',
:path => '/etc/snmp/snmp.conf',
:require => nil
)}
end
end
end

context 'on a supported osfamily, custom parameters' do
Expand Down
91 changes: 91 additions & 0 deletions spec/classes/snmp_init_spec.rb
Expand Up @@ -24,6 +24,7 @@
#debianish = ['Debian', 'Ubuntu']
suseish = ['Suse']
freebsdish = ['FreeBSD']
openbsdish = ['OpenBSD']

context 'on a supported osfamily, default parameters' do
describe "for osfamily RedHat, operatingsystem RedHat, operatingsystemrelease 5.9" do
Expand Down Expand Up @@ -561,6 +562,96 @@
)}
end
end

openbsdish.each do |os|
describe "for osfamily OpenBSD, operatingsystem #{os}" do
let(:params) {{}}
let :facts do {
:osfamily => 'OpenBSD',
:operatingsystem => os,
:operatingsystemrelease => '5.9',
:fqdn => 'myhost4.localdomain'
}
end
it { should contain_package('snmpd').with(
:ensure => 'present',
:name => 'net-snmp'
)}
it { should_not contain_class('snmp::client') }
it { should contain_file('var-net-snmp').with(
:ensure => 'directory',
:mode => '0600',
:owner => '_netsnmp',
:group => 'wheel',
:path => '/var/net-snmp',
:require => 'Package[snmpd]'
)}

it { should contain_file('snmpd.conf').with(
:ensure => 'present',
:mode => '0755',
:owner => 'root',
:group => 'wheel',
:path => '/etc/snmp/snmpd.conf',
:require => 'Package[snmpd]',
:notify => 'Service[snmpd]'
)}
# TODO add more contents for File[snmpd.conf]
it 'should contain File[snmpd.conf] with expected contents' do
verify_contents(catalogue, 'snmpd.conf', [
'agentaddress udp:127.0.0.1:161,udp6:[::1]:161',
'rocommunity public 127.0.0.1',
'rocommunity6 public ::1',
'com2sec notConfigUser default public',
'com2sec6 notConfigUser default public',
'group notConfigGroup v1 notConfigUser',
'group notConfigGroup v2c notConfigUser',
'view systemview included .1.3.6.1.2.1.1',
'view systemview included .1.3.6.1.2.1.25.1.1',
'access notConfigGroup "" any noauth exact systemview none none',
'sysLocation Unknown',
'sysContact Unknown',
'sysServices 72',
'sysName myhost4.localdomain',
'dontLogTCPWrappersConnects no',
])
end
it { should contain_service('snmpd').with(
:ensure => 'running',
:name => 'netsnmpd',
:enable => true,
:hasstatus => true,
:hasrestart => true,
:require => [ 'Package[snmpd]', 'File[var-net-snmp]', ]
)}

it { should contain_file('snmptrapd.conf').with(
:ensure => 'present',
:mode => '0755',
:owner => 'root',
:group => 'wheel',
:path => '/etc/snmp/snmptrapd.conf',
:require => 'Package[snmpd]',
:notify => 'Service[snmptrapd]'
)}
# TODO add more contents for File[snmptrapd.conf]
it 'should contain File[snmptrapd.conf] with correct contents' do
verify_contents(catalogue, 'snmptrapd.conf', [
'doNotLogTraps no',
'authCommunity log,execute,net public',
'disableAuthorization no',
])
end
it { should contain_service('snmptrapd').with(
:ensure => 'stopped',
:name => 'netsnmptrapd',
:enable => false,
:hasstatus => true,
:hasrestart => true,
:require => [ 'Package[snmpd]', 'File[var-net-snmp]', ]
)}
end
end
end

context 'on a supported osfamily (RedHat), custom parameters' do
Expand Down

0 comments on commit b574017

Please sign in to comment.