3. The plan
• Throw away what we don’t need
• Keep it simple
• ???
• Profit!
4. Standard stuff
“non ragioniam di lor, ma guarda e passa”
1 load 'deploy' if respond_to?(:namespace) # cap2 differentiator
2
3 # You should probably configure these
4 set :user, quot;drupalquot;
5 set :password, quot;supersecretquot;
6 set :application, quot;my.application.namequot;
7
8 # The default should be ok
9 set :deploy_to, quot;/var/apps/#{application}quot;
10
11 # SCM Stuff configure to taste, just remember the repository
12 set :repository, quot;git@github.com:intinig/app.gitquot;
13 set :scm, :git
14 set :branch, quot;masterquot;
15 set :repository_cache, quot;git_masterquot;
16 set :deploy_via, :remote_cache
17 set :scm_verbose, true
18
19 # Single server setup
20 role :web, quot;danton.mikamai.com:8888quot;, :primary => true
5. Callbacks
The Juice
22 # Callbacks
23 after 'deploy:setup', 'drupal:setup'
24 after 'deploy:symlink', 'drupal:symlink'
25 before 'deploy:start', 'drupal:db:import:production'
26
27 before 'deploy:restart', 'mikamai:permissions:fix'
28 before 'deploy:restart', 'mikamai:production:symlink', 'drupal:configure:production'
29 before 'deploy:start', 'mikamai:permissions:fix'
30 before 'deploy:start', 'mikamai:production:symlink', 'drupal:configure:production'
31 before 'deploy:cold', 'drupal:db:dump:development'
6. Overriding
Who’s your daddy?
85 namespace :deploy do
86 task :finalize_update, :except => { :no_release => true } do
87 sudo quot;chmod ‐R g+w #{latest_release}quot; if fetch(:group_writable,
true)
88 end
89
90 task :cold do
91 update
92 start
93 end
94
95 task :restart do
96 end
97
98 task :start do
99 end
100 end
7. The (long) Drupal namespace
48 namespace :drupal do
49 task :setup, :except => { :no_release => true } do
50 sudo quot;mkdir ‐p #{shared_path}/filesquot;
51 sudo quot;chown ‐R #{user}:#{user} #{deploy_to}quot;
52 end
53
54 task :symlink, :except => { :no_release => true } do
55 sudo quot;ln ‐s #{shared_path}/files #{latest_release}quot;
56 end
57
58 namespace :configure do
59 task :production do
60 sudo quot;cd #{latest_release}/sites/default; cp settings.production.php settings.phpquot;
61 end
62
63 task :development do
64 sudo quot;cd #{latest_release}/sites/default; cp settings.development.php settings.phpquot;
65 end
66 end
8. Still the (long) Drupal namespace
68 namespace :db do
69 namespace :dump do
70 task :development do
71 raise RuntimeError.new(quot;failed dumpquot;) unless system ...
72 end
73 end
74
75 namespace :import do
76 task :production do
77 ENV[quot;FILESquot;] = quot;dump.sqlquot;
78 deploy::upload
79 run quot;mysql ‐u #{db_user} ‐‐password=#{db_password} ...quot;
80 end
81 end
82 end
83 end
10. How we do it in
Mikamai
102 namespace :mikamai do
103
104 namespace :production do
105 task :symlink, :except => { :no_release => true } do
106 sudo quot;rm ‐rf /var/www/#{application}quot;
107 sudo quot;ln ‐s #{latest_release} /var/www/#{application}quot;
108 end
109 end
110
111 namespace :permissions do
112 task :fix, :except => { :no_release => true } do
113 sudo quot;chown ‐R www‐data:www‐data #{latest_release}quot;
114 end
115 end
116
117 end