Skip to content

Commit

Permalink
Add OpenBSD to the supported operating systems, similar to FreeBSD
Browse files Browse the repository at this point in the history
support. Add spec tests for OpenBSD and mention it in README and
metadata.json
  • Loading branch information
buzzdeee committed Sep 7, 2016
1 parent 671181c commit 7054d9d
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,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
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,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 @@ -504,7 +504,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
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 7054d9d

Please sign in to comment.