X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/faf8ae12e85eabb050b0f5eceb2cb67ad1de5261..4c86175022c9036999f9d8341e48cbd884448709:/cookbooks/mysql/providers/database.rb diff --git a/cookbooks/mysql/providers/database.rb b/cookbooks/mysql/providers/database.rb index 29b38f70e..6e488ce47 100644 --- a/cookbooks/mysql/providers/database.rb +++ b/cookbooks/mysql/providers/database.rb @@ -22,7 +22,7 @@ def load_current_resource @current_resource = Chef::Resource::MysqlDatabase.new(new_resource.name) @current_resource.database(new_resource.database) - if mysql_database = @mysql.databases[@current_resource.database] + if (mysql_database = @mysql.databases[@current_resource.database]) @current_resource.permissions(mysql_database[:permissions]) end @current_resource @@ -36,20 +36,20 @@ action :create do end end - new_permissions = Hash[new_resource.permissions.collect do |user,privileges| + new_permissions = Hash[new_resource.permissions.collect do |user, privileges| [@mysql.canonicalise_user(user), privileges] end] - @current_resource.permissions.each do |user,privileges| - unless new_permissions[user] - converge_by("revoke all for #{user} on #{new_resource}") do - Chef::Log.info("Revoking all for #{user} on #{new_resource}") - @mysql.execute(:command => "REVOKE ALL ON `#{new_resource.database}`.* FROM #{user}") - end + @current_resource.permissions.each_key do |user| + next if new_permissions[user] + + converge_by("revoke all for #{user} on #{new_resource}") do + Chef::Log.info("Revoking all for #{user} on #{new_resource}") + @mysql.execute(:command => "REVOKE ALL ON `#{new_resource.database}`.* FROM #{user}") end end - new_permissions.each do |user,new_privileges| + new_permissions.each do |user, new_privileges| current_privileges = @current_resource.permissions[user] || {} new_privileges = Array(new_privileges)