Skip to content

Commit d69ff1e

Browse files
committed
Autorequire the service class for postgresql_psql
1 parent 5c2bc6e commit d69ff1e

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

lib/puppet/type/postgresql_psql.rb

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

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

manifests/server/grant.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@
413413
psql_path => $psql_path,
414414
unless => $_unless,
415415
onlyif => $_onlyif,
416-
require => Class['postgresql::server']
417416
}
418417

419418
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
@@ -210,7 +210,7 @@ class {'postgresql::server':}
210210
it { is_expected.to contain_postgresql__server__role('test') }
211211
it do
212212
is_expected.to contain_postgresql_psql('grant:test') \
213-
.that_requires('Postgresql::Server::Role[test]')
213+
.that_requires(['Class[postgresql::server::service]', 'Postgresql::Server::Role[test]'])
214214
end
215215
end
216216

spec/unit/defines/server/reassign_owned_by_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ class {'postgresql::server':}
3232
MANIFEST
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"')
3940
.with_command('REASSIGN OWNED BY "test_old_role" TO "test_new_role"')
4041
.with_onlyif(%r{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
end

spec/unit/defines/server/role_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
.with_unless("SELECT 1 FROM pg_roles WHERE rolname = 'test'")
6767
.with_port(5432)
6868
.with_connect_settings('PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1', 'PGUSER' => 'login-user', 'PGPASSWORD' => 'login-pass')
69+
.that_requires('Class[postgresql::server::service]')
6970
end
7071
it 'has alter role for "test" user with password as ****' do
7172
is_expected.to contain_postgresql_psql('ALTER ROLE test ENCRYPTED PASSWORD ****')
@@ -138,7 +139,7 @@
138139
end
139140

140141
it 'has drop role for "test" user if ensure absent' do
141-
is_expected.to contain_postgresql_psql('DROP ROLE "test"')
142+
is_expected.to contain_postgresql_psql('DROP ROLE "test"').that_requires('Class[postgresql::server::service]')
142143
end
143144
end
144145
end

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)