diff --git a/manifests/params.pp b/manifests/params.pp index 908c537..3155714 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -84,12 +84,12 @@ default => 'nagios-plugins', } - $htpasswdfile = $::operatingsystem ? { - /(?i:Debian|Ubuntu|Mint)/ => '/etc/nagios3/htpasswd.users', - default => '/etc/nagios/htpasswd.users', + $htpasswdfile = $::osfamily ? { + 'Debian' => '/etc/nagios3/htpasswd.users', + 'RedHat' => '/etc/nagios/passwd', + default => '/etc/nagios/htpasswd.users', } - ### Application related parameters $package = $::operatingsystem ? { diff --git a/spec/classes/nagios_spec.rb b/spec/classes/nagios_spec.rb index 6db99b6..4390432 100644 --- a/spec/classes/nagios_spec.rb +++ b/spec/classes/nagios_spec.rb @@ -187,5 +187,33 @@ end end + describe 'Test htpasswdfile correct' do + before(:each) do + @htpasswd_resource = catalogue.resource('apache::htpasswd', 'nagiosadmin') + end + + context 'on Debian-like systems' do + let(:facts) { { :osfamily => 'Debian' } } + + it 'should set the apache htpasswd in the correct file' do + @htpasswd_resource[:htpasswd_file].should eq('/etc/nagios3/htpasswd.users') + end + end + + context 'on Redhat-like systems' do + let(:facts) { { :osfamily => 'Redhat' } } + + it 'should set the apache htpasswd in the correct file' do + @htpasswd_resource[:htpasswd_file].should eq('/etc/nagios/passwd') + end + end + + context 'on non-Redhat and non-Debian systems' do + it 'should set the apache htpasswd in the correct file' do + @htpasswd_resource[:htpasswd_file].should eq('/etc/nagios/htpasswd.users') + end + end + end + end