X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/069e33163e0b09a7d647a98c2fde284a16a43b99..1d23c59f10b2636d9c20b3da441aa22373f88af4:/cookbooks/postgresql/providers/user.rb diff --git a/cookbooks/postgresql/providers/user.rb b/cookbooks/postgresql/providers/user.rb index 791368255..5df0f3847 100644 --- a/cookbooks/postgresql/providers/user.rb +++ b/cookbooks/postgresql/providers/user.rb @@ -17,13 +17,17 @@ # limitations under the License. # +require "shellwords" + +use_inline_resources + def load_current_resource @pg = Chef::PostgreSQL.new(new_resource.cluster) @current_resource = Chef::Resource::PostgresqlUser.new(new_resource.name) @current_resource.user(new_resource.user) @current_resource.cluster(new_resource.cluster) - if pg_user = @pg.users[@current_resource.user] + if (pg_user = @pg.users[@current_resource.user]) @current_resource.superuser(pg_user[:superuser]) @current_resource.createdb(pg_user[:createdb]) @current_resource.createrole(pg_user[:createrole]) @@ -33,7 +37,7 @@ def load_current_resource end action :create do - password = new_resource.password ? "ENCRYPTED PASSWORD '#{new_resource.password}'" : "" + password = new_resource.password ? "ENCRYPTED PASSWORD '#{new_resource.password.shellescape}'" : "" superuser = new_resource.superuser ? "SUPERUSER" : "NOSUPERUSER" createdb = new_resource.createdb ? "CREATEDB" : "NOCREATEDB" createrole = new_resource.createrole ? "CREATEROLE" : "NOCREATEROLE"