Skip to content

Commit

Permalink
Reload rather than restart nscd
Browse files Browse the repository at this point in the history
On configuration change nscd should be reloaded and not restarted
  • Loading branch information
traylenator committed Oct 17, 2019
1 parent fb2f6f1 commit 5d704e4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions data/Debian-family.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
---
nscd::user: root

nscd::service_reload: '/bin/systemctl reload nscd.service'
3 changes: 3 additions & 0 deletions data/RedHat-6-family-major.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

nscd::service_reload: '/sbin/service nscd reload'
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ lookup_options:
strategy: deep
knockout_prefix: '--'

nscd::service_reload: '/usr/bin/systemctl reload nscd.service'

nscd::dbconfig:
passwd:
Expand Down
3 changes: 3 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions manifests/service.pp
Original file line number Diff line number Diff line change
@@ -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,
}
}
}
11 changes: 11 additions & 0 deletions spec/classes/nscd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
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) }
case facts[:os]['family']
when 'Debian'
it { is_expected.to contain_service('nscd').with_restart('/bin/systemctl reload nscd.service') }
else
case [facts[:os]['family'], facts[:os]['release']['major']]
when %w[RedHat 6]
it { is_expected.to contain_service('nscd').with_restart('/sbin/service nscd reload') }
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$}) }
Expand Down

0 comments on commit 5d704e4

Please sign in to comment.