capistrano-didi 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +6 -0
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/bin/didify +79 -1
- data/capistrano-didi.gemspec +2 -2
- data/lib/didi/recipes/didi.rb +53 -31
- metadata +4 -4
data/CHANGELOG.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.4.2 19 June 2012
|
2
|
+
|
3
|
+
* fixed issue in deploy:setup where "chown" was created as a folder
|
4
|
+
* added support for cleaning up sql dump in manage:pull_dump
|
5
|
+
* added new task: manage:push_dump to copy local database to remote
|
6
|
+
|
1
7
|
## 0.4.1 22 May 2012
|
2
8
|
|
3
9
|
* fix compatibility with capistrano 2.12.0
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= didi
|
2
2
|
|
3
|
-
Didi is an collection of capistrano recipes that
|
3
|
+
Didi is an collection of capistrano recipes that enables automated deployment and continuous integration of drupal websites. Once you have configured different hosting environments you can use the "didi" command to interact with them.
|
4
4
|
|
5
5
|
== What can didi do you for?
|
6
6
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/bin/didify
CHANGED
@@ -67,7 +67,85 @@ set :sitemail, "drupal_site_email_address"
|
|
67
67
|
set :adminpass, "drupal_admin_pass"
|
68
68
|
|
69
69
|
set :baseline, "drupal_feature_to_activate_after_fresh_install"
|
70
|
-
'
|
70
|
+
',
|
71
|
+
"config/sql/staging.sql" => <<scrub
|
72
|
+
--
|
73
|
+
-- Scrub important information from a Drupal database.
|
74
|
+
--
|
75
|
+
|
76
|
+
-- Remove all email addresses.
|
77
|
+
UPDATE users SET mail=CONCAT('user', uid, '@example.com'), init=CONCAT('user', uid, '@example.com') WHERE uid != 0;
|
78
|
+
|
79
|
+
-- Example: Disable a module by setting its system.status value to 0.
|
80
|
+
-- UPDATE system SET status = 0 WHERE name = 'securepages';
|
81
|
+
|
82
|
+
-- Example: Update or delete variables via the variable table.
|
83
|
+
-- DELETE FROM variable WHERE name='secret_key';
|
84
|
+
-- Note that to update variables the value must be a properly serialized php array.
|
85
|
+
-- UPDATE variable SET value='s:24:"http://test.gateway.com/";' WHERE name='payment_gateway';
|
86
|
+
|
87
|
+
-- IMPORTANT: If you change the variable table, clear the variables cache.
|
88
|
+
-- DELETE FROM cache WHERE cid = 'variables';
|
89
|
+
|
90
|
+
-- Scrub url aliases for non-admins since these also reveal names
|
91
|
+
-- Add the IGNORE keyword, since a user may have multiple aliases, and without
|
92
|
+
-- this keyword the attempt to store duplicate dst values causes the query to fail.
|
93
|
+
-- UPDATE IGNORE url_alias SET dst = CONCAT('users/', REPLACE(src,'/', '')) WHERE src IN (SELECT CONCAT('user/', u.uid) FROM users u WHERE u.uid NOT IN (SELECT uid FROM users_roles WHERE rid=3) AND u.uid > 0);
|
94
|
+
|
95
|
+
-- don't leave e-mail addresses, etc in comments table.
|
96
|
+
-- UPDATE comments SET name='Anonymous', mail='', homepage='http://example.com' WHERE uid=0;
|
97
|
+
|
98
|
+
-- Scrub webform submissions.
|
99
|
+
-- UPDATE webform_submitted_data set data='*scrubbed*';
|
100
|
+
|
101
|
+
-- remove sensitive customer data from custom module
|
102
|
+
-- TRUNCATE custom_customer_lead_data;
|
103
|
+
|
104
|
+
-- USER PASSWORDS
|
105
|
+
-- These statements assume you want to preserve real passwords for developers. Change 'rid=3' to the
|
106
|
+
-- developer or test role you want to preserve.
|
107
|
+
|
108
|
+
-- DRUPAL 6
|
109
|
+
-- Remove passwords unless users have 'developer role'
|
110
|
+
-- UPDATE users SET pass=md5('devpassword') WHERE uid IN (SELECT uid FROM users_roles WHERE rid=3) AND uid > 0;
|
111
|
+
|
112
|
+
-- Admin user should not be same but not really well known
|
113
|
+
-- UPDATE users SET pass = MD5('supersecret!') WHERE uid = 1;
|
114
|
+
|
115
|
+
-- DRUPAL 7
|
116
|
+
-- Drupal 7 requires sites to generate a hashed password specific to their site. A script in the
|
117
|
+
-- docroot/scripts directory is provided for doing this. From your docroot run the following:
|
118
|
+
--
|
119
|
+
-- scripts/password-hash.sh password
|
120
|
+
--
|
121
|
+
-- this will generate a hash for the password "password". In the following statements replace
|
122
|
+
-- $REPLACE THIS$ with your generated hash.
|
123
|
+
|
124
|
+
-- Remove passwords unless users have 'developer role'
|
125
|
+
-- UPDATE users SET pass='$REPLACE THIS$' WHERE uid IN (SELECT uid FROM users_roles WHERE rid=3) AND uid > 0;
|
126
|
+
|
127
|
+
-- Admin user should not be same but not really well known
|
128
|
+
-- UPDATE users SET pass='$REPLACE THIS$' WHERE uid = 1;
|
129
|
+
|
130
|
+
-- TRUNCATE accesslog;
|
131
|
+
-- TRUNCATE access;
|
132
|
+
-- TRUNCATE cache;
|
133
|
+
-- TRUNCATE cache_filter;
|
134
|
+
-- TRUNCATE cache_menu;
|
135
|
+
-- TRUNCATE cache_page;
|
136
|
+
-- TRUNCATE cache_views;
|
137
|
+
-- TRUNCATE cache_views_data;
|
138
|
+
-- TRUNCATE devel_queries;
|
139
|
+
-- TRUNCATE devel_times;
|
140
|
+
-- TRUNCATE flood;
|
141
|
+
-- TRUNCATE history;
|
142
|
+
-- TRUNCATE search_dataset;
|
143
|
+
-- TRUNCATE search_index;
|
144
|
+
-- TRUNCATE search_total;
|
145
|
+
-- TRUNCATE sessions;
|
146
|
+
-- TRUNCATE watchdog;
|
147
|
+
scrub
|
148
|
+
}
|
71
149
|
|
72
150
|
base = ARGV.shift
|
73
151
|
files.each do |file, content|
|
data/capistrano-didi.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "capistrano-didi"
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Koen Van Winckel"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-06-19"
|
13
13
|
s.description = "didi is a collection of recipes for capistrano that allow drupal to be deployed, tested and used in a CI environment"
|
14
14
|
s.email = "koenvw@gmail.com"
|
15
15
|
s.executables = ["didify", "didi"]
|
data/lib/didi/recipes/didi.rb
CHANGED
@@ -28,14 +28,15 @@ set :drupal_version, '7'
|
|
28
28
|
set :keep_releases, 5
|
29
29
|
set :use_sudo, false
|
30
30
|
|
31
|
-
set :domain,
|
32
|
-
set :db_host,
|
33
|
-
set :drupal_path,
|
34
|
-
set :srv_usr,
|
35
|
-
set :enable_robots,
|
36
|
-
set :no_disable,
|
37
|
-
set :local_database,
|
38
|
-
set :backup_database,
|
31
|
+
set :domain, 'default'
|
32
|
+
set :db_host, 'localhost'
|
33
|
+
set :drupal_path, 'drupal'
|
34
|
+
set :srv_usr, 'www-data'
|
35
|
+
set :enable_robots, false
|
36
|
+
set :no_disable, true
|
37
|
+
set :local_database, nil
|
38
|
+
set :backup_database, true
|
39
|
+
set :push_dump_enabled, false
|
39
40
|
|
40
41
|
ssh_options[:forward_agent] = true
|
41
42
|
#ssh_options[:verbose] = :debug #FIXME
|
@@ -63,6 +64,8 @@ _cset(:previous_release_settings) { releases.length > 1 ? domain.to_a.map {
|
|
63
64
|
_cset(:previous_release_files) { releases.length > 1 ? domain.to_a.map { |d| File.join(previous_release, drupal_path, 'sites', d, files) } : nil }
|
64
65
|
_cset(:previous_release_domain) { releases.length > 1 ? domain.to_a.map { |d| File.join(previous_release, drupal_path, 'sites', d) } : nil }
|
65
66
|
|
67
|
+
_cset(:is_multisite) { domain.to_a.size > 1 }
|
68
|
+
|
66
69
|
# =========================================================================
|
67
70
|
# Extra dependecy checks
|
68
71
|
# =========================================================================
|
@@ -116,9 +119,7 @@ namespace :deploy do
|
|
116
119
|
dirs += domain.map { |d| File.join(shared_path, d) }
|
117
120
|
|
118
121
|
run <<-CMD
|
119
|
-
mkdir -p #{dirs.join(' ')}
|
120
|
-
#{try_sudo} chown #{user}:#{srv_usr} #{shared_files.join(' ')} &&
|
121
|
-
#{try_sudo} chmod g+w #{shared_files.join(' ')}
|
122
|
+
mkdir -p #{dirs.join(' ')} && #{try_sudo} chown #{user}:#{srv_usr} #{shared_files.join(' ')} && #{try_sudo} chmod g+w #{shared_files.join(' ')}
|
122
123
|
CMD
|
123
124
|
|
124
125
|
#create drupal config file
|
@@ -157,7 +158,7 @@ namespace :deploy do
|
|
157
158
|
|
158
159
|
if previous_release
|
159
160
|
# FIXME: executes on initial deploy:cold?
|
160
|
-
# FIXME: this breaks the current site
|
161
|
+
# FIXME: this breaks the current site until deploy:symlink is executed ?
|
161
162
|
previous_release_domain.each_with_index do |prd, i|
|
162
163
|
run "if [ -d #{prd} ]; then chmod 777 #{prd}; fi" # if drupal changed the permissions of the folder
|
163
164
|
run <<-CMD
|
@@ -330,10 +331,10 @@ namespace :drush do
|
|
330
331
|
desc "Update via drush, runs fra, updb and cc"
|
331
332
|
task :update do
|
332
333
|
dissite unless no_disable
|
333
|
-
updb
|
334
|
-
cc # fix for user_permissions constraint
|
335
|
-
fra
|
336
|
-
cc # for
|
334
|
+
updb # database updates (also handles modules that have been moved around)
|
335
|
+
cc # fix for user_permissions constraint (install new modules)
|
336
|
+
fra # reverts all features
|
337
|
+
cc # clear cache (required for new menu items, hook_menu)
|
337
338
|
ensite unless no_disable
|
338
339
|
manage.block_robots unless enable_robots
|
339
340
|
end
|
@@ -424,26 +425,47 @@ namespace :manage do
|
|
424
425
|
|
425
426
|
desc 'Dump remote database and restore locally'
|
426
427
|
task :pull_dump do
|
427
|
-
if
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
428
|
+
abort("ERROR: multisite not supported") if is_multisite
|
429
|
+
abort("NO LOCAL DATABASE FOUND, set :local_database in the config file..") if local_database.nil?
|
430
|
+
|
431
|
+
set(:runit, Capistrano::CLI.ui.ask("WARNING!! will overwrite this local database: '#{local_database}', type 'yes' to continue: "))
|
432
|
+
if runit == 'yes'
|
433
|
+
sql_file = File.join(dbbackups_path, "#{releases.last}-pull.sql")
|
434
|
+
# dump & gzip remote file
|
435
|
+
run "cd #{current_path}/#{drupal_path} && #{drush_path}drush sql-dump > #{sql_file} && gzip -f #{sql_file}"
|
436
|
+
# copy to local
|
437
|
+
system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
|
438
|
+
download "#{sql_file}.gz", "build/", :once => true, :via => :scp
|
439
|
+
run "rm #{sql_file}.gz"
|
440
|
+
# extract and restore
|
441
|
+
system "gunzip -f build/#{File.basename(sql_file)}.gz && echo \"DROP DATABASE #{local_database};CREATE DATABASE #{local_database}\" | mysql && mysql #{local_database} < build/#{File.basename(sql_file)}" if local_database
|
442
|
+
# check if file sanitation sql file exists
|
443
|
+
if File.exists?("config/sql/#{stage}.sql")
|
444
|
+
puts " * executing \"config/sql/#{stage}.sql\""
|
445
|
+
system "mysql #{local_database} < config/sql/#{stage}.sql"
|
441
446
|
end
|
442
447
|
end
|
443
448
|
end
|
444
449
|
|
445
450
|
task :push_dump do
|
446
|
-
|
451
|
+
abort("ERROR: multisite not supported") if is_multisite
|
452
|
+
abort("NO LOCAL DATABASE FOUND, set :local_database in the config file..") if local_database.nil?
|
453
|
+
abort("THIS STAGE: #{stage} DOES NOT SUPPORT manage:push_dump") if push_dump_enabled.nil?
|
454
|
+
|
455
|
+
set(:runit, Capistrano::CLI.ui.ask("WARNING!! will overwrite this REMOTE database: '#{db_name}', type 'yes' to continue: "))
|
456
|
+
if runit == 'yes'
|
457
|
+
sql_file = "#{Time.now.to_i}.sql"
|
458
|
+
system "if [ ! -d build ]; then mkdir build; fi" # create build folder locally if needed
|
459
|
+
# dump & gzip local file
|
460
|
+
system "cd #{drupal_path} && drush sql-dump > ../build/#{sql_file} && gzip ../build/#{sql_file}"
|
461
|
+
# copy to remote
|
462
|
+
upload "build/#{sql_file}.gz", File.join(dbbackups_path, "#{sql_file}.gz"), :once => true, :via => :scp
|
463
|
+
system "rm build/#{sql_file}.gz"
|
464
|
+
# extract and restore
|
465
|
+
run "gunzip -f #{File.join(dbbackups_path, "#{sql_file}.gz")} && cd #{current_path}/#{drupal_path} && #{drush_path}drush sql-cli < #{File.join(dbbackups_path, "#{sql_file}")}"
|
466
|
+
run "rm #{File.join(dbbackups_path, "#{sql_file}")}"
|
467
|
+
end
|
468
|
+
|
447
469
|
end
|
448
470
|
end
|
449
471
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-didi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Koen Van Winckel
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-06-19 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|