superuser = new_resource.superuser ? "SUPERUSER" : "NOSUPERUSER"
createdb = new_resource.createdb ? "CREATEDB" : "NOCREATEDB"
createrole = new_resource.createrole ? "CREATEROLE" : "NOCREATEROLE"
replication = new_resource.replication ? "REPLICATION" : "NOREPLICATION"
if !@pg.users.include?(new_resource.user)
superuser = new_resource.superuser ? "SUPERUSER" : "NOSUPERUSER"
createdb = new_resource.createdb ? "CREATEDB" : "NOCREATEDB"
createrole = new_resource.createrole ? "CREATEROLE" : "NOCREATEROLE"
replication = new_resource.replication ? "REPLICATION" : "NOREPLICATION"
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)
+ converge_by "create role #{new_resource.user}" do
+ @pg.execute(:command => "CREATE ROLE \"#{new_resource.user}\" LOGIN #{password} #{superuser} #{createdb} #{createrole}")
+ end
- @pg.execute(:command => "ALTER ROLE \"#{new_resource.user}\" #{superuser}")
- new_resource.updated_by_last_action(true)
+ converge_by "alter role #{new_resource.user}" do
+ @pg.execute(:command => "ALTER ROLE \"#{new_resource.user}\" #{superuser}")
+ end
- @pg.execute(:command => "ALTER ROLE \"#{new_resource.user}\" #{createdb}")
- new_resource.updated_by_last_action(true)
+ converge_by "alter role #{new_resource.user}" do
+ @pg.execute(:command => "ALTER ROLE \"#{new_resource.user}\" #{createdb}")
+ end
- @pg.execute(:command => "ALTER ROLE \"#{new_resource.user}\" #{createrole}")
- new_resource.updated_by_last_action(true)
+ converge_by "alter role #{new_resource.user}" do
+ @pg.execute(:command => "ALTER ROLE \"#{new_resource.user}\" #{createrole}")
+ end
- @pg.execute(:command => "ALTER ROLE \"#{new_resource.user}\" #{replication}")
- new_resource.updated_by_last_action(true)
+ converge_by "alter role #{new_resource.user}" do
+ @pg.execute(:command => "ALTER ROLE \"#{new_resource.user}\" #{replication}")
+ end
- @pg.execute(:command => "DROP ROLE \"#{new_resource.user}\"")
- new_resource.updated_by_last_action(true)
+ converge_by "drop role #{new_resource.user}" do
+ @pg.execute(:command => "DROP ROLE \"#{new_resource.user}\"")
+ end