Skip to content

Instantly share code, notes, and snippets.

@mattd
Created February 7, 2012 20:40
Show Gist options
  • Save mattd/1761802 to your computer and use it in GitHub Desktop.
Save mattd/1761802 to your computer and use it in GitHub Desktop.
db_password = "somepassword"
mysql_command = "mysql -u root -p#{node[:mysql][:server_root_password]} -e"
bash "setup_#{app}_db" do
code <<-EOH
#{mysql_command} "CREATE DATABASE #{app}"
#{mysql_command} "GRANT ALL PRIVILEGES ON #{app}.* \
TO '#{site}'@'localhost' \
IDENTIFIED BY '#{db_password}' \
WITH GRANT OPTION"
date > /var/lib/mysql/setup_#{app}_db
echo 'chef created #{app} database' >> /var/lib/mysql/setup_#{app}_db
EOH
not_if {File.exists?("/var/lib/mysql/setup_#{app}_db")}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment