diff --git a/manifests/init.pp b/manifests/init.pp index 4959503..46dfb2f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -24,6 +24,10 @@ ensure => present, } + Package[$mdadm::params::mdadm_package] -> + class { 'mdadm::mdmonitor': } + + Package[$mdadm::params::mdadm_package] -> class { 'mdadm::raid_check': options => $raid_check_options, } diff --git a/manifests/mdmonitor.pp b/manifests/mdmonitor.pp new file mode 100644 index 0000000..d703389 --- /dev/null +++ b/manifests/mdmonitor.pp @@ -0,0 +1,12 @@ +# == Class: mdadm::mdmonitor +# +# This class should be considered private. +# +class mdadm::mdmonitor { + service { 'mdmonitor': + ensure => 'running', + hasrestart => true, + hasstatus => true, + enable => true, + } +} diff --git a/spec/classes/mdadm_spec.rb b/spec/classes/mdadm_spec.rb index 05f0d61..2e71835 100644 --- a/spec/classes/mdadm_spec.rb +++ b/spec/classes/mdadm_spec.rb @@ -2,12 +2,25 @@ describe 'mdadm', :type => :class do + shared_examples 'mdadm' do + it { should contain_package('mdadm').with_ensure('present') } + it { should include_class('mdadm::params') } + it { should contain_class('mdadm::mdmonitor') } + it do + should contain_service('mdmonitor').with({ + :ensure => 'running', + :hasrestart => true, + :hasstatus => true, + :enable => true, + }) + end + end + context 'on osfamily RedHat' do let(:facts) {{ :osfamily => 'RedHat' }} context 'no params' do - it { should contain_package('mdadm').with_ensure('present') } - it { should include_class('mdadm::params') } + it_behaves_like 'mdadm' it do should contain_file('/etc/sysconfig/raid-check'). with_content(/ENABLED="yes"/). @@ -23,8 +36,7 @@ context '{}' do let(:params) {{ :raid_check_options => {} }} - it { should contain_package('mdadm').with_ensure('present') } - it { should include_class('mdadm::params') } + it_behaves_like 'mdadm' it do should contain_file('/etc/sysconfig/raid-check'). with_content(/ENABLED="yes"/). @@ -50,8 +62,7 @@ } end - it { should contain_package('mdadm').with_ensure('present') } - it { should include_class('mdadm::params') } + it_behaves_like 'mdadm' it do should contain_file('/etc/sysconfig/raid-check'). with_content(/ENABLED="foo"/).