Skip to content

Commit e13bb80

Browse files
authored
Merge pull request #1392 from SimonHoenscheid/shoenscheid_postgresql_instances_reload_class_to_define
Add multi instance support, refactoring reload.pp (6/x)
2 parents 6e4f005 + 1277a36 commit e13bb80

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

manifests/server/instance_reload.pp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# @param service_reload Overrides the default reload command for your PostgreSQL service.
2+
# @param service_status Overrides the default status check command for your PostgreSQL service.
3+
define postgresql::server::instance_reload (
4+
$service_status = $postgresql::server::service_status,
5+
$service_reload = $postgresql::server::service_reload,
6+
) {
7+
exec { 'postgresql_reload':
8+
path => '/usr/bin:/usr/sbin:/bin:/sbin',
9+
command => $service_reload,
10+
onlyif => $service_status,
11+
refreshonly => true,
12+
require => Class['postgresql::server::service'],
13+
}
14+
}

manifests/server/reload.pp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
# @api private
22
class postgresql::server::reload {
3-
$service_status = $postgresql::server::service_status
4-
$service_reload = $postgresql::server::service_reload
5-
6-
exec { 'postgresql_reload':
7-
path => '/usr/bin:/usr/sbin:/bin:/sbin',
8-
command => $service_reload,
9-
onlyif => $service_status,
10-
refreshonly => true,
11-
require => Class['postgresql::server::service'],
3+
postgresql::server::instance_reload { 'main':
4+
service_status => $postgresql::server::service_status,
5+
service_reload => $postgresql::server::service_reload,
126
}
137
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'postgresql::server::instance_reload' do
6+
let(:title) { 'main' }
7+
8+
on_supported_os.each do |os, os_facts|
9+
context "on #{os}" do
10+
let :facts do
11+
os_facts
12+
end
13+
14+
let :pre_condition do
15+
"class {'postgresql::server':}"
16+
end
17+
18+
context 'with defaults from server class' do
19+
it { is_expected.to compile.with_all_deps }
20+
end
21+
end
22+
end
23+
end

0 commit comments

Comments
 (0)