diff --git a/README.md b/README.md index 3a6b7bb..5bdda3b 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ class { '::mdadm': force_service => false, service_ensure => 'running', service_enable => true, + raid_check_manage => true raid_check_options => {}, } ``` @@ -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 '{}' diff --git a/manifests/init.pp b/manifests/init.pp index 392b79a..5d99810 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,6 +9,7 @@ $service_force = false, $service_ensure = 'running', $service_enable = true, + $raid_check_manage = true, $raid_check_options = {}, ) inherits mdadm::params { validate_bool($config_file_manage) @@ -16,6 +17,7 @@ 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 { @@ -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': } } diff --git a/manifests/raid_check.pp b/manifests/raid_check.pp index cd361c1..02bc69d 100644 --- a/manifests/raid_check.pp +++ b/manifests/raid_check.pp @@ -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 = { @@ -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), } } diff --git a/spec/unit/classes/mdadm_spec.rb b/spec/unit/classes/mdadm_spec.rb index 91383b6..fff6b8c 100644 --- a/spec/unit/classes/mdadm_spec.rb +++ b/spec/unit/classes/mdadm_spec.rb @@ -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 => {} }}