X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/fb1f1d56e8d8a6a86b79c71546e6c114fec2640c..35f220a555dee107786152d3daff4d66d1655e56:/cookbooks/mysql/providers/database.rb?ds=sidebyside diff --git a/cookbooks/mysql/providers/database.rb b/cookbooks/mysql/providers/database.rb index 647925f26..0e7e9091a 100644 --- a/cookbooks/mysql/providers/database.rb +++ b/cookbooks/mysql/providers/database.rb @@ -17,12 +17,14 @@ # limitations under the License. # +use_inline_resources + def load_current_resource @mysql = Chef::MySQL.new @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 @@ -65,12 +67,10 @@ action :create do @mysql.execute(:command => "GRANT #{@mysql.privilege_name(privilege)} ON `#{new_resource.database}`.* TO #{user}") end end - else - if current_privileges.include?(privilege) - converge_by("revoke #{privilege} for #{user} on #{new_resource}") do - Chef::Log.info("Revoking #{privilege} for #{user} on #{new_resource}") - @mysql.execute(:command => "REVOKE #{@mysql.privilege_name(privilege)} ON `#{new_resource.database}`.* FROM #{user}") - end + elsif current_privileges.include?(privilege) + converge_by("revoke #{privilege} for #{user} on #{new_resource}") do + Chef::Log.info("Revoking #{privilege} for #{user} on #{new_resource}") + @mysql.execute(:command => "REVOKE #{@mysql.privilege_name(privilege)} ON `#{new_resource.database}`.* FROM #{user}") end end end