Sha256: 746cc9694a61041de1b47e95a6ae96b390fa0a15e2333acd741731c281426e26

Contents?: true

Size: 1.31 KB

Versions: 20

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

20 entries across 20 versions & 1 rubygems

Version Path
prun-ops-0.3.4 lib/capistrano/config/mysql.rake
prun-ops-0.3.3 lib/capistrano/config/mysql.rake
prun-ops-0.3.2 lib/capistrano/config/mysql.rake
prun-ops-0.3.1 lib/capistrano/config/mysql.rake
prun-ops-0.3.0 lib/capistrano/config/mysql.rake
prun-ops-0.2.18 lib/capistrano/config/mysql.rake
prun-ops-0.2.17 lib/capistrano/config/mysql.rake
prun-ops-0.2.16 lib/capistrano/config/mysql.rake
prun-ops-0.2.15 lib/capistrano/config/mysql.rake
prun-ops-0.2.14 lib/capistrano/config/mysql.rake
prun-ops-0.2.13 lib/capistrano/config/mysql.rake
prun-ops-0.2.12 lib/capistrano/config/mysql.rake
prun-ops-0.2.11 lib/capistrano/config/mysql.rake
prun-ops-0.2.10 lib/capistrano/config/mysql.rake
prun-ops-0.2.9 lib/capistrano/config/mysql.rake
prun-ops-0.2.8 lib/capistrano/config/mysql.rake
prun-ops-0.2.7 lib/capistrano/config/mysql.rake
prun-ops-0.2.6 lib/capistrano/config/mysql.rake
prun-ops-0.2.4 lib/capistrano/config/mysql.rake
prun-ops-0.2.3 lib/capistrano/config/mysql.rake