Skip to content

Commit 964f5ea

Browse files
committed
Autorequire the service class for postgresql_psql
1 parent 64198cd commit 964f5ea

File tree

9 files changed

+12
-13
lines changed

9 files changed

+12
-13
lines changed

lib/puppet/type/postgresql_psql.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def matches(value)
119119
newvalues(:true, :false)
120120
end
121121

122+
autorequire(:class) { ['Postgresql::Server::Service'] }
123+
122124
def should_run_sql(refreshing = false)
123125
onlyif_param = @parameters[:onlyif]
124126
unless_param = @parameters[:unless]

manifests/server/grant.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@
334334
psql_path => $psql_path,
335335
unless => $_unless,
336336
onlyif => $_onlyif,
337-
require => Class['postgresql::server']
338337
}
339338

340339
if($role != undef and defined(Postgresql::Server::Role[$role])) {

manifests/server/reassign_owned_by.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
psql_group => $group,
4646
psql_path => $psql_path,
4747
onlyif => $onlyif,
48-
require => Class['postgresql::server']
4948
}
5049

5150
if($old_role != undef and defined(Postgresql::Server::Role[$old_role])) {

manifests/server/role.pp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@
4747
psql_path => $psql_path,
4848
connect_settings => $connect_settings,
4949
cwd => $module_workdir,
50-
require => [
51-
Postgresql_psql["CREATE ROLE ${username} ENCRYPTED PASSWORD ****"],
52-
Class['postgresql::server'],
53-
],
50+
require => Postgresql_psql["CREATE ROLE ${username} ENCRYPTED PASSWORD ****"],
5451
}
5552

5653
if $ensure == 'present' {
@@ -72,7 +69,7 @@
7269
command => "CREATE ROLE \"${username}\" ${password_sql} ${login_sql} ${createrole_sql} ${createdb_sql} ${superuser_sql} ${replication_sql} CONNECTION LIMIT ${connection_limit}",
7370
unless => "SELECT 1 FROM pg_roles WHERE rolname = '${username}'",
7471
environment => $environment,
75-
require => Class['Postgresql::Server'],
72+
require => undef,
7673
}
7774

7875
postgresql_psql {"ALTER ROLE \"${username}\" ${superuser_sql}":
@@ -128,7 +125,7 @@
128125
# ensure == absent
129126
postgresql_psql { "DROP ROLE \"${username}\"":
130127
onlyif => "SELECT 1 FROM pg_roles WHERE rolname = '${username}'",
131-
require => Class['Postgresql::Server'],
128+
require => undef,
132129
}
133130
}
134131
}

manifests/server/tablespace.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
postgresql_psql { "CREATE TABLESPACE \"${spcname}\"":
4141
command => "CREATE TABLESPACE \"${spcname}\" LOCATION '${location}'",
4242
unless => "SELECT 1 FROM pg_tablespace WHERE spcname = '${spcname}'",
43-
require => [Class['postgresql::server'], File[$location]],
43+
require => File[$location],
4444
}
4545

4646
if $owner {

spec/unit/defines/server/grant_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class {'postgresql::server':}
218218
it { is_expected.to contain_postgresql__server__role('test') }
219219
it do
220220
is_expected.to contain_postgresql_psql('grant:test'). \
221-
that_requires('Postgresql::Server::Role[test]')
221+
that_requires(['Class[postgresql::server::service]', 'Postgresql::Server::Role[test]'])
222222
end
223223
end
224224

spec/unit/defines/server/reassign_owned_by_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ class {'postgresql::server':}
3232
EOS
3333
end
3434

35+
it { is_expected.to compile.with_all_deps }
3536
it { is_expected.to contain_postgresql__server__reassign_owned_by('test') }
3637

3738
it {
3839
is_expected.to contain_postgresql_psql('reassign_owned_by:test:REASSIGN OWNED BY "test_old_role" TO "test_new_role"').with({
3940
'command' => "REASSIGN OWNED BY \"test_old_role\" TO \"test_new_role\"",
4041
'onlyif' => /SELECT tablename FROM pg_catalog.pg_tables WHERE\s*schemaname NOT IN \('pg_catalog', 'information_schema'\) AND\s*tableowner = 'test_old_role'.*/m,
41-
}).that_requires('Class[postgresql::server]')
42+
}).that_requires('Class[Postgresql::Server::Service]')
4243
}
4344

4445
end

spec/unit/defines/server/role_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
'DBVERSION' => '9.1',
7373
'PGUSER' => 'login-user',
7474
'PGPASSWORD' => 'login-pass' },
75-
})
75+
}).that_requires('Class[postgresql::server::service]')
7676
end
7777
it 'should have alter role for "test" user with password as ****' do
7878
is_expected.to contain_postgresql_psql('ALTER ROLE test ENCRYPTED PASSWORD ****').with({
@@ -161,7 +161,7 @@
161161
end
162162

163163
it 'should have drop role for "test" user if ensure absent' do
164-
is_expected.to contain_postgresql_psql('DROP ROLE "test"')
164+
is_expected.to contain_postgresql_psql('DROP ROLE "test"').that_requires('Class[postgresql::server::service]')
165165
end
166166
end
167167

spec/unit/defines/server/tablespace_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
end
2929

3030
it { is_expected.to contain_postgresql__server__tablespace('test') }
31+
it { is_expected.to contain_postgresql_psql('CREATE TABLESPACE "test"').that_requires('Class[postgresql::server::service]') }
3132

3233
context "with different owner" do
3334
let :params do

0 commit comments

Comments
 (0)