Skip to content

Commit a246e58

Browse files
committed
create role before database
Creating the role before creating the database is mandatory because otherwise granting the access right to the database fails.
1 parent 9c2399b commit a246e58

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

manifests/server/db.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
if ! defined(Postgresql::Server::Role[$user]) {
3030
postgresql::server::role { $user:
3131
password_hash => $password,
32+
before => Postgresql::Server::Database[$dbname],
3233
}
3334
}
3435

spec/unit/defines/server/db_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
it { is_expected.to contain_postgresql__server__db('test') }
3535
it { is_expected.to contain_postgresql__server__database('test').with_owner('tester') }
36-
it { is_expected.to contain_postgresql__server__role('test') }
36+
it { is_expected.to contain_postgresql__server__role('test').that_comes_before('Postgresql::Server::Database[test]') }
3737
it { is_expected.to contain_postgresql__server__database_grant('GRANT test - ALL - test') }
3838

3939
end

0 commit comments

Comments
 (0)