Skip to content

Commit

Permalink
tweaks to allow some failures when setting up mysql users and databases
Browse files Browse the repository at this point in the history
  • Loading branch information
jashmenn committed Jul 21, 2009
1 parent e35e674 commit e4cb16f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/extensions/mysql/database.rb
Expand Up @@ -2,6 +2,8 @@
== Overview
== Notes
== Usage
== Bugs
Needs some work on determining if these commands need to be run. Ignoring failures for now.
== References
=end

Expand All @@ -20,6 +22,7 @@ def create_database(name)
has_exec(:name => "create-#{name}-database", :command => "/usr/bin/mysqladmin #{permissions_string} create #{name}") do
# not_if "/usr/bin/mysqlshow #{permissions_string} #{name} | grep -q #{name}"
not_if "/usr/bin/mysqlshow #{permissions_string} | grep -q #{name}"
ignore_failure true
end
end

Expand All @@ -36,6 +39,7 @@ def grant_permissions_on_cloud_with_keypair_for_user(keypair, user, password)
def grant_permissions_on_host_for_user(host, user, password)
has_exec(:name => "create-#{name}-user-#{user}-#{host}", :command => %Q{/usr/bin/mysql #{permissions_string} -e 'grant all privileges on #{name}.* to \\"#{user}\\"@\\"#{host}\\" identified by \\"#{password}\\"'}) do
not_if %Q{mysql #{permissions_string} -e 'use mysql;select User,Host from user where User=\\"#{user}\\" AND Host=\\"#{host}\\"';}
ignore_failure true
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/extensions/mysql/mysql.rb
Expand Up @@ -36,9 +36,10 @@ def client
def root_password(passwd="root_password")
root_password_string passwd
pw_string = existing_root_password ? "-p#{existing_root_password}" : ""
has_exec(:name => "Change the root password",
has_exec(:name => "Change the root mysql password",
:command => "mysqladmin -uroot #{pw_string} password #{passwd}",
:not_if => "mysqladmin -uroot -p#{passwd} status",
:ignore_failure => true,
:subscribe => [:reload, get_package("mysql-server")])
end

Expand Down

0 comments on commit e4cb16f

Please sign in to comment.