Skip to content

Commit

Permalink
add raid_check_manage param to mdadm class
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed May 21, 2014
1 parent f236b7d commit 7ba06ea
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class { '::mdadm':
force_service => false,
service_ensure => 'running',
service_enable => true,
raid_check_manage => true
raid_check_options => {},
}
```
Expand Down Expand Up @@ -93,6 +94,12 @@ Valid strings are: 'running', 'stopped'

`Bool` defaults to 'true'

##### `raid_check_manage`

`Bool` defaults to `true`

Enables/disables management of the EL specific `raid-check` cron task.

##### `raid_check_options`

`Hash` defaults to '{}'
Expand Down
11 changes: 8 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
$service_force = false,
$service_ensure = 'running',
$service_enable = true,
$raid_check_manage = true,
$raid_check_options = {},
) inherits mdadm::params {
validate_bool($config_file_manage)
validate_hash($config_file_options)
validate_bool($service_force)
validate_re($service_ensure, '^running$|^stopped$')
validate_bool($service_enable)
validate_bool($raid_check_manage)
validate_hash($raid_check_options)

if $service_force {
Expand Down Expand Up @@ -46,13 +48,16 @@
enable => $use_service_enable,
}

class { 'mdadm::raid_check':
options => $raid_check_options,
if $raid_check_manage {
Class['mdadm::mdmonitor'] ->
class { 'mdadm::raid_check':
options => $raid_check_options,
} ->
Anchor['mdadm::end']
}

anchor { 'mdadm::begin': } ->
Package[$mdadm::params::mdadm_package] ->
Class['mdadm::mdmonitor'] ->
Class['mdadm::raid_check'] ->
anchor { 'mdadm::end': }
}
6 changes: 2 additions & 4 deletions manifests/raid_check.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

include mdadm::params

# note that 'NICE' is el6.x only

$default_options = {
Expand All @@ -26,11 +24,11 @@

$safe_options = merge($default_options, $options)

file { $mdadm::params::raid_check_path:
file { $mdadm::raid_check_path:
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => template($mdadm::params::raid_check_template),
content => template($mdadm::raid_check_template),
}
}
22 changes: 22 additions & 0 deletions spec/unit/classes/mdadm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@
end
end # service_force

context 'raid_check_manage =>' do
context 'true' do
let(:params) {{ :raid_check_manage => true }}

it { should contain_file('/etc/sysconfig/raid-check') }
end

context 'false' do
let(:params) {{ :raid_check_manage => false }}

it { should_not contain_file('/etc/sysconfig/raid-check') }
end

context 'foo' do
let(:params) {{ :raid_check_manage => 'foo' }}

it 'should fail' do
expect { should }.to raise_error(/is not a boolean/)
end
end
end # raid_check_manage

context 'raid_check_options =>' do
context '{}' do
let(:params) {{ :raid_check_options => {} }}
Expand Down

0 comments on commit 7ba06ea

Please sign in to comment.