capdrupal 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.markdown +53 -0
  2. data/VERSION +1 -0
  3. data/capdrupal.gemspec +30 -0
  4. data/lib/capdrupal.rb +149 -0
  5. metadata +90 -0
data/README.markdown ADDED
@@ -0,0 +1,53 @@
1
+ # Capistrano Drupal
2
+
3
+ This gem provides a number of tasks which are useful for deploying Drupal projects.
4
+
5
+ Credit goes to railsless-deploy for many ideas here.
6
+
7
+ ## Installation
8
+ These gems must be installed on your system first.
9
+
10
+ * capistrano
11
+ * rubygems
12
+ * railsless-deploy
13
+
14
+ You can check to see a list of installed gems by running this.
15
+
16
+ $ gem query --local
17
+
18
+ If any of these gems is missing you can install them with:
19
+
20
+ $ gem install gemname
21
+
22
+ Finally install the capistrano-drupal recipes as a gem.
23
+
24
+ ### From RubyGems.org
25
+
26
+ $ gem install capistrano-drupal
27
+
28
+ ### From Github
29
+
30
+ $ git clone git://github.com/antistatique/capistrano-drupal.git
31
+ $ cd capistrano-drupal
32
+ $ gem build capistrano-drupal.gemspec
33
+ $ gem install capistrano-drupal-{version}.gem
34
+
35
+ ## Usage
36
+
37
+ Open your application's `Capfile` and make it begin like this:
38
+
39
+ require 'rubygems'
40
+ require 'railsless-deploy'
41
+ require 'capistrano-drupal'
42
+ load 'config/deploy'
43
+
44
+ You should then be able to proceed as you would usually, you may want to familiarise yourself with the truncated list of tasks, you can get a full list with:
45
+
46
+ $ cap -T
47
+
48
+ ## Roadmap
49
+
50
+ - Split out the tasks into indivual files/modules
51
+ - Use drush aliases
52
+ - Support install profiles
53
+ - Support composer
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.9.0
data/capdrupal.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'capdrupal'
5
+ s.version = '0.9.0'
6
+ s.platform = Gem::Platform::RUBY
7
+ s.description = <<-DESC
8
+ A set of tasks for deploying Drupal projects with Capistrano and the help of Drush.
9
+ Based on the work at https://github.com/previousnext/capistrano-drupal}
10
+ DESC
11
+ s.summary = 'A set of tasks for deploying Drupal projects with Capistrano'
12
+
13
+ s.extra_rdoc_files = [
14
+ "README.markdown"
15
+ ]
16
+ s.files = [
17
+ "README.markdown",
18
+ "VERSION",
19
+ "capdrupal.gemspec",
20
+ "lib/capdrupal.rb"
21
+ ]
22
+ s.require_paths = 'lib'
23
+
24
+ s.add_dependency 'capistrano', ">= 2.13.5","<= 2.15.4"
25
+ s.add_dependency 'railsless-deploy', "~> 1.1.2"
26
+
27
+ s.authors = [ "Simon Perdrisat", "Gilles Doge", "Robert Wohleb", "Kim Pepper" ]
28
+ s.email = 'gilles.doge@gmail.com'
29
+ s.homepage = %q{http://github.com/antistatique/capdrupal/}
30
+ end
data/lib/capdrupal.rb ADDED
@@ -0,0 +1,149 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ require 'capistrano/recipes/deploy/scm'
4
+ require 'capistrano/recipes/deploy/strategy'
5
+
6
+ # =========================================================================
7
+ # These variables may be set in the client capfile if their default values
8
+ # are not sufficient.
9
+ # =========================================================================
10
+
11
+ _cset :scm, :git
12
+ _cset :deploy_via, :remote_cache
13
+ _cset :branch, "master"
14
+ _cset :git_enable_submodules, true
15
+
16
+ _cset :download_drush, false
17
+ _cset(:drush_cmd) { download_drush ? "#{shared_path}/drush/drush" : "drush" }
18
+
19
+ _cset :runner_group, "www-data"
20
+ _cset :group_writable, false
21
+
22
+ _cset(:deploy_to) { "/var/www/#{application}" }
23
+ _cset(:app_path) { "drupal" }
24
+ _cset :shared_children, false
25
+
26
+ after "deploy:update_code", "drupal:symlink_shared"
27
+ after "deploy:finalize_update" do
28
+ if download_drush
29
+ drush.get
30
+ end
31
+
32
+ drush.site_offline
33
+ drush.updatedb
34
+ drush.cache_clear
35
+ drush.feature_revert
36
+ drush.site_online
37
+ end
38
+
39
+ # This is an optional step that can be defined.
40
+ #after "deploy", "git:push_deploy_tag"
41
+
42
+ namespace :deploy do
43
+ desc <<-DESC
44
+ Prepares one or more servers for deployment. Before you can use any \
45
+ of the Capistrano deployment tasks with your project, you will need to \
46
+ make sure all of your servers have been prepared with `cap deploy:setup'. When \
47
+ you add a new server to your cluster, you can easily run the setup task \
48
+ on just that server by specifying the HOSTS environment variable:
49
+
50
+ $ cap HOSTS=new.server.com deploy:setup
51
+
52
+ It is safe to run this task on servers that have already been set up; it \
53
+ will not destroy any deployed revisions or data.
54
+ DESC
55
+ task :setup, :except => { :no_release => true } do
56
+ dirs = [deploy_to, releases_path, shared_path].join(' ')
57
+ run "#{try_sudo} mkdir -p #{releases_path} #{shared_path}"
58
+ run "#{try_sudo} chown -R #{user}:#{runner_group} #{deploy_to}"
59
+ if shared_children.size > 0
60
+ sub_dirs = shared_children.map { |d| File.join(shared_path, d) }
61
+ run "#{try_sudo} mkdir -p #{sub_dirs.join(' ')}"
62
+ run "#{try_sudo} chmod 2775 #{sub_dirs.join(' ')}"
63
+ end
64
+ end
65
+ end
66
+
67
+ namespace :drupal do
68
+ desc "Symlinks static directories and static files that need to remain between deployments"
69
+ task :symlink_shared, :roles => :app, :except => { :no_release => true } do
70
+ if shared_children
71
+ # Creating symlinks for shared directories
72
+ shared_children.each do |link|
73
+ run "#{try_sudo} mkdir -p #{shared_path}/#{link}"
74
+ run "#{try_sudo} sh -c 'if [ -d #{release_path}/#{link} ] ; then rm -rf #{release_path}/#{link}; fi'"
75
+ run "#{try_sudo} ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
76
+ end
77
+ end
78
+
79
+ if shared_files
80
+ # Creating symlinks for shared files
81
+ shared_files.each do |link|
82
+ link_dir = File.dirname("#{shared_path}/#{link}")
83
+ run "#{try_sudo} mkdir -p #{link_dir}"
84
+ run "#{try_sudo} touch #{shared_path}/#{link}"
85
+ run "#{try_sudo} ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ namespace :git do
92
+
93
+ desc "Place release tag into Git and push it to origin server."
94
+ task :push_deploy_tag do
95
+ user = `git config --get user.name`
96
+ email = `git config --get user.email`
97
+ tag = "release_#{release_name}"
98
+ if exists?(:stage)
99
+ tag = "#{stage}_#{tag}"
100
+ end
101
+ puts `git tag #{tag} #{revision} -m "Deployed by #{user} <#{email}>"`
102
+ puts `git push origin tag #{tag}`
103
+ end
104
+
105
+ end
106
+
107
+ namespace :drush do
108
+
109
+ desc "Gets drush and installs it"
110
+ task :get, :roles => :app, :except => { :no_release => true } do
111
+ run "#{try_sudo} cd #{shared_path} && curl -O -s http://ftp.drupal.org/files/projects/drush-7.x-5.8.tar.gz && tar -xf drush-7.x-5.8.tar.gz && rm drush-7.x-5.8.tar.gz"
112
+ run "#{try_sudo} cd #{shared_path} && chmod u+x drush/drush"
113
+ end
114
+
115
+ desc "Set the site offline"
116
+ task :site_offline, :on_error => :continue do
117
+ run "#{drush_cmd} -r #{latest_release}/#{app_path} vset site_offline 1 -y"
118
+ run "#{drush_cmd} -r #{latest_release}/#{app_path} vset maintenance_mode 1 -y"
119
+ end
120
+
121
+ desc "Backup the database"
122
+ task :backupdb, :on_error => :continue do
123
+ run "#{drush_cmd} -r #{latest_release}/#{app_path} bam-backup"
124
+ end
125
+
126
+ desc "Run Drupal database migrations if required"
127
+ task :updatedb, :on_error => :continue do
128
+ run "#{drush_cmd} -r #{latest_release}/#{app_path} updatedb -y"
129
+ end
130
+
131
+ desc "Clear the drupal cache"
132
+ task :cache_clear, :on_error => :continue do
133
+ run "#{drush_cmd} -r #{latest_release}/#{app_path} cc all"
134
+ end
135
+
136
+ desc "Revert feature"
137
+ task :feature_revert, :on_error => :continue do
138
+ run "#{drush_cmd} -r #{latest_release}/#{app_path} fr all"
139
+ end
140
+
141
+ desc "Set the site online"
142
+ task :site_online, :on_error => :continue do
143
+ run "#{drush_cmd} -r #{latest_release}/#{app_path} vset site_offline 0 -y"
144
+ run "#{drush_cmd} -r #{latest_release}/#{app_path} vset maintenance_mode 0 -y"
145
+ end
146
+
147
+ end
148
+
149
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capdrupal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Simon Perdrisat
9
+ - Gilles Doge
10
+ - Robert Wohleb
11
+ - Kim Pepper
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2013-05-29 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: capistrano
19
+ requirement: !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: 2.13.5
25
+ - - <=
26
+ - !ruby/object:Gem::Version
27
+ version: 2.15.4
28
+ type: :runtime
29
+ prerelease: false
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: 2.13.5
36
+ - - <=
37
+ - !ruby/object:Gem::Version
38
+ version: 2.15.4
39
+ - !ruby/object:Gem::Dependency
40
+ name: railsless-deploy
41
+ requirement: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 1.1.2
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.1.2
55
+ description: ! " A set of tasks for deploying Drupal projects with Capistrano and
56
+ the help of Drush.\n Based on the work at https://github.com/previousnext/capistrano-drupal}\n"
57
+ email: gilles.doge@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files:
61
+ - README.markdown
62
+ files:
63
+ - README.markdown
64
+ - VERSION
65
+ - capdrupal.gemspec
66
+ - lib/capdrupal.rb
67
+ homepage: http://github.com/antistatique/capdrupal/
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths: lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 1.8.23
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: A set of tasks for deploying Drupal projects with Capistrano
90
+ test_files: []