Skip to content

Commit 309dc76

Browse files
authored
Merge pull request #1349 from arjenz/fix_service
Fix service status detection on Debian-based OSes
2 parents f417f00 + 66f8f66 commit 309dc76

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

Diff for: manifests/params.pp

+5-10
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,13 @@
166166
$bindir = pick($bindir, "/usr/lib/postgresql/${version}/bin")
167167
$datadir = pick($datadir, "/var/lib/postgresql/${version}/main")
168168
$confdir = pick($confdir, "/etc/postgresql/${version}/main")
169-
if $facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '8') >= 0 {
170-
# Jessie uses systemd
171-
$service_status = pick($service_status, "/usr/sbin/service ${service_name}@*-main status")
172-
} elsif $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '18.04') >= 0 {
173-
$service_status = pick($service_status, "/usr/sbin/service ${service_name}@*-main status")
174-
} elsif $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '15.04') >= 0 {
175-
# Ubuntu releases since vivid use systemd
176-
$service_status = pick($service_status, "/usr/sbin/service ${service_name} status")
169+
if pick($service_provider, $facts['service_provider']) == 'systemd' {
170+
$service_reload = "systemctl reload ${service_name}"
171+
$service_status = pick($service_status, "systemctl status ${service_name}")
177172
} else {
178-
$service_status = pick($service_status, "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+|online'")
173+
$service_reload = "service ${service_name} reload"
174+
$service_status = pick($service_status, "service ${service_name} status")
179175
}
180-
$service_reload = "service ${service_name} reload"
181176
$psql_path = pick($psql_path, '/usr/bin/psql')
182177
$postgresql_conf_mode = pick($postgresql_conf_mode, '0644')
183178
}

Diff for: spec/classes/server/service_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
end
1111

1212
it { is_expected.to contain_class('postgresql::server::service') }
13-
it { is_expected.to contain_service('postgresqld').with_name('postgresql').with_status('/usr/sbin/service postgresql@*-main status') }
13+
it { is_expected.to contain_service('postgresqld').with_name('postgresql').with_status('systemctl status postgresql') }
1414
end

Diff for: spec/classes/server_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
it { is_expected.to contain_class('postgresql::server') }
1111
it { is_expected.to contain_file('/var/lib/postgresql/13/main') }
1212
it {
13-
is_expected.to contain_exec('postgresql_reload').with('command' => 'service postgresql reload')
13+
is_expected.to contain_exec('postgresql_reload').with('command' => 'systemctl reload postgresql')
1414
}
1515
it 'validates connection' do
1616
is_expected.to contain_postgresql_conn_validator('validate_service_is_running')

0 commit comments

Comments
 (0)