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 eb624d1
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 2 deletions.
3 changes: 3 additions & 0 deletions data/Debian-16.04-family-major.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

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

nscd::service_reload: '/sbin/service nscd reload'
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,
}
}
}
12 changes: 12 additions & 0 deletions spec/classes/nscd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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$}) }

Expand Down

0 comments on commit eb624d1

Please sign in to comment.