awsborn 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.mdown +10 -5
- data/VERSION +1 -1
- data/lib/awsborn/rake.rb +4 -1
- data/lib/awsborn/server.rb +18 -2
- data/spec/server_spec.rb +26 -4
- metadata +3 -3
data/.gitignore
CHANGED
data/README.mdown
CHANGED
@@ -62,8 +62,8 @@ Servers take five different directives:
|
|
62
62
|
|
63
63
|
* `instance_type` -- a symbol. One of `:m1_small`, `:m1_large`, `:m1_xlarge`,
|
64
64
|
`:m2_2xlarge`, `:m2_4xlarge`, `:c1_medium`, and `:c1_xlarge`.
|
65
|
-
* `image_id` -- a valid EC2 AMI
|
66
|
-
does not allow you to log in as root.
|
65
|
+
* `image_id` -- a valid EC2 AMI or a hash `{:i386 => 'ami-3232', :x64 => 'ami-6464'}`
|
66
|
+
Specify `:sudo_user` as an option if the AMI does not allow you to log in as root.
|
67
67
|
* `security_group` -- a security group that you own.
|
68
68
|
* `keys` -- one or more globs to public ssh key files. When the servers are running,
|
69
69
|
`root` will be able to log in using any one of these keys.
|
@@ -103,6 +103,7 @@ Keys that override server type settings:
|
|
103
103
|
* `:security_group`
|
104
104
|
* `:keys`
|
105
105
|
* `:bootstrap_script`
|
106
|
+
* `:image_id`
|
106
107
|
|
107
108
|
### Launching a cluster
|
108
109
|
|
@@ -233,7 +234,13 @@ Other rake tasks include:
|
|
233
234
|
|
234
235
|
## Bugs and surprising features
|
235
236
|
|
236
|
-
|
237
|
+
* There is a race condition in launch: Immediately after the launch request (`launch_instance`) we
|
238
|
+
call `instance_running?`, but occasionally, AWS will not recognise the instance id yet
|
239
|
+
(`InvalidInstanceID.NotFound: The instance ID 'i-e9005283' does not exist`)
|
240
|
+
* Running with `rake` suppresses stack traces which makes it hard to debug rare errors. The rake
|
241
|
+
tasks or entry points should catch exceptions and print the stack trace.
|
242
|
+
* `t1_micro` instances will select an i386 image when `image_id` is specified as a hash. To run
|
243
|
+
them with x64 images, specify the image name on the server directive.
|
237
244
|
|
238
245
|
### Untested features
|
239
246
|
|
@@ -246,8 +253,6 @@ No bugs are known at this time.
|
|
246
253
|
* Hack RightAws to verify certificates.
|
247
254
|
* Elastic Load Balancing.
|
248
255
|
* Launch servers in parallel.
|
249
|
-
* Make `image_id` a hash with different AMIs for different instance types.
|
250
|
-
* Make `image_id` overridable per server.
|
251
256
|
|
252
257
|
|
253
258
|
## Note on Patches/Pull Requests
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/awsborn/rake.rb
CHANGED
@@ -11,7 +11,10 @@ module Awsborn
|
|
11
11
|
task :all => [:start, "chef:run"]
|
12
12
|
task :default => :all
|
13
13
|
|
14
|
-
desc "
|
14
|
+
desc "Like 'all' but with chef debugging on."
|
15
|
+
task :debug => ["chef:set_chef_debug", :all]
|
16
|
+
|
17
|
+
desc "Start all servers (or host=name1,name2) but don't run chef."
|
15
18
|
task :start do |t,args|
|
16
19
|
hosts = args[:host] && args[:host].split(',')
|
17
20
|
default_cluster.launch hosts
|
data/lib/awsborn/server.rb
CHANGED
@@ -13,6 +13,10 @@ module Awsborn
|
|
13
13
|
@children ||= []
|
14
14
|
@children << klass
|
15
15
|
end
|
16
|
+
# Set image_id. Examples:
|
17
|
+
# image_id 'ami-123123'
|
18
|
+
# image_id 'ami-123123', :sudo_user => 'ubuntu'
|
19
|
+
# image_id :i386 => 'ami-323232', :x64 => 'ami-646464', :sudo_user => 'ubuntu'
|
16
20
|
def image_id (*args)
|
17
21
|
unless args.empty?
|
18
22
|
@image_id = args.first
|
@@ -218,7 +222,17 @@ module Awsborn
|
|
218
222
|
volume.is_a?(Array) && volume.last == :format
|
219
223
|
end
|
220
224
|
def image_id
|
221
|
-
|
225
|
+
return @options[:image_id] if @options[:image_id]
|
226
|
+
tmp = self.class.image_id
|
227
|
+
tmp.is_a?(String) ? tmp : tmp[architecture]
|
228
|
+
end
|
229
|
+
def architecture
|
230
|
+
string = constant(instance_type)
|
231
|
+
case
|
232
|
+
when INSTANCE_TYPES_32_BIT.include?(string) then :i386
|
233
|
+
when INSTANCE_TYPES_64_BIT.include?(string) then :x64
|
234
|
+
else raise "Don't know if #{instance_type} is i386 or x64"
|
235
|
+
end
|
222
236
|
end
|
223
237
|
def instance_type
|
224
238
|
@options[:instance_type] || self.class.instance_type
|
@@ -271,7 +285,9 @@ module Awsborn
|
|
271
285
|
eu-west-1a eu-west-1b
|
272
286
|
ap-southeast-1a ap-southeast-1b
|
273
287
|
]
|
274
|
-
|
288
|
+
INSTANCE_TYPES_32_BIT = %w[m1.small c1.medium t1.micro]
|
289
|
+
INSTANCE_TYPES_64_BIT = %w[m1.large m1.xlarge m2.xlarge m2.2xlarge m2.4xlarge c1.xlarge cc1.4xlarge t1.micro]
|
290
|
+
INSTANCE_TYPES = (INSTANCE_TYPES_32_BIT + INSTANCE_TYPES_64_BIT).uniq
|
275
291
|
SYMBOL_CONSTANT_MAP = (AVAILABILITY_ZONES + INSTANCE_TYPES).inject({}) { |memo,str| memo[str.tr('-.','_').to_sym] = str; memo }
|
276
292
|
|
277
293
|
def constant (symbol)
|
data/spec/server_spec.rb
CHANGED
@@ -6,6 +6,11 @@ class SampleServer < Awsborn::Server
|
|
6
6
|
keys :all
|
7
7
|
end
|
8
8
|
|
9
|
+
class BigAndSmallServer < Awsborn::Server
|
10
|
+
instance_type :m1_small
|
11
|
+
image_id :x64 => 'ami-big', :i386 => 'ami-small'
|
12
|
+
end
|
13
|
+
|
9
14
|
describe Awsborn::Server do
|
10
15
|
before(:each) do
|
11
16
|
@server = SampleServer.new :sample, :zone => :eu_west_1a, :disk => {:sdf => "vol-aaaaaaaa"}
|
@@ -20,11 +25,28 @@ describe Awsborn::Server do
|
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
describe "image_id" do
|
29
|
+
it "should use a given string" do
|
30
|
+
@server.image_id.should == 'ami-2fc2e95b'
|
31
|
+
end
|
32
|
+
it "should use the i386 image for a small server" do
|
33
|
+
server = BigAndSmallServer.new :sample, :zone => :eu_west_1a, :disk => {:sdf => "vol-a"}, :instance_type => :m1_small
|
34
|
+
server.image_id.should == 'ami-small'
|
35
|
+
end
|
36
|
+
it "should use the i386 image for a micro server (which could use either)" do
|
37
|
+
server = BigAndSmallServer.new :sample, :zone => :eu_west_1a, :disk => {:sdf => "vol-a"}, :instance_type => :t1_micro
|
38
|
+
server.image_id.should == 'ami-small'
|
39
|
+
end
|
40
|
+
it "should use the x64 image for a big server" do
|
41
|
+
server = BigAndSmallServer.new :sample, :zone => :eu_west_1a, :disk => {:sdf => "vol-a"}, :instance_type => :m1_large
|
42
|
+
server.image_id.should == 'ami-big'
|
43
|
+
end
|
27
44
|
end
|
45
|
+
|
46
|
+
# TODO
|
47
|
+
# context "first of all" do
|
48
|
+
# it "should have a connection to the EU service point"
|
49
|
+
# end
|
28
50
|
|
29
51
|
context "#launch when not started" do
|
30
52
|
before(:each) do
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 5
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.5.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Vrensk
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-09-
|
17
|
+
date: 2010-09-10 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|