X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/57997055a817d2104f605a56141ae26515aabbd2..cdb2f6f01940242c613b6c1d31332598dec7d625:/cookbooks/mysql/libraries/mysql.rb?ds=sidebyside diff --git a/cookbooks/mysql/libraries/mysql.rb b/cookbooks/mysql/libraries/mysql.rb index 2b2bca67d..91eb6f9d1 100644 --- a/cookbooks/mysql/libraries/mysql.rb +++ b/cookbooks/mysql/libraries/mysql.rb @@ -104,12 +104,14 @@ class Chef end query("SELECT * FROM db").each do |record| - if database = @databases[record[:db]] - user = "'#{record[:user]}'@'#{record[:host]}'" + database = @databases[record[:db]] - database[:permissions][user] = DATABASE_PRIVILEGES.each_with_object([]) do |privilege, privileges| - privileges << privilege if record["#{privilege}_priv".to_sym] == "Y" - end + next unless database + + user = "'#{record[:user]}'@'#{record[:host]}'" + + database[:permissions][user] = DATABASE_PRIVILEGES.each_with_object([]) do |privilege, privileges| + privileges << privilege if record["#{privilege}_priv".to_sym] == "Y" end end