ec2onrails 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,29 @@
1
+ == 0.9.8 XXXX-XX-XX
2
+
3
+ * ami-XXXX (32-bit) and ami-XXXX (64-bit)
4
+ * This is another test release, still not intended to be production-ready. Look for version 1.0. Almost there!!
5
+ * Incremental database backups instead of doing a full mysqldump each time (full dump is done once nightly). (Thanks to Markus Bengts for the bug fix)
6
+ * Added monit monitoring daemon: monitors mysqld, apache, memcached, mongrels, system load and free drive space
7
+ * Enabled postfix by default, mail is delivered to admin user (or use new ec2onrails[:admin_mail_forward_address] option in deploy.rb to forward admin mail to an email address)
8
+ * Apache now supports SSL, set :ec2onrails[:enable_ssl] = true to enable and upload ssl cert & key (there is also a self-signed cert generated for each instance on first startup)
9
+ * Base image now built with Eric Hammond's EC2 Ubuntu script: http://alestic.com/ (using svn revision 44)
10
+ * Now installing latest rubygems (version 1.1.1) from source instead of using Ubuntu package
11
+ * Apache now denies access to any file in a directory named .svn, to protect the subversion info of those who deploy with Capistrano "checkout" method
12
+ * Added force-proxy-request-1.0 and proxy-nokeepalive for proxy requests to mongrel to fix occasional "proxy: error reading status line from remote server" error (mongrel doesn't support keep-alive anyway), see apache bug #37770
13
+ * Increased default memcache size to 128m, and memcache now listens on all interfaces for clustered use
14
+ * Tuned MySQL setting defaults for better performance
15
+ * restore_db_and_deploy task now runs migrations after restoring db
16
+ * upgrade_packages task now does "safe upgrade" instead of "full upgrade"
17
+ * Now requires Capistrano 2.3.0
18
+ * Bug fix: #20040: installing or upgrading packages no longer breaks - /etc/apt/sources.list is now correct
19
+ * Bug fix: #19808: Capistrano database tasks don't try to load database config if there are no hosts in the "db" role (with :primary => true, slave roles not yet supported)
20
+ * Bug fix: #19791: MySQL no longer fails after rebundling due to missing /mnt/mysql_data
21
+ * Bug fix: #14555: Syslog messages about unacknowledged DHCP requests is no longer occurring
22
+ * Bug fix: Database backup and restore scripts now exit if already backing up or restoring.
23
+ * Bug fix: EC2 ephemeral store and swap volumes were not correctly mounted
24
+ * Bug fix: Reload apache config when setting roles to find new app hosts.
25
+
26
+
1
27
  == 0.9.7 2008-03-03
2
28
 
3
29
  * ami-5c0aef35 (32-bit) and ami-540aef3d (64-bit)
data/config/hoe.rb CHANGED
@@ -59,7 +59,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
59
59
 
60
60
  # == Optional
61
61
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\\n\\n")
62
- p.extra_deps = [['capistrano', '>= 2.0.0'], ['archive-tar-minitar', '>= 0.5.1'], ['optiflag', '>= 0.6.5']] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
62
+ p.extra_deps = [['capistrano', '>= 2.3.0'], ['archive-tar-minitar', '>= 0.5.1'], ['optiflag', '>= 0.6.5']] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
63
63
 
64
64
  #p.spec_extras = {} # A hash of extra values to set in the gemspec.
65
65
 
@@ -5,6 +5,11 @@ module Ec2onrails
5
5
  raise("error: #{$?}") unless result
6
6
  end
7
7
 
8
+ def run_init_script(script, arg)
9
+ # since init scripts might have the execute bit unset by the set_roles script we need to check
10
+ sudo "sh -c 'if [ -x /etc/init.d/#{script} ] ; then /etc/init.d/#{script} #{arg}; fi'"
11
+ end
12
+
8
13
  def make_admin_role_for(role)
9
14
  newrole = "#{role.to_s}_admin".to_sym
10
15
  roles[role].each do |srv_def|
@@ -16,13 +21,13 @@ module Ec2onrails
16
21
  end
17
22
  end
18
23
 
19
- # return hostnames for the role named role_sym. It must have the options given or no hostnames will be returned
24
+ # return hostnames for the role named role_sym that has the specified options
20
25
  def hostnames_for_role(role_sym, options = {})
21
26
  role = roles[role_sym]
22
27
  unless role
23
28
  return []
24
29
  end
25
- role.reject{|s| s.options != options}.collect{|s| s.host}.join(',')
30
+ role.select{|s| s.options == options}.collect{|s| s.host}
26
31
  end
27
32
  end
28
- end
33
+ end
@@ -19,6 +19,7 @@
19
19
  require 'fileutils'
20
20
  include FileUtils
21
21
  require 'tmpdir'
22
+ require 'pp'
22
23
  require 'zlib'
23
24
  require 'archive/tar/minitar'
24
25
  include Archive::Tar
@@ -41,39 +42,47 @@ Capistrano::Configuration.instance.load do
41
42
  set :deploy_to, "/mnt/app"
42
43
  set :use_sudo, false
43
44
  set :user, "app"
45
+
46
+ # make an "admin" role for each role, and create arrays containing
47
+ # the names of admin roles and non-admin roles for convenience
48
+ set :all_admin_role_names, []
49
+ set :all_non_admin_role_names, []
50
+ roles.keys.clone.each do |name|
51
+ make_admin_role_for(name)
52
+ all_non_admin_role_names << name
53
+ all_admin_role_names << "#{name.to_s}_admin".to_sym
54
+ end
44
55
 
45
- make_admin_role_for :web
46
- make_admin_role_for :app
47
- make_admin_role_for :db
48
-
49
- roles[:web_admin].to_s
50
- roles[:app_admin].to_s
51
- roles[:db_admin].to_s
56
+ after "deploy:symlink", "ec2onrails:server:set_roles"
57
+ after "deploy:cold", "ec2onrails:db:init_backup"
52
58
 
53
59
  # override default start/stop/restart tasks
54
60
  namespace :deploy do
55
61
  desc <<-DESC
56
- Overrides the default Capistrano deploy:start, directly calls \
62
+ Overrides the default Capistrano deploy:restart, uses \
57
63
  /etc/init.d/mongrel
58
64
  DESC
59
- task :start, :roles => :app do
60
- run "/etc/init.d/mongrel start"
65
+ task :start, :roles => :app_admin do
66
+ run_init_script("mongrel", "start")
67
+ sudo "sleep 30 && monit -g app monitor all" # give the service 30 seconds to start before attempting to monitor it
61
68
  end
62
69
 
63
70
  desc <<-DESC
64
- Overrides the default Capistrano deploy:stop, directly calls \
71
+ Overrides the default Capistrano deploy:restart, uses \
65
72
  /etc/init.d/mongrel
66
73
  DESC
67
- task :stop, :roles => :app do
68
- run "/etc/init.d/mongrel stop"
74
+ task :stop, :roles => :app_admin do
75
+ sudo "monit -g app unmonitor all"
76
+ run_init_script("mongrel", "stop")
69
77
  end
70
78
 
71
79
  desc <<-DESC
72
- Overrides the default Capistrano deploy:restart, directly calls \
80
+ Overrides the default Capistrano deploy:restart, uses \
73
81
  /etc/init.d/mongrel
74
82
  DESC
75
- task :restart, :roles => :app do
76
- run "/etc/init.d/mongrel restart"
83
+ task :restart, :roles => :app_admin do
84
+ deploy.stop
85
+ deploy.start
77
86
  end
78
87
  end
79
88
 
@@ -82,7 +91,7 @@ Capistrano::Configuration.instance.load do
82
91
  Show the AMI id's of the current images for this version of \
83
92
  EC2 on Rails.
84
93
  DESC
85
- task :ami_ids, :roles => [:web, :db, :app] do
94
+ task :ami_ids do
86
95
  puts "32-bit server image for EC2 on Rails #{ec2onrails_version}: #{image_id_32_bit}"
87
96
  puts "64-bit server image for EC2 on Rails #{ec2onrails_version}: #{image_id_64_bit}"
88
97
  end
@@ -114,42 +123,35 @@ Capistrano::Configuration.instance.load do
114
123
  run_local "scp -i '#{privkey}' app@#{host}:.ssh/authorized_keys #{pubkey}"
115
124
  end
116
125
  end
117
-
126
+
118
127
  desc <<-DESC
119
- Start a new server instance and prepare it for a cold deploy.
128
+ Prepare a newly-started instance for a cold deploy.
120
129
  DESC
121
- task :setup, :roles => [:web, :db, :app] do
122
- ec2.start_instance
130
+ task :setup, :roles => all_admin_role_names do
131
+ server.set_admin_mail_forward_address
123
132
  server.set_timezone
124
133
  server.install_packages
125
134
  server.install_gems
126
135
  server.deploy_files
136
+ server.enable_ssl if cfg[:enable_ssl]
127
137
  server.set_rails_env
128
138
  server.restart_services
129
139
  deploy.setup
130
- server.set_roles
131
140
  db.create
132
141
  end
133
142
 
134
143
  desc <<-DESC
135
144
  Deploy and restore database from S3
136
145
  DESC
137
- task :restore_db_and_deploy, :roles => [:web, :db, :app] do
146
+ task :restore_db_and_deploy do
138
147
  db.recreate
139
148
  deploy.update_code
140
149
  deploy.symlink
141
- # don't need to migrate because we're restoring the db
142
150
  db.restore
143
- deploy.restart
151
+ deploy.migrations
144
152
  end
145
153
 
146
- namespace :ec2 do
147
- desc <<-DESC
148
- DESC
149
- task :start_instance, :roles => [:web, :db, :app] do
150
- # TODO
151
- end
152
-
154
+ namespace :ec2 do
153
155
  desc <<-DESC
154
156
  DESC
155
157
  task :configure_firewall do
@@ -160,27 +162,28 @@ Capistrano::Configuration.instance.load do
160
162
  namespace :db do
161
163
  desc <<-DESC
162
164
  [internal] Load configuration info for the database from
163
- config/database.yml.
165
+ config/database.yml, and start mysql (it must be running
166
+ in order to interact with it).
164
167
  DESC
165
- task :load_config, :roles => :db do
166
- db_config = YAML::load(ERB.new(File.read("config/database.yml")).result)[rails_env]
167
- cfg[:db_name] = db_config['database']
168
- cfg[:db_user] = db_config['username']
169
- cfg[:db_password] = db_config['password']
170
- cfg[:db_host] = db_config['host']
171
- cfg[:db_socket] = db_config['socket']
168
+ task :load_config do
169
+ unless hostnames_for_role(:db, :primary => true).empty?
170
+ db_config = YAML::load(ERB.new(File.read("config/database.yml")).result)[rails_env.to_s]
171
+ cfg[:db_name] = db_config['database']
172
+ cfg[:db_user] = db_config['username']
173
+ cfg[:db_password] = db_config['password']
174
+ cfg[:db_host] = db_config['host']
175
+ cfg[:db_socket] = db_config['socket']
172
176
 
173
- if (cfg[:db_host].nil? || cfg[:db_host].empty?) &&
174
- (cfg[:db_host] != 'localhost' || cfg[:db_host] != '127.0.0.1') &&
175
- (cfg[:db_socket].nil? || cfg[:db_socket].empty?)
176
- raise "ERROR: missing database config. Make sure database.yml contains a '#{rails_env}' section with either 'host: localhost' or 'socket: /var/run/mysqld/mysqld.sock'."
177
- end
177
+ if (cfg[:db_host].nil? || cfg[:db_host].empty?) && (cfg[:db_socket].nil? || cfg[:db_socket].empty?)
178
+ raise "ERROR: missing database config. Make sure database.yml contains a '#{rails_env}' section with either 'host: hostname' or 'socket: /var/run/mysqld/mysqld.sock'."
179
+ end
178
180
 
179
- [cfg[:db_name], cfg[:db_user], cfg[:db_password]].each do |s|
180
- if s.nil? || s.empty?
181
- raise "ERROR: missing database config. Make sure database.yml contains a '#{rails_env}' section with a database name, user, and password."
182
- elsif s.match(/['"]/)
183
- raise "ERROR: database config string '#{s}' contains quotes."
181
+ [cfg[:db_name], cfg[:db_user], cfg[:db_password]].each do |s|
182
+ if s.nil? || s.empty?
183
+ raise "ERROR: missing database config. Make sure database.yml contains a '#{rails_env}' section with a database name, user, and password."
184
+ elsif s.match(/['"]/)
185
+ raise "ERROR: database config string '#{s}' contains quotes."
186
+ end
184
187
  end
185
188
  end
186
189
  end
@@ -193,8 +196,21 @@ Capistrano::Configuration.instance.load do
193
196
  task :create, :roles => :db do
194
197
  on_rollback { drop }
195
198
  load_config
196
- run "echo 'create database if not exists #{cfg[:db_name]};' | mysql -u root"
197
- run "echo \"grant all on #{cfg[:db_name]}.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';\" | mysql -u root"
199
+ start
200
+ run %{mysql -u root -e "create database if not exists #{cfg[:db_name]};"}
201
+ run %{mysql -u root -e "grant all on #{cfg[:db_name]}.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
202
+ run %{mysql -u root -e "grant reload on *.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
203
+ run %{mysql -u root -e "grant super on *.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
204
+ end
205
+
206
+ desc <<-DESC
207
+ Make sure the MySQL server has been started, just in case the db role
208
+ hasn't been set, e.g. when called from ec2onrails:setup.
209
+ (But don't enable monitoring on it.)
210
+ DESC
211
+ task :start, :roles => :db_admin do
212
+ sudo "chmod a+x /etc/init.d/mysql"
213
+ sudo "/etc/init.d/mysql start"
198
214
  end
199
215
 
200
216
  desc <<-DESC
@@ -204,7 +220,7 @@ Capistrano::Configuration.instance.load do
204
220
  DESC
205
221
  task :drop, :roles => :db do
206
222
  load_config
207
- run "echo 'drop database if exists #{cfg[:db_name]};' | mysql -u root"
223
+ run %{mysql -u root -e "drop database if exists #{cfg[:db_name]};"}
208
224
  end
209
225
 
210
226
  desc <<-DESC
@@ -221,7 +237,7 @@ Capistrano::Configuration.instance.load do
221
237
  DESC
222
238
  task :set_root_password, :roles => :db do
223
239
  if cfg[:mysql_root_password]
224
- run %{echo "set password for root@localhost=password('#{cfg[:mysql_root_password]}');" | mysql -u root}
240
+ run %{mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD('#{cfg[:mysql_root_password]}') WHERE User='root'; FLUSH PRIVILEGES;"}
225
241
  end
226
242
  end
227
243
 
@@ -230,17 +246,26 @@ Capistrano::Configuration.instance.load do
230
246
  ec2onrails_config[:archive_to_bucket]. The filename will be \
231
247
  "app-<timestamp>.sql.gz".
232
248
  DESC
233
- task :archive, :roles => [:db] do
234
- run "/usr/local/ec2onrails/bin/backup_app_db.rb --bucket #{cfg[:archive_to_bucket]} --file app-#{Time.new.strftime('%Y-%m-%d--%H-%M-%S')}.sql.gz"
249
+ task :archive, :roles => :db do
250
+ run "/usr/local/ec2onrails/bin/backup_app_db.rb --noreset --bucket #{cfg[:archive_to_bucket]} --dir database-#{Time.new.strftime('%Y-%m-%d--%H-%M-%S')}"
235
251
  end
236
252
 
237
253
  desc <<-DESC
238
254
  Restore the MySQL database from the S3 bucket specified by \
239
255
  ec2onrails_config[:restore_from_bucket]. The archive filename is \
240
- expected to be the default, "app.sql.gz".
256
+ expected to be the default, "mysqldump.sql.gz".
257
+ DESC
258
+ task :restore, :roles => :db do
259
+ run "/usr/local/ec2onrails/bin/restore_app_db.rb --bucket #{cfg[:restore_from_bucket]} --dir #{cfg[:restore_from_bucket_subdir]}"
260
+ end
261
+
262
+ desc <<-DESC
263
+ [internal] Initialize the default backup folder on S3 (i.e. do a full
264
+ backup of the newly-created db so the automatic incremental backups
265
+ make sense).
241
266
  DESC
242
- task :restore, :roles => [:db] do
243
- run "/usr/local/ec2onrails/bin/restore_app_db.rb --bucket #{cfg[:restore_from_bucket]}"
267
+ task :init_backup, :roles => :db do
268
+ run "/usr/local/ec2onrails/bin/backup_app_db.rb"
244
269
  end
245
270
  end
246
271
 
@@ -250,36 +275,45 @@ Capistrano::Configuration.instance.load do
250
275
  the appropriate settings for each role, and starts and/or stops the \
251
276
  relevant services.
252
277
  DESC
253
- task :set_roles, :roles => [:web_admin, :db_admin, :app_admin] do
278
+ task :set_roles, :roles => all_admin_role_names do
254
279
  # TODO generate this based on the roles that actually exist so arbitrary new ones can be added
255
- sudo "/usr/local/ec2onrails/bin/set_roles.rb web=#{hostnames_for_role(:web)} app=#{hostnames_for_role(:app)} db_primary=#{hostnames_for_role(:db, :primary => true)} memcache=#{hostnames_for_role(:memcache)}"
280
+ roles = {
281
+ :web => hostnames_for_role(:web),
282
+ :app => hostnames_for_role(:app),
283
+ :db_primary => hostnames_for_role(:db, :primary => true),
284
+ :memcache => hostnames_for_role(:memcache)
285
+ }
286
+ roles_yml = YAML::dump(roles)
287
+ put roles_yml, "/tmp/roles.yml"
288
+ sudo "cp /tmp/roles.yml /etc/ec2onrails"
289
+ sudo "/usr/local/ec2onrails/bin/set_roles.rb"
256
290
  end
257
291
 
258
292
  desc <<-DESC
259
293
  Change the default value of RAILS_ENV on the server. Technically
260
294
  this changes the server's mongrel config to use a different value
261
- for "environment". The value is specified in :rails_env
295
+ for "environment". The value is specified in :rails_env.
296
+ Be sure to do deploy:restart after this.
262
297
  DESC
263
- task :set_rails_env, :roles => [:web_admin, :db_admin, :app_admin] do
298
+ task :set_rails_env, :roles => all_admin_role_names do
264
299
  rails_env = fetch(:rails_env, "production")
265
300
  sudo "/usr/local/ec2onrails/bin/set_rails_env #{rails_env}"
266
- deploy.restart
267
301
  end
268
302
 
269
303
  desc <<-DESC
270
304
  Upgrade to the newest versions of all Ubuntu packages.
271
305
  DESC
272
- task :upgrade_packages, :roles => [:web_admin, :db_admin, :app_admin] do
306
+ task :upgrade_packages, :roles => all_admin_role_names do
273
307
  sudo "aptitude -q update"
274
- run "export DEBIAN_FRONTEND=noninteractive; sudo aptitude -q -y dist-upgrade"
308
+ run "export DEBIAN_FRONTEND=noninteractive; sudo aptitude -q -y safe-upgrade"
275
309
  end
276
310
 
277
311
  desc <<-DESC
278
312
  Upgrade to the newest versions of all rubygems.
279
313
  DESC
280
- task :upgrade_gems, :roles => [:web_admin, :db_admin, :app_admin] do
314
+ task :upgrade_gems, :roles => all_admin_role_names do
281
315
  sudo "gem update --system --no-rdoc --no-ri"
282
- sudo "gem update -y --no-rdoc --no-ri" do |ch, str, data|
316
+ sudo "gem update --no-rdoc --no-ri" do |ch, str, data|
283
317
  ch[:data] ||= ""
284
318
  ch[:data] << data
285
319
  if data =~ />\s*$/
@@ -301,7 +335,7 @@ Capistrano::Configuration.instance.load do
301
335
  'dpkg-reconfigure packagename' or replace the package's config files \
302
336
  using the 'ec2onrails:server:deploy_files' task.
303
337
  DESC
304
- task :install_packages, :roles => [:web_admin, :db_admin, :app_admin] do
338
+ task :install_packages, :roles => all_admin_role_names do
305
339
  if cfg[:packages] && cfg[:packages].any?
306
340
  run "export DEBIAN_FRONTEND=noninteractive; sudo aptitude -q -y install #{cfg[:packages].join(' ')}"
307
341
  end
@@ -311,10 +345,10 @@ Capistrano::Configuration.instance.load do
311
345
  Install extra rubygems. Set ec2onrails_config[:rubygems], it should \
312
346
  be with an array of strings.
313
347
  DESC
314
- task :install_gems, :roles => [:web_admin, :db_admin, :app_admin] do
348
+ task :install_gems, :roles => all_admin_role_names do
315
349
  if cfg[:rubygems]
316
350
  cfg[:rubygems].each do |gem|
317
- sudo "gem install #{gem} -y --no-rdoc --no-ri" do |ch, str, data|
351
+ sudo "gem install #{gem} --no-rdoc --no-ri" do |ch, str, data|
318
352
  ch[:data] ||= ""
319
353
  ch[:data] << data
320
354
  if data =~ />\s*$/
@@ -333,7 +367,7 @@ Capistrano::Configuration.instance.load do
333
367
  A convenience task to upgrade existing packages and gems and install \
334
368
  specified new ones.
335
369
  DESC
336
- task :upgrade_and_install_all, :roles => [:web_admin, :db_admin, :app_admin] do
370
+ task :upgrade_and_install_all, :roles => all_admin_role_names do
337
371
  upgrade_packages
338
372
  upgrade_gems
339
373
  install_packages
@@ -349,7 +383,7 @@ Capistrano::Configuration.instance.load do
349
383
  directory and file as the value. For example 'Africa/Abidjan' or \
350
384
  'posix/GMT' or 'Canada/Eastern'.
351
385
  DESC
352
- task :set_timezone, :roles => [:web_admin, :db_admin, :app_admin] do
386
+ task :set_timezone, :roles => all_admin_role_names do
353
387
  if cfg[:timezone]
354
388
  sudo "bash -c 'echo #{cfg[:timezone]} > /etc/timezone'"
355
389
  sudo "cp /usr/share/zoneinfo/#{cfg[:timezone]} /etc/localtime"
@@ -358,9 +392,13 @@ Capistrano::Configuration.instance.load do
358
392
 
359
393
  desc <<-DESC
360
394
  Deploy a set of config files to the server, the files will be owned by \
361
- root. This doesn't delete any files from the server.
395
+ root. This doesn't delete any files from the server. This is intended
396
+ mainly for customized config files for new packages installed via the \
397
+ ec2onrails:server:install_packages task. Subdirectories and files \
398
+ inside here will be placed within the same directory structure \
399
+ relative to the root of the server's filesystem.
362
400
  DESC
363
- task :deploy_files, :roles => [:web_admin, :db_admin, :app_admin] do
401
+ task :deploy_files, :roles => all_admin_role_names do
364
402
  if cfg[:server_config_files_root]
365
403
  begin
366
404
  filename = "config_files.tar"
@@ -383,30 +421,30 @@ Capistrano::Configuration.instance.load do
383
421
  to an array of strings. It's assumed that each service has a script \
384
422
  in /etc/init.d
385
423
  DESC
386
- task :restart_services, :roles => [:web_admin, :db_admin, :app_admin] do
424
+ task :restart_services, :roles => all_admin_role_names do
387
425
  if cfg[:services_to_restart] && cfg[:services_to_restart].any?
388
426
  cfg[:services_to_restart].each do |service|
389
- sudo "/etc/init.d/#{service} restart"
427
+ run_init_script(service, "restart")
390
428
  end
391
429
  end
392
430
  end
393
431
 
394
432
  desc <<-DESC
433
+ Set the email address that mail to the admin user forwards to.
395
434
  DESC
396
- task :enable_mail_server, :roles => [:web_admin, :db_admin, :app_admin] do
397
- # TODO
435
+ task :set_admin_mail_forward_address, :roles => all_admin_role_names do
436
+ put cfg[:admin_mail_forward_address], "/home/admin/.forward"
398
437
  end
399
-
400
- desc <<-DESC
401
- DESC
402
- task :add_user, :roles => [:web_admin, :db_admin, :app_admin] do
403
- # TODO
404
- end
405
-
438
+
406
439
  desc <<-DESC
440
+ Enable ssl for the web server. The SSL cert file should be in
441
+ /etc/ssl/certs/default.pem and the SSL key file should be in
442
+ /etc/ssl/private/default.key (use the deploy_files task).
407
443
  DESC
408
- task :run_script, :roles => [:web_admin, :db_admin, :app_admin] do
409
- # TODO
444
+ task :enable_ssl, :roles => :web_admin do
445
+ sudo "a2enmod ssl"
446
+ sudo "a2ensite default-ssl"
447
+ sudo "/etc/init.d/apache2 restart"
410
448
  end
411
449
  end
412
450
 
@@ -20,10 +20,10 @@ module Ec2onrails #:nodoc:
20
20
  module VERSION #:nodoc:
21
21
  MAJOR = 0
22
22
  MINOR = 9
23
- TINY = 7
23
+ TINY = 8
24
24
  STRING = [MAJOR, MINOR, TINY].join('.')
25
25
 
26
- AMI_ID_32_BIT = 'ami-5c0aef35'
27
- AMI_ID_64_BIT = 'ami-540aef3d'
26
+ AMI_ID_32_BIT = 'ami-b657b2df'
27
+ AMI_ID_64_BIT = 'ami-8957b2e0'
28
28
  end
29
29
  end
data/script/destroy CHANGED
File without changes
data/script/generate CHANGED
File without changes
data/script/txt2html CHANGED
File without changes
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>EC2 on Rails</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/ec2onrails"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/ec2onrails" class="numbers">0.9.7</a>
36
+ <a href="http://rubyforge.org/projects/ec2onrails" class="numbers">0.9.8</a>
37
37
  </div>
38
38
  <h2>Deploy a Ruby on Rails app on <span class="caps">EC2</span> in five minutes</h2>
39
39
 
@@ -55,22 +55,27 @@ your Rails app.</p>
55
55
 
56
56
 
57
57
  <ul>
58
- <li>Ready to deploy a Rails app with little or no configuration of the server required.</li>
59
- <li>Automatic backup of MySQL database to S3.</li>
60
- <li>Capistrano tasks to customize the server image, archive and restore the database to/from S3, and more (available as a rubygem).</li>
58
+ <li>Ready to deploy a Rails app with little or no configuration of the server required</li>
59
+ <li>Automatic backup of MySQL database to S3 (full backup nightly + incremental backup using binary logs every 10 minutes)</li>
60
+ <li>Capistrano tasks to customize the server image, archive and restore the database to/from S3, and more (available as a rubygem)</li>
61
61
  <li>Mongrel_cluster behind Apache 2.2, configured according to
62
62
  <a href="http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you/">Coda Hale&#8217;s excellent guide</a></li>
63
- <li>Ruby on Rails 1.2.5</li>
63
+ <li>Ruby on Rails 2.0.2 and 1.2.6</li>
64
64
  <li>Ruby 1.8.6</li>
65
65
  <li>MySQL 5</li>
66
- <li>Ubuntu 7.10 &#8220;Gutsy&#8221; with <a href="http://wiki.xensource.com/xenwiki/XenSpecificGlibc">Xen versions of standard libs</a> (<a href="http://packages.ubuntu.com/gutsy/libs/libc6-xen">libc6-xen</a> package).</li>
66
+ <li><a href="http://www.danga.com/memcached/">memcached</a></li>
67
+ <li><a href="http://www.tildeslash.com/monit/">monit</a> system monitoring</li>
68
+ <li>Ubuntu 7.10 &#8220;Gutsy&#8221; base image built using <a href="http://alestic.com/">Eric Hammond&#8217;s <span class="caps">EC2</span> Ubuntu script</a></li>
69
+ <li><span class="caps">SSL</span> support</li>
67
70
  <li>Amazon <span class="caps">AMI</span> tools installed</li>
68
71
  <li>A script to rebundle a customized version of the image in one step if required</li>
69
72
  <li>MySQL, Apache, and syslog configured to use /mnt for data and logging so you don&#8217;t fill up <span class="caps">EC2</span>&#8217;s small root filesystem</li>
70
73
  <li>Automatically archives Rails and Apache logs to S3 nightly.</li>
71
74
  <li>32-bit and 64-bit images available (supports all instance types, small to extra large).</li>
72
- <li>Created using a build file, full source is available.</li>
73
- <li>Multiple instance support.</li>
75
+ <li>Created using a build file, full source is <a href="http://rubyforge.org/scm/?group_id=4552">available</a> (the <span class="caps">EC2</span> on Rails script is run from <a href="http://alestic.com/">Eric Hammond&#8217;s <span class="caps">EC2</span> Ubuntu script</a>)</li>
76
+ <li>Supports multiple instances</li>
77
+ <li>Automatically runs hourly, daily, weekly and monthly scripts if they exist in Rails application&#8217;s script directory</li>
78
+ <li>Local <span class="caps">SMTP</span> server (postfix)</li>
74
79
  </ul>
75
80
 
76
81
 
@@ -108,7 +113,8 @@ to the instance defined in your Capistrano &#8220;db&#8221; role.</p>
108
113
  <h4>4. Start up one or more instances of the image.</h4>
109
114
 
110
115
 
111
- <p>Soon there will be a Capistrano task to do this for you. In the meantime read the
116
+ <p>Soon there will be a Capistrano task to do this for you. In the meantime I&#8217;m not going to lie, this part is complicated
117
+ the first time. Read the
112
118
  <a href="http://docs.amazonwebservices.com/AWSEC2/2007-08-29/GettingStartedGuide/running-an-instance.html">running an instance section</a>
113
119
  in Amazon&#8217;s getting started guide.</p>
114
120
 
@@ -117,6 +123,9 @@ in Amazon&#8217;s getting started guide.</p>
117
123
  or do <code>cap ec2onrails:ami_ids</code> from within the app that you configured in the previous step.</p>
118
124
 
119
125
 
126
+ <p><em><span class="caps">NOTE</span>: Only use the images that match the current version of the gem.</em></p>
127
+
128
+
120
129
  <p>Please see the <a href="http://ec2onrails.rubyforge.org/svn/trunk/gem/History.txt">change log</a> for release notes, and
121
130
  see the <a href="http://rubyforge.org/tracker/?atid=17558&#38;group_id=4552&#38;func=browse">list of open issues</a>.</p>
122
131
 
@@ -142,7 +151,8 @@ If you&#8217;re using multiple instances, be sure to allow them network access t
142
151
 
143
152
 
144
153
  <p>Technically all you should need to connect to the server is the private key file, the public key is on the server.
145
- But for some reason Capistrano requires that you have both the public key and the private key files together on the client.</p>
154
+ But for some reason
155
+ <a href="http://groups.google.com/group/capistrano/browse_thread/thread/1102208ff925d18">Capistrano requires that you have both the public key and the private key files together on the client</a>.</p>
146
156
 
147
157
 
148
158
  <p>From within the root of your rails app do:</p>
@@ -150,12 +160,15 @@ But for some reason Capistrano requires that you have both the public key and th
150
160
 
151
161
  <pre>cap ec2onrails:get_public_key_from_server</pre>
152
162
 
163
+ <p>Note, this will only work if you have an external ssh command in the path, it won&#8217;t work for most Windows users.</p>
164
+
165
+
153
166
  <h4>6. Deploy the app with Capistrano</h4>
154
167
 
155
168
 
156
169
  <pre>
157
170
  cap ec2onrails:setup
158
- cap deploy:migrations
171
+ cap deploy:cold
159
172
  </pre>
160
173
 
161
174
  <p>Yes, it&#8217;s that easy! The setup task will set the server&#8217;s timezone, install any
@@ -178,15 +191,15 @@ files to the server (they will be owned by root). It&#8217;s intended mainly for
178
191
  customized config files for new packages installed via the install_packages
179
192
  task.
180
193
  <ul>
181
- <li>ec2onrails:server:deploy_files</li>
182
- <li>ec2onrails:server:set_timezone</li>
183
- <li>ec2onrails:server:upgrade_gems</li>
184
- <li>ec2onrails:server:upgrade_packages</li>
185
- <li>ec2onrails:server:install_gems</li>
186
- <li>ec2onrails:server:install_packages</li>
187
- <li>ec2onrails:server:upgrade_and_install_all</li>
188
- <li>ec2onrails:server:restart_services</li>
189
- <li>ec2onrails:server:set_roles
194
+ <li><code>cap ec2onrails:server:deploy_files</code></li>
195
+ <li><code>cap ec2onrails:server:set_timezone</code></li>
196
+ <li><code>cap ec2onrails:server:upgrade_gems</code></li>
197
+ <li><code>cap ec2onrails:server:upgrade_packages</code></li>
198
+ <li><code>cap ec2onrails:server:install_gems</code></li>
199
+ <li><code>cap ec2onrails:server:install_packages</code></li>
200
+ <li><code>cap ec2onrails:server:upgrade_and_install_all</code></li>
201
+ <li><code>cap ec2onrails:server:restart_services</code></li>
202
+ <li><code>cap ec2onrails:server:set_roles</code>
190
203
  - Customizes each instance for it&#8217;s role(s) (as defined in your Capistrano deploy.rb file).
191
204
  For now this just makes sure that only the appropriate services (Apache, Mongrel, and/or MySQL)
192
205
  are running. Eventually this will customize settings for the running services also. Note that
@@ -200,30 +213,30 @@ bucket) onto a staging server that has the current production version of my
200
213
  app. I then deploy the new version which tests migrations exactly as they&#8217;ll
201
214
  run on the production server.
202
215
  <ul>
203
- <li>ec2onrails:db:archive</li>
204
- <li>ec2onrails:db:restore</li>
205
- <li>ec2onrails:db:create</li>
206
- <li>ec2onrails:db:drop</li>
207
- <li>ec2onrails:db:recreate</li>
208
- <li>ec2onrails:db:set_root_password</li>
216
+ <li><code>cap ec2onrails:db:archive</code></li>
217
+ <li><code>cap ec2onrails:db:restore</code></li>
218
+ <li><code>cap ec2onrails:db:create</code></li>
219
+ <li><code>cap ec2onrails:db:drop</code></li>
220
+ <li><code>cap ec2onrails:db:recreate</code></li>
221
+ <li><code>cap ec2onrails:db:set_root_password</code></li>
209
222
  </ul>
210
223
 
211
224
 
212
225
  <ul>
213
- <li>ec2onrails:ami_ids
226
+ <li><code>cap ec2onrails:ami_ids</code>
214
227
  - Shows the <span class="caps">AMI</span> id&#8217;s of the images that match the current version of the gem.</li>
215
228
  </ul>
216
229
 
217
230
 
218
231
  <ul>
219
- <li>ec2onrails:setup
232
+ <li><code>cap ec2onrails:setup</code>
220
233
  - This is a convenience task to get a new instance completely set up in one
221
234
  step, everything except deploying the app.</li>
222
235
  </ul>
223
236
 
224
237
 
225
238
  <ul>
226
- <li>ec2onrails:restore_db_and_deploy
239
+ <li><code>cap ec2onrails:restore_db_and_deploy</code>
227
240
  - Another convenience task to recreate the db, restore data to it from an s3
228
241
  bucket and deploy the app, useful to set up a staging server.</li>
229
242
  </ul>
@@ -299,18 +312,26 @@ or send me an <a href="http://pauldowman.com/contact/">email</a>.</p>
299
312
  <h2>How to submit patches</h2>
300
313
 
301
314
 
302
- <p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
303
-
315
+ Pleae read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a>.
316
+ The source code can be checked out anonymously using:
317
+ <pre>
318
+ svn checkout http://ec2onrails.rubyforge.org/svn/trunk ec2onrails
319
+ </pre>
304
320
 
305
- <p>The trunk repository is <code>svn://rubyforge.org/var/svn/ec2onrails/trunk</code> for anonymous access.</p>
321
+ <p>Patches can be submitted to the <a href="http://rubyforge.org/tracker/?atid=17560&#38;group_id=4552&#38;func=browse">RubyForge Tracker</a>
322
+ or <a href="http://pauldowman.com/contact/">emailed directly to me</a> .</p>
306
323
 
307
324
 
308
325
  <h2>License</h2>
309
326
 
310
327
 
311
328
  <p>This code is free to use under the terms of the <span class="caps">GPL</span> v2.</p>
329
+
330
+
331
+ <p>If you find <span class="caps">EC2</span> on Rails useful please <a href="http://www.workingwithrails.com/person/10131-paul-dowman">recommend Paul Dowman</a>
332
+ at Working With Rails.</p>
312
333
  <p class="coda">
313
- <a href="http://pauldowman.com/contact/">Paul Dowman</a>, 2nd March 2008<br>
334
+ <a href="http://pauldowman.com/contact/">Paul Dowman</a>, 19th May 2008<br>
314
335
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
315
336
  </p>
316
337
  </div>
data/website/index.txt CHANGED
@@ -15,22 +15,27 @@ _Deploying a simple rails app is simple, and complex customization (if required)
15
15
 
16
16
  Features of the EC2 image:
17
17
 
18
- * Ready to deploy a Rails app with little or no configuration of the server required.
19
- * Automatic backup of MySQL database to S3.
20
- * Capistrano tasks to customize the server image, archive and restore the database to/from S3, and more (available as a rubygem).
18
+ * Ready to deploy a Rails app with little or no configuration of the server required
19
+ * Automatic backup of MySQL database to S3 (full backup nightly + incremental backup using binary logs every 10 minutes)
20
+ * Capistrano tasks to customize the server image, archive and restore the database to/from S3, and more (available as a rubygem)
21
21
  * Mongrel_cluster behind Apache 2.2, configured according to
22
22
  "Coda Hale's excellent guide":http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you/
23
- * Ruby on Rails 1.2.5
23
+ * Ruby on Rails 2.0.2 and 1.2.6
24
24
  * Ruby 1.8.6
25
25
  * MySQL 5
26
- * Ubuntu 7.10 "Gutsy" with "Xen versions of standard libs":http://wiki.xensource.com/xenwiki/XenSpecificGlibc ("libc6-xen":http://packages.ubuntu.com/gutsy/libs/libc6-xen package).
26
+ * "memcached":http://www.danga.com/memcached/
27
+ * "monit":http://www.tildeslash.com/monit/ system monitoring
28
+ * Ubuntu 7.10 "Gutsy" base image built using "Eric Hammond's EC2 Ubuntu script":http://alestic.com/
29
+ * SSL support
27
30
  * Amazon AMI tools installed
28
31
  * A script to rebundle a customized version of the image in one step if required
29
32
  * MySQL, Apache, and syslog configured to use /mnt for data and logging so you don't fill up EC2's small root filesystem
30
33
  * Automatically archives Rails and Apache logs to S3 nightly.
31
34
  * 32-bit and 64-bit images available (supports all instance types, small to extra large).
32
- * Created using a build file, full source is available.
33
- * Multiple instance support.
35
+ * Created using a build file, full source is "available":http://rubyforge.org/scm/?group_id=4552 (the EC2 on Rails script is run from "Eric Hammond's EC2 Ubuntu script":http://alestic.com/)
36
+ * Supports multiple instances
37
+ * Automatically runs hourly, daily, weekly and monthly scripts if they exist in Rails application's script directory
38
+ * Local SMTP server (postfix)
34
39
 
35
40
 
36
41
  h2. Using the image
@@ -60,13 +65,16 @@ to the instance defined in your Capistrano "db" role.
60
65
 
61
66
  h4. 4. Start up one or more instances of the image.
62
67
 
63
- Soon there will be a Capistrano task to do this for you. In the meantime read the
68
+ Soon there will be a Capistrano task to do this for you. In the meantime I'm not going to lie, this part is complicated
69
+ the first time. Read the
64
70
  "running an instance section":http://docs.amazonwebservices.com/AWSEC2/2007-08-29/GettingStartedGuide/running-an-instance.html
65
71
  in Amazon's getting started guide.
66
72
 
67
73
  For the AMI id's of the current images see the "change log":http://ec2onrails.rubyforge.org/svn/trunk/gem/History.txt
68
74
  or do <code>cap ec2onrails:ami_ids</code> from within the app that you configured in the previous step.
69
75
 
76
+ _NOTE: Only use the images that match the current version of the gem._
77
+
70
78
  Please see the "change log":http://ec2onrails.rubyforge.org/svn/trunk/gem/History.txt for release notes, and
71
79
  see the "list of open issues":http://rubyforge.org/tracker/?atid=17558&group_id=4552&func=browse.
72
80
 
@@ -88,18 +96,21 @@ If you're using multiple instances, be sure to allow them network access to each
88
96
  h4. 5. Copy your public key from the server to keep Capistrano happy
89
97
 
90
98
  Technically all you should need to connect to the server is the private key file, the public key is on the server.
91
- But for some reason Capistrano requires that you have both the public key and the private key files together on the client.
99
+ But for some reason
100
+ "Capistrano requires that you have both the public key and the private key files together on the client":http://groups.google.com/group/capistrano/browse_thread/thread/1102208ff925d18.
92
101
 
93
102
  From within the root of your rails app do:
94
103
 
95
104
  <pre>cap ec2onrails:get_public_key_from_server</pre>
96
105
 
106
+ Note, this will only work if you have an external ssh command in the path, it won't work for most Windows users.
107
+
97
108
 
98
109
  h4. 6. Deploy the app with Capistrano
99
110
 
100
111
  <pre>
101
112
  cap ec2onrails:setup
102
- cap deploy:migrations
113
+ cap deploy:cold
103
114
  </pre>
104
115
 
105
116
  Yes, it's that easy! The setup task will set the server's timezone, install any
@@ -117,15 +128,15 @@ gems and Ubuntu packages to be installed. The deploy_files task uploads
117
128
  files to the server (they will be owned by root). It's intended mainly for
118
129
  customized config files for new packages installed via the install_packages
119
130
  task.
120
- * ec2onrails:server:deploy_files
121
- * ec2onrails:server:set_timezone
122
- * ec2onrails:server:upgrade_gems
123
- * ec2onrails:server:upgrade_packages
124
- * ec2onrails:server:install_gems
125
- * ec2onrails:server:install_packages
126
- * ec2onrails:server:upgrade_and_install_all
127
- * ec2onrails:server:restart_services
128
- * ec2onrails:server:set_roles
131
+ * <code>cap ec2onrails:server:deploy_files</code>
132
+ * <code>cap ec2onrails:server:set_timezone</code>
133
+ * <code>cap ec2onrails:server:upgrade_gems</code>
134
+ * <code>cap ec2onrails:server:upgrade_packages</code>
135
+ * <code>cap ec2onrails:server:install_gems</code>
136
+ * <code>cap ec2onrails:server:install_packages</code>
137
+ * <code>cap ec2onrails:server:upgrade_and_install_all</code>
138
+ * <code>cap ec2onrails:server:restart_services</code>
139
+ * <code>cap ec2onrails:server:set_roles</code>
129
140
  - Customizes each instance for it's role(s) (as defined in your Capistrano deploy.rb file).
130
141
  For now this just makes sure that only the appropriate services (Apache, Mongrel, and/or MySQL)
131
142
  are running. Eventually this will customize settings for the running services also. Note that
@@ -136,21 +147,21 @@ For example, I use this to restore the current production data (from my actual p
136
147
  bucket) onto a staging server that has the current production version of my
137
148
  app. I then deploy the new version which tests migrations exactly as they'll
138
149
  run on the production server.
139
- * ec2onrails:db:archive
140
- * ec2onrails:db:restore
141
- * ec2onrails:db:create
142
- * ec2onrails:db:drop
143
- * ec2onrails:db:recreate
144
- * ec2onrails:db:set_root_password
145
-
146
- * ec2onrails:ami_ids
150
+ * <code>cap ec2onrails:db:archive</code>
151
+ * <code>cap ec2onrails:db:restore</code>
152
+ * <code>cap ec2onrails:db:create</code>
153
+ * <code>cap ec2onrails:db:drop</code>
154
+ * <code>cap ec2onrails:db:recreate</code>
155
+ * <code>cap ec2onrails:db:set_root_password</code>
156
+
157
+ * <code>cap ec2onrails:ami_ids</code>
147
158
  - Shows the AMI id's of the images that match the current version of the gem.
148
159
 
149
- * ec2onrails:setup
160
+ * <code>cap ec2onrails:setup</code>
150
161
  - This is a convenience task to get a new instance completely set up in one
151
162
  step, everything except deploying the app.
152
163
 
153
- * ec2onrails:restore_db_and_deploy
164
+ * <code>cap ec2onrails:restore_db_and_deploy</code>
154
165
  - Another convenience task to recreate the db, restore data to it from an s3
155
166
  bucket and deploy the app, useful to set up a staging server.
156
167
 
@@ -215,11 +226,18 @@ See the "change log":http://ec2onrails.rubyforge.org/svn/trunk/gem/History.txt.
215
226
 
216
227
  h2. How to submit patches
217
228
 
218
- Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
219
-
220
- The trunk repository is <code>svn://rubyforge.org/var/svn/ec2onrails/trunk</code> for anonymous access.
229
+ Pleae read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/.
230
+ The source code can be checked out anonymously using:
231
+ <pre>
232
+ svn checkout http://ec2onrails.rubyforge.org/svn/trunk ec2onrails
233
+ </pre>
221
234
 
235
+ Patches can be submitted to the "RubyForge Tracker":http://rubyforge.org/tracker/?atid=17560&group_id=4552&func=browse
236
+ or "emailed directly to me":http://pauldowman.com/contact/ .
222
237
 
223
238
  h2. License
224
239
 
225
240
  This code is free to use under the terms of the GPL v2.
241
+
242
+ If you find EC2 on Rails useful please "recommend Paul Dowman":http://www.workingwithrails.com/person/10131-paul-dowman
243
+ at Working With Rails.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2onrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dowman
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-03-03 00:00:00 -05:00
12
+ date: 2008-05-19 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 2.0.0
22
+ version: 2.3.0
23
23
  version:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: archive-tar-minitar
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  requirements: []
102
102
 
103
103
  rubyforge_project: ec2onrails
104
- rubygems_version: 1.0.1
104
+ rubygems_version: 1.1.0
105
105
  signing_key:
106
106
  specification_version: 2
107
107
  summary: Client-side libraries (Capistrano tasks) for managing and deploying to EC2 on Rails servers.