Skip to content

Commit 1277a36

Browse files
Add multi instance support, refactoring reload.pp (6/x)
This commit adds changes a class to add multi instance support to this module. The general idea is to first copy all classes which are used and create defines from them. These classes will use the defines as is. Necessary changes for the instances itself will be added to the classes and defined types at a later point. This ensures, the module will work as it does right now and there are no breaking changes.
1 parent 6e4f005 commit 1277a36

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)