Skip to content

Commit 09bbfe2

Browse files
committed
Use autorequires
1 parent 163175e commit 09bbfe2

File tree

6 files changed

+7
-9
lines changed

6 files changed

+7
-9
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: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,14 @@
6060
psql_path => $psql_path,
6161
connect_settings => $connect_settings,
6262
cwd => $module_workdir,
63-
require => [
64-
Postgresql_psql["CREATE ROLE ${username} ENCRYPTED PASSWORD ****"],
65-
Class['postgresql::server'],
66-
],
63+
require => Postgresql_psql["CREATE ROLE ${username} ENCRYPTED PASSWORD ****"],
6764
}
6865

6966
postgresql_psql { "CREATE ROLE ${username} ENCRYPTED PASSWORD ****":
7067
command => "CREATE ROLE \"${username}\" ${password_sql} ${login_sql} ${createrole_sql} ${createdb_sql} ${superuser_sql} ${replication_sql} CONNECTION LIMIT ${connection_limit}",
7168
unless => "SELECT 1 FROM pg_roles WHERE rolname = '${username}'",
7269
environment => $environment,
73-
require => Class['Postgresql::Server'],
70+
require => [],
7471
}
7572

7673
postgresql_psql {"ALTER ROLE \"${username}\" ${superuser_sql}":

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)