diff --git a/data/Debian-16.04-family-major.yaml b/data/Debian-16.04-family-major.yaml new file mode 100644 index 0000000..eaab257 --- /dev/null +++ b/data/Debian-16.04-family-major.yaml @@ -0,0 +1,3 @@ +--- + +nscd::service_reload: '/sbin/service nscd reload' diff --git a/data/Debian-8-family-major.yaml b/data/Debian-8-family-major.yaml new file mode 100644 index 0000000..eaab257 --- /dev/null +++ b/data/Debian-8-family-major.yaml @@ -0,0 +1,3 @@ +--- + +nscd::service_reload: '/sbin/service nscd reload' diff --git a/data/Debian-family.yaml b/data/Debian-family.yaml index 32d92e7..1787812 100644 --- a/data/Debian-family.yaml +++ b/data/Debian-family.yaml @@ -1,2 +1,4 @@ --- nscd::user: root + +nscd::service_reload: '/bin/systemctl reload nscd.service' diff --git a/data/RedHat-6-family-major.yaml b/data/RedHat-6-family-major.yaml new file mode 100644 index 0000000..eaab257 --- /dev/null +++ b/data/RedHat-6-family-major.yaml @@ -0,0 +1,3 @@ +--- + +nscd::service_reload: '/sbin/service nscd reload' diff --git a/data/common.yaml b/data/common.yaml index c991c12..6907834 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -6,6 +6,7 @@ lookup_options: strategy: deep knockout_prefix: '--' +nscd::service_reload: '/usr/bin/systemctl reload nscd.service' nscd::dbconfig: passwd: diff --git a/hiera.yaml b/hiera.yaml index 422fa92..75a8759 100644 --- a/hiera.yaml +++ b/hiera.yaml @@ -6,6 +6,9 @@ defaults: data_hash: 'yaml_data' hierarchy: + - name: 'Operating System Family Release' + path: '%{facts.os.family}-%{facts.os.release.major}-family-major.yaml' + - name: 'Operating System Family' path: '%{facts.os.family}-family.yaml' diff --git a/manifests/init.pp b/manifests/init.pp index e6cdf1f..852291c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -29,10 +29,12 @@ # @param debug_level debug level # @param reload_count any many reload attempts to make # @param logfile specify a debug log file location. +# @param service_reload command to reload nscd service # @dbconfig configuration for each of the passwd, group, hosts and service database. class nscd ( Nscd::Database $dbconfig, + String $service_reload, Enum['present','absent','latest'] $pkg_ensure = 'present', Boolean $service_ensure = true, Boolean $service_enable = true, diff --git a/manifests/service.pp b/manifests/service.pp index 17b1e6a..21f4a25 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,13 +1,15 @@ class nscd::service ( $service_ensure = $nscd::service_ensure, $service_enable = $nscd::service_enable, + $service_reload = $nscd::service_reload, $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_reload, } } } diff --git a/spec/classes/nscd_spec.rb b/spec/classes/nscd_spec.rb index 2509ac9..0e0272e 100644 --- a/spec/classes/nscd_spec.rb +++ b/spec/classes/nscd_spec.rb @@ -13,6 +13,18 @@ it { is_expected.to contain_package('nscd').with_ensure('present') } it { is_expected.to contain_service('nscd').with_ensure(true) } + case [facts[:os]['family'], facts[:os]['release']['major']] + when %w[RedHat 6], ['Debian', '16.04'], %w[Debian 8] + it { is_expected.to contain_service('nscd').with_restart('/sbin/service nscd reload') } + else + case facts[:os]['family'] + when 'Debian' + it { is_expected.to contain_service('nscd').with_restart('/bin/systemctl reload nscd.service') } + else + it { is_expected.to contain_service('nscd').with_restart('/usr/bin/systemctl reload nscd.service') } + end + end + 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$}) }