File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ # Define for granting roles to users.
2+ define postgresql::server::role_grant (
3+ $role ,
4+ $user ,
5+ $admin_option = false
6+ ) {
7+
8+ if $admin_option {
9+ $grant_cmd = " GRANT \" ${role} \" TO \" ${user} \" WITH ADMIN OPTION"
10+ } else {
11+ $grant_cmd = " GRANT \" ${role} \" TO \" ${user} \" "
12+ }
13+
14+ postgresql_psql { $grant_cmd:
15+ db => $on_db ,
16+ psql_user => $psql_user ,
17+ psql_group => $group ,
18+ psql_path => $psql_path ,
19+ unless => " SELECT 1 WHERE pg_has_role('${user} ', '${role} ', 'USAGE')" ,
20+ require => Class[' postgresql::server' ]
21+ }
22+
23+ if ($role != undef and defined (Postgresql::Server::Role[$role ])) {
24+ Postgresql::Server::Role[$role ]->Postgresql_psql[$grant_cmd ]
25+ }
26+
27+ if ($db != undef and defined (Postgresql::Server::Role[$user ])) {
28+ Postgresql::Server::Role[$user ]->Postgresql_psql[$grant_cmd ]
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments