Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Reload rather than restart nscd #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data/Debian-8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
nscd::service_restart: /usr/sbin/service nscd reload
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that Debian 8 could be used with systemd and sysv, but in all other modules we have we assume it's running systemd. (also I think we should not support debian 8 anymore because it has very limited support and debian 9/10 are available)

1 change: 1 addition & 0 deletions data/Debian-family.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
nscd::user: root
nscd::service_restart: /bin/systemctl reload nscd
1 change: 1 addition & 0 deletions data/RedHat-family.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
nscd::service_restart: /usr/sbin/service nscd reload
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this valid? I never saw a 16.04 without systemd and in all other modules we assume 16.04 and newer ubuntus are running with systemd

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/bin/systemctl just to be annoying.

3 changes: 2 additions & 1 deletion hiera.yaml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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