sml-rubber 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
data/TODO CHANGED
@@ -1,9 +1,8 @@
1
- * try to do less stuff as root
2
- * extract ec2 specific code, and ubuntu specific code into a strategy/factory pattern so this can be used with other grid computing system
1
+ * extract ubuntu specific code into a strategy/factory pattern
2
+ * integrate chef and/or sprinkle for more robust package installs?
3
3
  * figure out how to test the capistrano bits
4
- * make rubber into a gem
5
- * divorce from rails for use in deploying other things
6
- * Script setup of round robin dns (Web role), mx records (mail role), etc in generators
4
+ * Script setup of round robin dns (Web role), mx records (mail role), etc in generators
7
5
  * add scripted failover to generated configs for:
8
6
  * remove web hosts from round robin on web host failure
9
7
  * db failover (promote slave replica? master-master replicas? cluster?)
8
+ * make passenger default template instead of mongrel
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.5
1
+ 0.9.6
@@ -75,3 +75,10 @@ task :setup_perms do
75
75
  run "find #{shared_path} -name cached-copy -prune -o -print | xargs chown #{runner}:#{runner}"
76
76
  run "chown -R #{runner}:#{runner} #{current_path}/tmp"
77
77
  end
78
+
79
+ # Uncomment this is you want to install gems defined in the rails environment.rb
80
+ # after "deploy:update", "install_rails_gems"
81
+ task :install_rails_gems do
82
+ sudo "sh -c 'cd #{current_path} && rake gems:install'"
83
+ end
84
+
@@ -85,10 +85,10 @@ cloud_providers:
85
85
 
86
86
  # REQUIRED: the ami and instance type for creating instances
87
87
  # The Ubuntu images at http://alestic.com/ work well
88
- # Ubuntu 9.04 Jaunty base install 32-bit 2.6.21.7-2.fc8xen ami-bf5eb9d6
89
- # Ubuntu 9.04 Jaunty base install 64-bit 2.6.21.7-2.fc8xen ami-bc5eb9d5
88
+ # Ubuntu 9.04 Jaunty base install 32-bit 2.6.21.7-2.fc8xen ami-ed46a784
89
+ # Ubuntu 9.04 Jaunty base install 64-bit 2.6.21.7-2.fc8xen ami-5b46a732
90
90
  #
91
- image_id: ami-bf5eb9d6
91
+ image_id: ami-ed46a784
92
92
  # m1.small or m1.large or m1.xlarge
93
93
  image_type: m1.small
94
94
 
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- require 'EC2'
2
+ require 'AWS'
3
3
  require 'aws/s3'
4
4
 
5
5
  module Rubber
@@ -10,7 +10,7 @@ module Rubber
10
10
  def initialize(env, capistrano)
11
11
  super(env, capistrano)
12
12
  @aws_env = env.cloud_providers.aws
13
- @ec2 = EC2::Base.new(:access_key_id => @aws_env.access_key, :secret_access_key => @aws_env.secret_access_key)
13
+ @ec2 = AWS::EC2::Base.new(:access_key_id => @aws_env.access_key, :secret_access_key => @aws_env.secret_access_key)
14
14
  AWS::S3::Base.establish_connection!(:access_key_id => @aws_env.access_key, :secret_access_key => @aws_env.secret_access_key)
15
15
  end
16
16
 
@@ -147,7 +147,9 @@ module Rubber
147
147
 
148
148
  def describe_static_ips(ip=nil)
149
149
  ips = []
150
- response = @ec2.describe_addresses()
150
+ opts = {}
151
+ opts[:public_ip] = ip if ip
152
+ response = @ec2.describe_addresses(opts)
151
153
  response.addressesSet.item.each do |item|
152
154
  ip = {}
153
155
  ip[:instance_id] = item.instanceId
@@ -185,7 +187,8 @@ module Rubber
185
187
  volume = {}
186
188
  volume[:id] = item.volumeId
187
189
  volume[:status] = item.status
188
- if attach = item.attachmentSet.item[0]
190
+ if item.attachmentSet
191
+ attach = item.attachmentSet.item[0]
189
192
  volume[:attachment_instance_id] = attach.instanceId
190
193
  volume[:attachment_status] = attach.status
191
194
  end
@@ -202,7 +205,6 @@ module Rubber
202
205
  ec2_key = @aws_env.key_file
203
206
  ec2_pk = @aws_env.pk_file
204
207
  ec2_cert = @aws_env.cert_file
205
- aws_account = @aws_env.account
206
208
  ec2_key_dest = "/mnt/#{File.basename(ec2_key)}"
207
209
  ec2_pk_dest = "/mnt/#{File.basename(ec2_pk)}"
208
210
  ec2_cert_dest = "/mnt/#{File.basename(ec2_cert)}"
@@ -213,13 +215,21 @@ module Rubber
213
215
 
214
216
  arch = capistrano.capture "uname -m"
215
217
  arch = case arch when /i\d86/ then "i386" else arch end
218
+
216
219
  capistrano.sudo_script "create_bundle", <<-CMD
217
220
  export RUBYLIB=/usr/lib/site_ruby/
218
- ec2-bundle-vol --batch -d /mnt -k #{ec2_pk_dest} -c #{ec2_cert_dest} -u #{account} -p #{image_name} -r #{arch}
221
+ nohup ec2-bundle-vol --batch -d /mnt -k #{ec2_pk_dest} -c #{ec2_cert_dest} -u #{@aws_env.account} -p #{image_name} -r #{arch} &> /tmp/ec2-bundle-vol.log &
222
+ echo "Creating image from instance volume..."
223
+ while true; do
224
+ if ! ps ax | grep -q "[e]c2-bundle-vol"; then exit; fi
225
+ echo -n .
226
+ sleep 1
227
+ done
219
228
  CMD
220
229
 
221
230
  capistrano.sudo_script "register_bundle", <<-CMD
222
231
  export RUBYLIB=/usr/lib/site_ruby/
232
+ echo "Uploading image to S3..."
223
233
  ec2-upload-bundle --batch -b #{@aws_env.image_bucket} -m /mnt/#{image_name}.manifest.xml -a #{@aws_env.access_key} -s #{@aws_env.secret_access_key}
224
234
  CMD
225
235
 
@@ -230,7 +240,9 @@ module Rubber
230
240
 
231
241
  def describe_images(image_id=nil)
232
242
  images = []
233
- response = @ec2.describe_images(:owner_id => 'self', :image_id => image_id)
243
+ opts = {:owner_id => 'self'}
244
+ opts[:image_id] = image_id if image_id
245
+ response = @ec2.describe_images(opts)
234
246
  response.imagesSet.item.each do |item|
235
247
  image = {}
236
248
  image[:id] = item.imageId
@@ -32,6 +32,9 @@ namespace :rubber do
32
32
  opts['NO_POST'] = true if ENV['NO_POST']
33
33
  opts['FILE'] = ENV['FILE'] if ENV['FILE']
34
34
  opts['RUBBER_ENV'] = RUBBER_ENV
35
+ # we need to set rails env as well because when running rake
36
+ # in a rails project, rails gets loaded before the rubber hook gets run
37
+ opts['RAILS_ENV'] = RUBBER_ENV
35
38
 
36
39
  # when running deploy:migrations, we need to run config against release_path
37
40
  opts[:deploy_path] = current_release if fetch(:migrate_target, :current).to_sym == :latest
@@ -49,7 +52,7 @@ namespace :rubber do
49
52
  push_files = [rubber_cfg.instance.file] + rubber_cfg.environment.config_files
50
53
  push_files.each do |file|
51
54
  dest_file = file.sub(/^#{RUBBER_ROOT}\/?/, '')
52
- put(File.read(file), File.join(path, dest_file))
55
+ put(File.read(file), File.join(path, dest_file), :mode => "+r")
53
56
  end
54
57
  end
55
58
 
@@ -57,7 +60,7 @@ namespace :rubber do
57
60
  secret = rubber_cfg.environment.config_secret
58
61
  if secret && File.exist?(secret)
59
62
  base = rubber_cfg.environment.config_root.sub(/^#{RUBBER_ROOT}\/?/, '')
60
- put(File.read(secret), File.join(path, base, File.basename(secret)))
63
+ put(File.read(secret), File.join(path, base, File.basename(secret)), :mode => "+r")
61
64
  end
62
65
 
63
66
  sudo "sh -c 'cd #{path} && #{extra_env} rake rubber:config'"
@@ -24,7 +24,7 @@ namespace :rubber do
24
24
  logger.info "Associating static ip #{ip} with #{ic.full_name}"
25
25
  associate_static_ip(ip, ic.instance_id)
26
26
 
27
- instance = cloud.describe_instances(:instance_id => ic.instance_id).first
27
+ instance = cloud.describe_instances(ic.instance_id).first
28
28
  ic.external_host = instance[:external_host]
29
29
  ic.internal_host = instance[:internal_host]
30
30
  ic.external_ip = ip
@@ -59,7 +59,7 @@ namespace :rubber do
59
59
  format = "%-10s %-15s %-30s"
60
60
  results << format % %w[InstanceID IP Alias]
61
61
 
62
- ips = cloud.describe_addresses()
62
+ ips = cloud.describe_static_ips()
63
63
  ips.each do |ip_data|
64
64
  instance_id = ip_data[:instance_id]
65
65
  ip = ip_data[:ip]
@@ -244,7 +244,8 @@ namespace :rubber do
244
244
  print "."
245
245
  sleep 2
246
246
  volume = cloud.describe_volumes(volume_id).first
247
- break if !volume || volume[:attachment_status] == "detached"
247
+ status = volume && volume[:attachment_status]
248
+ break if !status || status == "detached"
248
249
  end
249
250
  print "\n"
250
251
 
data/lib/rubber.rb CHANGED
@@ -8,7 +8,7 @@ module Rubber
8
8
  return if defined?(RUBBER_ROOT) && defined?(RUBBER_ENV)
9
9
 
10
10
  Object.const_set('RUBBER_ENV', project_env)
11
- Object.const_set('RUBBER_ROOT', project_root)
11
+ Object.const_set('RUBBER_ROOT', File.expand_path(project_root))
12
12
 
13
13
  # pull in basic rails env. rubber only needs RAILS_ROOT and RAILS_ENV.
14
14
  # We actually do NOT want the entire rails environment because it
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sml-rubber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: "0"
33
+ version: 0.5.0
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: aws-s3
@@ -62,6 +62,16 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: "0"
64
64
  version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: rails
67
+ type: :runtime
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
65
75
  description: "The rubber plugin enables relatively complex multi-instance deployments of RubyOnRails applications to Amazon\xD5s Elastic Compute Cloud (EC2). Like capistrano, rubber is role based, so you can define a set of configuration files for a role and then assign that role to as many concrete instances as needed. One can also assign multiple roles to a single instance. This lets one start out with a single ec2 instance (belonging to all roles), and add new instances into the mix as needed to scale specific facets of your deployment, e.g. adding in instances that serve only as an 'app' role to handle increased app server load."
66
76
  email: matt@conwaysplace.com
67
77
  executables: