Skip to content

Commit

Permalink
Always reload rather than start/stop the nscd service
Browse files Browse the repository at this point in the history
  • Loading branch information
traylenator committed Dec 5, 2020
1 parent 82df136 commit a4a1168
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 7 deletions.
2 changes: 2 additions & 0 deletions data/Debian-8.yaml
@@ -0,0 +1,2 @@
---
nscd::service_restart: /usr/sbin/service nscd reload
1 change: 1 addition & 0 deletions data/Debian-family.yaml
@@ -1,2 +1,3 @@
---
nscd::user: root
nscd::service_restart: /bin/systemctl reload nscd
1 change: 1 addition & 0 deletions data/RedHat-family.yaml
@@ -1,3 +1,4 @@
---
nscd::user: nscd
nscd::logfile: /var/log/nscd.log
nscd::service_restart: /usr/bin/systemctl reload nscd
2 changes: 2 additions & 0 deletions data/Ubuntu-16.04.yaml
@@ -0,0 +1,2 @@
---
nscd::service_restart: /usr/sbin/service nscd reload
3 changes: 2 additions & 1 deletion hiera.yaml
Expand Up @@ -6,9 +6,10 @@ defaults:
data_hash: 'yaml_data'

hierarchy:
- name: 'Operating System Name Version'
path: '%{facts.os.name}-%{facts.os.release.full}.yaml'
- name: 'Operating System Family'
path: '%{facts.os.family}-family.yaml'

- name: 'common'
path: 'common.yaml'

2 changes: 2 additions & 0 deletions manifests/init.pp
Expand Up @@ -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.
Expand All @@ -32,6 +33,7 @@
# @dbconfig configuration for each of the passwd, group, hosts and service database.

class nscd (
String[1] $service_restart,
Nscd::Database $dbconfig,
Enum['present','absent','latest'] $pkg_ensure = 'present',
Boolean $service_ensure = true,
Expand Down
13 changes: 8 additions & 5 deletions 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,
}
}
}
9 changes: 8 additions & 1 deletion spec/classes/nscd_spec.rb
Expand Up @@ -12,6 +12,7 @@
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_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$}) }
Expand Down Expand Up @@ -73,10 +74,16 @@
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$}) }

it { is_expected.to contain_service('nscd').with_restart('/usr/bin/systemctl reload 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$}) }
case facts[:os]['release']['full']
when '16.04', '8'
it { is_expected.to contain_service('nscd').with_restart('/usr/sbin/service nscd reload') }
else
it { is_expected.to contain_service('nscd').with_restart('/bin/systemctl reload nscd') }
end
end
end

Expand Down

0 comments on commit a4a1168

Please sign in to comment.