Skip to content

Commit

Permalink
Grant roles to newly created users
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Oct 15, 2023
1 parent 5f259f2 commit 23961a3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cookbooks/postgresql/resources/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
converge_by "create role #{new_resource.user}" do
cluster.execute(:command => "CREATE ROLE \"#{new_resource.user}\" LOGIN #{password} #{superuser} #{createdb} #{createrole}")
end

Array(new_resource.roles).each do |role|
converge_by "grant #{role} to #{new_resource.user}" do
cluster.execute(:command => "GRANT \"#{role}\" TO \"#{new_resource.user}\"")
end
end
else
current_user = cluster.users[new_resource.user]

Expand Down

0 comments on commit 23961a3

Please sign in to comment.