capistrano_recipes 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/capistrano_recipes.gemspec +1 -1
- data/lib/capistrano/recipes/git.rb +0 -1
- data/lib/capistrano/recipes/mysql.rb +16 -12
- data/lib/capistrano_recipes.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e78c7154d5a61df05a26fa96ebae0b6f29d6ecb
|
4
|
+
data.tar.gz: 27b8455987d54d5676a5f27f5aff825dd8beea8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef431fd46ed70b81bed968e342a65964bc1eeed6d3558ad09df1880ea478091f4213057e285fe33c7bead08cd52ec91fe65aed5e652305cdfdd4c78ef6a60ed9
|
7
|
+
data.tar.gz: 1e44229c200d5f54872a89b2fc313caaf632b935dbf12a44b474d8d14b0b68222c8a856fba1b9781bc0fa164aec48955b99e95abda29b758d26bd9d246635489
|
data/capistrano_recipes.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'capistrano_recipes'
|
7
|
-
s.version = '1.
|
7
|
+
s.version = '1.3.0'
|
8
8
|
s.authors = ['Fernando Aleman']
|
9
9
|
s.email = ['fernandoaleman@mac.com']
|
10
10
|
s.description = 'Capistrano recipes to make your deployments fast and easy'
|
@@ -2,15 +2,19 @@ module CapistranoRecipes
|
|
2
2
|
module Mysql
|
3
3
|
def self.load_into(configuration)
|
4
4
|
configuration.load do
|
5
|
+
|
6
|
+
# MySQL command
|
7
|
+
_cset :mysql_command, lambda { 'mysqld' }
|
8
|
+
|
5
9
|
# MySQL admin user with access to create databases and grant permissions
|
6
10
|
_cset :mysql_admin_user, lambda { ask "Enter #{rails_env} database username with access to create database" }
|
7
11
|
|
8
12
|
# Application database adapter
|
9
13
|
_cset :mysql_adapter, lambda { 'mysql2' }
|
10
|
-
|
14
|
+
|
11
15
|
# Application database name
|
12
16
|
_cset :mysql_database, lambda { "#{application}_#{rails_env}" }
|
13
|
-
|
17
|
+
|
14
18
|
# Application database user
|
15
19
|
_cset :mysql_user, lambda { ask "Enter #{rails_env} database username" }
|
16
20
|
|
@@ -51,17 +55,17 @@ module CapistranoRecipes
|
|
51
55
|
desc 'Create mysql database'
|
52
56
|
task :create, :roles => :db, :only => { :primary => true } do
|
53
57
|
prepare_from_yaml
|
54
|
-
|
58
|
+
|
55
59
|
db_exists = false
|
56
|
-
|
60
|
+
|
57
61
|
mysql_admin = mysql_admin_user
|
58
62
|
pass = password_prompt "Enter database password for '#{mysql_admin}'"
|
59
|
-
|
60
|
-
run "echo \"SHOW DATABASES\" | mysql -u #{mysql_admin} -p" do |channel, stream, data|
|
63
|
+
|
64
|
+
run "echo \"SHOW DATABASES\" | mysql -h #{mysql_host} -u #{mysql_admin} -p" do |channel, stream, data|
|
61
65
|
if data =~ /^Enter password:/
|
62
66
|
channel.send_data "#{pass}\n"
|
63
67
|
end
|
64
|
-
|
68
|
+
|
65
69
|
if data =~ /^Database/
|
66
70
|
db_exists = db_exists || data.include?(db_name)
|
67
71
|
end
|
@@ -73,8 +77,8 @@ module CapistranoRecipes
|
|
73
77
|
sql = "CREATE DATABASE #{db_name};"\
|
74
78
|
"GRANT ALL PRIVILEGES ON #{db_name}.* TO #{db_user}@localhost IDENTIFIED BY '#{db_pass}';"\
|
75
79
|
"FLUSH PRIVILEGES;"
|
76
|
-
|
77
|
-
run "echo \"#{sql}\" | mysql -u #{mysql_admin} -p" do |channel, stream, data|
|
80
|
+
|
81
|
+
run "echo \"#{sql}\" | mysql -h #{mysql_host} -u #{mysql_admin} -p" do |channel, stream, data|
|
78
82
|
if data =~ /^Enter password:/
|
79
83
|
channel.send_data "#{pass}\n"
|
80
84
|
end
|
@@ -124,7 +128,7 @@ module CapistranoRecipes
|
|
124
128
|
%w[start stop restart status].each do |command|
|
125
129
|
desc "#{command.capitalize} mysql"
|
126
130
|
task command, :roles => :db, :only => { :primary => true } do
|
127
|
-
run "#{sudo} service
|
131
|
+
run "#{sudo} service #{mysql_command} #{command}"
|
128
132
|
end
|
129
133
|
end
|
130
134
|
end
|
@@ -135,11 +139,11 @@ module CapistranoRecipes
|
|
135
139
|
set(:db_host) { db_config[rails_env]["host"] }
|
136
140
|
set(:db_name) { db_config[rails_env]["database"] }
|
137
141
|
end
|
138
|
-
|
142
|
+
|
139
143
|
def db_config
|
140
144
|
@db_config ||= fetch_db_config
|
141
145
|
end
|
142
|
-
|
146
|
+
|
143
147
|
def fetch_db_config
|
144
148
|
require 'yaml'
|
145
149
|
file = capture "cat #{mysql_remote_config_file}"
|
data/lib/capistrano_recipes.rb
CHANGED
@@ -15,11 +15,13 @@ module CapistranoRecipes
|
|
15
15
|
_cset :pids_path, lambda { File.join shared_path, 'pids' }
|
16
16
|
_cset :sockets_path, lambda { File.join shared_path, 'sockets' }
|
17
17
|
|
18
|
-
set :user, 'deployer'
|
18
|
+
set :user, lambda { 'deployer' }
|
19
19
|
|
20
20
|
default_run_options[:pty] = true
|
21
21
|
ssh_options[:forward_agent] = true
|
22
22
|
|
23
|
+
set :use_sudo, false
|
24
|
+
|
23
25
|
@used_recipes = []
|
24
26
|
|
25
27
|
class << self
|