Skip to content

Commit

Permalink
Merge pull request jhoblitt#11 from bodgit/watchdog
Browse files Browse the repository at this point in the history
Add support for enabling the IPMI watchdog
  • Loading branch information
Joshua Hoblitt committed Dec 10, 2014
2 parents 73cf7ef + eade2fe commit cf8ef28
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Usage
class { 'ipmi':
service_ensure => 'running', # default is 'running'
ipmievd_service_ensure => 'running', # default is 'stopped'
watchdog => true, # default is false
}
```

Expand All @@ -69,6 +70,11 @@ Controls the state of the `ipmi` service.

Controls the state of the `ipmievd` service.

##### `watchdog`

`Boolean` defaults to: `false`

Controls whether the IPMI watchdog is enabled.

Limitations
-----------
Expand Down
18 changes: 18 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# == Class: ipmi::config
#
# This class should be considered private.
#
class ipmi::config {

$watchdog_real = $::ipmi::watchdog ? {
true => 'yes',
default => 'no',
}

augeas { '/etc/sysconfig/ipmi':
context => '/files/etc/sysconfig/ipmi',
changes => [
"set IPMI_WATCHDOG ${watchdog_real}",
],
}
}
15 changes: 11 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
class ipmi (
$service_ensure = 'running',
$ipmievd_service_ensure = 'stopped',
$watchdog = false,
) inherits ipmi::params {
validate_re($service_ensure, '^running$|^stopped$')
validate_re($ipmievd_service_ensure, '^running$|^stopped$')
validate_bool($watchdog)

$enable_ipmi = $service_ensure ? {
'running' => true,
Expand All @@ -20,6 +22,9 @@
'stopped' => false,
}

include ::ipmi::install
include ::ipmi::config

class { 'ipmi::service::ipmi':
ensure => $service_ensure,
enable => $enable_ipmi,
Expand All @@ -30,8 +35,10 @@
enable => $enable_ipmievd,
}

class { 'ipmi::install': } ->
Class['ipmi::service::ipmi'] ->
Class['ipmi::service::ipmievd'] ->
Class['ipmi']
anchor { 'ipmi::begin': }
anchor { 'ipmi::end': }

Anchor['ipmi::begin'] -> Class['::ipmi::install'] ~> Class['::ipmi::config']
~> Class['::ipmi::service::ipmi'] ~> Class['::ipmi::service::ipmievd']
-> Anchor['ipmi::end']
}
112 changes: 112 additions & 0 deletions spec/classes/ipmi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
# it { should contain_class('ipmi') }
it { should contain_class('ipmi::params') }
it { should contain_class('ipmi::install') }
it { should contain_class('ipmi::config') }
it do
should contain_augeas('/etc/sysconfig/ipmi').with({
'context' => '/files/etc/sysconfig/ipmi',
'changes' => [
'set IPMI_WATCHDOG no',
],
})
end
it do
should contain_class('ipmi::service::ipmi').with({
:ensure => 'running',
Expand All @@ -34,6 +43,15 @@
# it { should contain_class('ipmi') }
it { should contain_class('ipmi::params') }
it { should contain_class('ipmi::install') }
it { should contain_class('ipmi::config') }
it do
should contain_augeas('/etc/sysconfig/ipmi').with({
'context' => '/files/etc/sysconfig/ipmi',
'changes' => [
'set IPMI_WATCHDOG no',
],
})
end
it do
should contain_class('ipmi::service::ipmi').with({
:ensure => 'running',
Expand All @@ -54,6 +72,15 @@
# it { should contain_class('ipmi') }
it { should contain_class('ipmi::params') }
it { should contain_class('ipmi::install') }
it { should contain_class('ipmi::config') }
it do
should contain_augeas('/etc/sysconfig/ipmi').with({
'context' => '/files/etc/sysconfig/ipmi',
'changes' => [
'set IPMI_WATCHDOG no',
],
})
end
it do
should contain_class('ipmi::service::ipmi').with({
:ensure => 'stopped',
Expand Down Expand Up @@ -84,6 +111,15 @@
# it { should contain_class('ipmi') }
it { should contain_class('ipmi::params') }
it { should contain_class('ipmi::install') }
it { should contain_class('ipmi::config') }
it do
should contain_augeas('/etc/sysconfig/ipmi').with({
'context' => '/files/etc/sysconfig/ipmi',
'changes' => [
'set IPMI_WATCHDOG no',
],
})
end
it do
should contain_class('ipmi::service::ipmi').with({
:ensure => 'running',
Expand All @@ -104,6 +140,15 @@
# it { should contain_class('ipmi') }
it { should contain_class('ipmi::params') }
it { should contain_class('ipmi::install') }
it { should contain_class('ipmi::config') }
it do
should contain_augeas('/etc/sysconfig/ipmi').with({
'context' => '/files/etc/sysconfig/ipmi',
'changes' => [
'set IPMI_WATCHDOG no',
],
})
end
it do
should contain_class('ipmi::service::ipmi').with({
:ensure => 'running',
Expand All @@ -127,6 +172,73 @@
}.to raise_error(Puppet::Error, /does not match/)
end
end

describe 'watchdog => true' do
let(:params) {{ :watchdog => true }}

it { should contain_class('ipmi::params') }
it { should contain_class('ipmi::install') }
it { should contain_class('ipmi::config') }
it do
should contain_augeas('/etc/sysconfig/ipmi').with({
'context' => '/files/etc/sysconfig/ipmi',
'changes' => [
'set IPMI_WATCHDOG yes',
],
})
end
it do
should contain_class('ipmi::service::ipmi').with({
:ensure => 'running',
:enable => true,
})
end
it do
should contain_class('ipmi::service::ipmievd').with({
:ensure => 'stopped',
:enable => false,
})
end
end

describe 'watchdog => false' do
let(:params) {{ :watchdog => false }}

it { should contain_class('ipmi::params') }
it { should contain_class('ipmi::install') }
it { should contain_class('ipmi::config') }
it do
should contain_augeas('/etc/sysconfig/ipmi').with({
'context' => '/files/etc/sysconfig/ipmi',
'changes' => [
'set IPMI_WATCHDOG no',
],
})
end
it do
should contain_class('ipmi::service::ipmi').with({
:ensure => 'running',
:enable => true,
})
end
it do
should contain_class('ipmi::service::ipmievd').with({
:ensure => 'stopped',
:enable => false,
})
end
end

describe 'watchdog => invalid-string' do
let(:params) {{ :watchdog => 'invalid-string' }}

it 'should fail' do
expect {
should contain_class('ipmi')
}.to raise_error(Puppet::Error, /is not a boolean/)
end
end

end

end

0 comments on commit cf8ef28

Please sign in to comment.