Sha256: 782ed3bd6a39cd99ad50c0d7ee0da38eedb576a3fbc22a6ec57d5a30a5c5cc36
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
namespace :mysql do task :install do on roles :db do not_if 'which mysql' do execute <<-EOBLOCK debconf-set-selections <<< 'mysql-server mysql-server/root_password password #{fetch :my_pass}' debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password #{fetch :my_pass}' apt-get install -y mysql-server mysql-client libmysqlclient-dev EOBLOCK end not_if "mysql --user='root' --password='#{fetch :my_pass}' --execute='show databases;' | grep #{fetch :application}" do execute <<-EOBLOCK mysql --user='root' --password='#{fetch :my_pass}' --execute='create database #{fetch :application};' mysql --user='root' --password='#{fetch :my_pass}' --execute="grant all on #{fetch :application}.* to #{fetch :my_user}@'%' identified by '#{fetch :my_pass}';" EOBLOCK end invoke 'mysql:restart' end end task :test do on roles :db do not_if "echo ''" do p 'executing ......' end end end %w(start stop restart).each do |action| desc "MySQL" task :"#{action}" do on roles(:app) do execute "sudo service mysql #{action}" end end end end def not_if(command) begin yield unless execute command rescue Exception yield end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
prun-ops-0.2.2 | lib/capistrano/config/mysql.rake |
prun-ops-0.2.1 | lib/capistrano/config/mysql.rake |
prun-ops-0.2.0 | lib/capistrano/config/mysql.rake |