Skip to content

Commit e98a0e7

Browse files
Merge pull request #1503 from SimonHoenscheid/unique_resource_titles
unique resource titles to allow multiple instances
2 parents 1164f77 + f8d838f commit e98a0e7

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

manifests/server/instance/initdb.pp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175

176176
# This runs the initdb command, we use the existance of the PG_VERSION
177177
# file to ensure we don't keep running this command.
178-
exec { 'postgresql_initdb':
178+
exec { "postgresql_initdb_instance_${name}":
179179
command => $initdb_command,
180180
creates => "${datadir}/PG_VERSION",
181181
user => $user,
@@ -185,6 +185,11 @@
185185
cwd => $module_workdir,
186186
}
187187
} elsif $encoding != undef {
188-
include postgresql::server::late_initdb
188+
postgresql::server::instance::late_initdb { $name:
189+
encoding => $encoding,
190+
user => $user,
191+
group => $group,
192+
module_workdir => $module_workdir,
193+
}
189194
}
190195
}

manifests/server/instance/passwd.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
# the default for pg_hba.conf.
4343
$escaped = postgresql::postgresql_escape($real_postgres_password)
4444
$exec_command = "${stdlib::shell_escape($psql_path)}${_dboption} -c \"ALTER ROLE \\\"${stdlib::shell_escape($user)}\\\" PASSWORD \${NEWPASSWD_ESCAPED}\"" # lint:ignore:140chars
45-
exec { 'set_postgres_postgrespw':
45+
exec { "set_postgres_postgrespw_${name}":
4646
# This command works w/no password because we run it as postgres system
4747
# user
4848
command => $exec_command,

manifests/server/instance/reload.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
String[1] $service_status = $postgresql::server::service_status,
77
String[1] $service_reload = $postgresql::server::service_reload,
88
) {
9-
exec { 'postgresql_reload':
9+
exec { "postgresql_reload_${name}":
1010
path => '/usr/bin:/usr/sbin:/bin:/sbin',
1111
command => $service_reload,
1212
onlyif => $service_status,

spec/classes/server/initdb_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class { 'postgresql::server': }
6565
end
6666

6767
it 'contains exec with specified working directory' do
68-
expect(subject).to contain_exec('postgresql_initdb').with(
68+
expect(subject).to contain_exec('postgresql_initdb_instance_main').with(
6969
cwd: '/var/tmp',
7070
)
7171
end
@@ -82,7 +82,7 @@ class { 'postgresql::server': }
8282
end
8383

8484
it 'contains exec with default working directory' do
85-
expect(subject).to contain_exec('postgresql_initdb').with(
85+
expect(subject).to contain_exec('postgresql_initdb_instance_main').with(
8686
cwd: '/tmp',
8787
)
8888
end

spec/classes/server_spec.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
it { is_expected.to contain_file('/var/lib/postgresql/13/main') }
1212

1313
it {
14-
expect(subject).to contain_exec('postgresql_reload').with('command' => 'systemctl reload postgresql')
14+
expect(subject).to contain_exec('postgresql_reload_main').with('command' => 'systemctl reload postgresql')
1515
}
1616

1717
it 'validates connection' do
@@ -65,10 +65,10 @@ class { 'postgresql::globals':
6565
end
6666

6767
it 'sets postgres password' do
68-
expect(subject).to contain_exec('set_postgres_postgrespw').with('command' => '/usr/bin/psql -c "ALTER ROLE \"postgres\" PASSWORD ${NEWPASSWD_ESCAPED}"',
69-
'user' => 'postgres',
70-
'environment' => ['PGPASSWORD=new-p@s$word-to-set', 'PGPORT=5432', 'NEWPASSWD_ESCAPED=$$new-p@s$word-to-set$$'],
71-
'unless' => "/usr/bin/psql -h localhost -p 5432 -c 'select 1' > /dev/null")
68+
expect(subject).to contain_exec('set_postgres_postgrespw_main').with('command' => '/usr/bin/psql -c "ALTER ROLE \"postgres\" PASSWORD ${NEWPASSWD_ESCAPED}"',
69+
'user' => 'postgres',
70+
'environment' => ['PGPASSWORD=new-p@s$word-to-set', 'PGPORT=5432', 'NEWPASSWD_ESCAPED=$$new-p@s$word-to-set$$'],
71+
'unless' => "/usr/bin/psql -h localhost -p 5432 -c 'select 1' > /dev/null")
7272
end
7373
end
7474

@@ -89,10 +89,10 @@ class { 'postgresql::globals':
8989
end
9090

9191
it 'sets postgres password' do
92-
expect(subject).to contain_exec('set_postgres_postgrespw').with('command' => ['/usr/bin/psql -c "ALTER ROLE \"postgres\" PASSWORD ${NEWPASSWD_ESCAPED}"'],
93-
'user' => 'postgres',
94-
'environment' => ['PGPASSWORD=new-p@s$word-to-set', 'PGPORT=5432', 'NEWPASSWD_ESCAPED=$$new-p@s$word-to-set$$'],
95-
'unless' => "/usr/bin/psql -h localhost -p 5432 -c 'select 1' > /dev/null")
92+
expect(subject).to contain_exec('set_postgres_postgrespw_main').with('command' => ['/usr/bin/psql -c "ALTER ROLE \"postgres\" PASSWORD ${NEWPASSWD_ESCAPED}"'],
93+
'user' => 'postgres',
94+
'environment' => ['PGPASSWORD=new-p@s$word-to-set', 'PGPORT=5432', 'NEWPASSWD_ESCAPED=$$new-p@s$word-to-set$$'],
95+
'unless' => "/usr/bin/psql -h localhost -p 5432 -c 'select 1' > /dev/null")
9696
end
9797
end
9898

@@ -146,7 +146,7 @@ class { 'postgresql::globals':
146146
it { is_expected.to contain_class('postgresql::server') }
147147

148148
it {
149-
expect(subject).to contain_exec('postgresql_reload').with('command' => '/bin/true')
149+
expect(subject).to contain_exec('postgresql_reload_main').with('command' => '/bin/true')
150150
}
151151

152152
it 'validates connection' do
@@ -194,7 +194,7 @@ class { 'postgresql::globals':
194194
end
195195

196196
it 'contains proper initdb exec' do
197-
expect(subject).to contain_exec('postgresql_initdb')
197+
expect(subject).to contain_exec('postgresql_initdb_instance_main')
198198
end
199199
end
200200

0 commit comments

Comments
 (0)