diff --git a/hiera.yaml b/hiera.yaml index 422fa92..4670840 100644 --- a/hiera.yaml +++ b/hiera.yaml @@ -8,7 +8,6 @@ defaults: hierarchy: - name: 'Operating System Family' path: '%{facts.os.family}-family.yaml' - - name: 'common' path: 'common.yaml' diff --git a/manifests/init.pp b/manifests/init.pp index 7689f9b..131c8de 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -20,6 +20,7 @@ # @param pkg_ensure state of nscd package. # @param service_ensure state of nscd service ensure # @param service_enable state of nscd service enable +# $param service_restart command to reload nscd service # @param threads number of threads. # @param max_threads maximum number of threads. # @prarm paranoia enable internal restart mode. @@ -36,6 +37,7 @@ Enum['present','absent','latest'] $pkg_ensure = 'present', Boolean $service_ensure = true, Boolean $service_enable = true, + String[1] $service_restart = '/bin/systemctl reload nscd', String[1] $user = 'root', Optional[String[1]] $stat_user = undef, Integer $threads = 5, diff --git a/manifests/service.pp b/manifests/service.pp index 3b7fd44..122c497 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,12 +1,15 @@ class nscd::service ( - $service_ensure = $nscd::service_ensure, - $service_enable = $nscd::service_enable, - $pkg_ensure = $nscd::pkg_ensure, + $service_ensure = $nscd::service_ensure, + $service_enable = $nscd::service_enable, + $service_restart = $nscd::service_restart, + $pkg_ensure = $nscd::pkg_ensure, ) { if $pkg_ensure != 'absent' { service { 'nscd': - ensure => $service_ensure, - enable => $service_enable, + ensure => $service_ensure, + enable => $service_enable, + restart => $service_restart, + hasrestart => true, } } } diff --git a/spec/classes/nscd_spec.rb b/spec/classes/nscd_spec.rb index 2509ac9..546c9f2 100644 --- a/spec/classes/nscd_spec.rb +++ b/spec/classes/nscd_spec.rb @@ -12,6 +12,8 @@ it { is_expected.to contain_class('nscd::service') } it { is_expected.to contain_package('nscd').with_ensure('present') } it { is_expected.to contain_service('nscd').with_ensure(true) } + it { is_expected.to contain_service('nscd').with_hasrestart(true) } + it { is_expected.to contain_service('nscd').with_restart('/bin/systemctl reload nscd') } it { is_expected.to contain_file('/etc/nscd.conf').with_content(%r{^threads\s+5$}) } it { is_expected.to contain_file('/etc/nscd.conf').with_content(%r{^max-threads\s+32$}) } @@ -73,7 +75,6 @@ when 'RedHat' it { is_expected.to contain_file('/etc/nscd.conf').with_content(%r{^logfile\s+/var/log/nscd.log$}) } it { is_expected.to contain_file('/etc/nscd.conf').with_content(%r{^server-user\s+nscd$}) } - else it { is_expected.to contain_file('/etc/nscd.conf').without_content(%r{^logfile.*$}) } it { is_expected.to contain_file('/etc/nscd.conf').with_content(%r{^server-user\s+root$}) }