]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/postgresql/providers/user.rb
Merge pull request #50 from Firefishy/add-imagery
[chef.git] / cookbooks / postgresql / providers / user.rb
index 11c783e22264f1b132dae4b1c8ec7ce0c1d41df1..5a1402d40389f28ff5a388dc3068788cf7c19f6b 100644 (file)
 # limitations under the License.
 #
 
+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])
@@ -39,7 +41,7 @@ action :create do
   createrole = new_resource.createrole ? "CREATEROLE" : "NOCREATEROLE"
   replication = new_resource.replication ? "REPLICATION" : "NOREPLICATION"
 
-  unless @pg.users.include?(new_resource.user)
+  if !@pg.users.include?(new_resource.user)
     @pg.execute(:command => "CREATE ROLE \"#{new_resource.user}\" LOGIN #{password} #{superuser} #{createdb} #{createrole}")
     new_resource.updated_by_last_action(true)
   else