Skip to content

Commit 507a69f

Browse files
committed
Use autorequires
1 parent 64198cd commit 507a69f

File tree

6 files changed

+8
-10
lines changed

6 files changed

+8
-10
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::passwd' }
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 => [],
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 => [],
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
it do
5353
is_expected.to contain_postgresql_psql('grant:test'). \
5454
with_command(/GRANT USAGE ON SEQUENCE "test" TO\s* "test"/m). \
55-
with_unless(/SELECT 1 WHERE has_sequence_privilege\('test',\s* 'test', 'USAGE'\)/m)
55+
with_unless(/SELECT 1 WHERE has_sequence_privilege\('test',\s* 'test', 'USAGE'\)/m). \
56+
that_requires('Class[postgresql::server::passwd]')
5657
end
5758
end
5859

0 commit comments

Comments
 (0)