Sha256: 75852160e0d35a94d2d7bde36ccd6f6d0a61c068b910ba47094e4c27fe26f4c0

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

if platform_family?("debian")

  root_dir = File.join(File.dirname(__FILE__), "..","..","..","..")
  $LOAD_PATH << File.join(root_dir, "lib")
  require 'toaster/util/config'

  cfg_db_pass = Toaster::Config.get("db.password")
  cfg_db_pass = "root" if "#{cfg_db_pass}".empty?
  node.set['mysql']['server_root_password'] = cfg_db_pass
  include_recipe "mysql::server"

  bash 'db_create' do
    code <<-EOH
    db_pass=#{node['mysql']['server_root_password']}
    ip_pattern=#{node["network"]["ip_pattern"].gsub('*','%')}
    echo 'create database toaster;' | mysql -u root -p$db_pass
    echo "GRANT ALL ON toaster.* TO 'root'@'$ip_pattern' IDENTIFIED BY '$db_pass';" | mysql -u root -p$db_pass
    echo "FLUSH PRIVILEGES;" | mysql -u root -p$db_pass
    cd #{root_dir}/webapp && ./bin/rake db:migrate RAILS_ENV=development
EOH
    not_if "echo \"show databases;\" | mysql -u root -p#{node['mysql']['server_root_password']} | grep toaster"
  end

else

  bash "error_os" do
    code <<-EOH
    echo "ERROR: Currently supported host OSs: Debian/Ubuntu."
    exit 1
EOH
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cloud-toaster-1.1.6 chef/cookbooks/lxc/recipes/setup_database.rb