awsborn 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.mdown CHANGED
@@ -61,7 +61,7 @@ Server types can be named anything but must inherit from `Awsborn::Server`.
61
61
  Servers take five different directives:
62
62
 
63
63
  * `instance_type` -- a symbol. One of `:m1_small`, `:m1_large`, `:m1_xlarge`,
64
- `:m2_2xlarge`, `:m2_4xlarge`, `:c1_medium`, and `:c1_xlarge`.
64
+ `:m2_2xlarge`, `:m2_4xlarge`, `:c1_medium`, `:c1_xlarge`, `cc1.4xlarge`, and `t1.micro`.
65
65
  * `image_id` -- a valid EC2 AMI or a hash `{:i386 => 'ami-3232', :x64 => 'ami-6464'}`
66
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.
@@ -85,7 +85,8 @@ and a hash:
85
85
  Mandatory keys:
86
86
 
87
87
  * `:zone` -- the availability zone for the server. One of `:us_east_1a`, `:us_east_1b`,
88
- `:us_east_1c`, `:us_west_1a`, `:us_west_1b`, `:eu_west_1a`, `:eu_west_1b`.
88
+ `:us_east_1c`, `:us_east_1d`, `:us_west_1a`, `:us_west_1b`, `:eu_west_1a`, `:eu_west_1b`,
89
+ `:ap-southeast-1a`, `:ap-southeast-1b`.
89
90
  * `:disk` -- a hash of `device => volume-id`. Awsborn uses the disks to tell if a server
90
91
  is running or not (see *Launching a cluster*). `volume-id` can also be an array
91
92
  `[volume-id, :format]`, in which case `the_server.format_disk_on_device?(device)`
@@ -111,7 +112,7 @@ The `launch` method on the cluster checks to see if each server is running by ch
111
112
  if the server's disks are attached to an EC2 instance, i.e., the server is
112
113
  defined by its content, not by its AMI or ip address.
113
114
 
114
- Servers that not running are started by calling the `start` method on the server,
115
+ Servers that are not running are started by calling the `start` method on the server,
115
116
  which does the following:
116
117
 
117
118
  def start (key_pair)
@@ -224,7 +225,8 @@ Just add a `Rakefile` in the same directory:
224
225
  include Awsborn::Chef::Rake
225
226
  require './servers'
226
227
 
227
- You are now able to run `rake` to start all servers and run Chef on each of them.
228
+ Put your cookbooks directory in the same directory as the `Rakefile` or in its
229
+ parent directory. Run `rake` to start all servers and run Chef on each of them.
228
230
  Other rake tasks include:
229
231
 
230
232
  * `rake chef` - Run chef on all servers, or the ones specified with `host=name1,name2`.
@@ -261,12 +263,23 @@ Other rake tasks include:
261
263
  * Make your feature addition or bug fix.
262
264
  * Add tests for it. This is important so I don't break it in a
263
265
  future version unintentionally.
264
- * At the moment, the gem does not have any tests. I intend to fix that,
266
+ * At the moment, the gem does not have much tests. I intend to fix that,
265
267
  and I won't accept patches without tests.
266
268
  * Commit, do not mess with rakefile, version, or history.
267
269
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
268
270
  * Send me a pull request. Bonus points for topic branches.
269
271
 
272
+ ## Changes
273
+
274
+ ### New in 0.5.1
275
+
276
+ * When awsborn uploads cookbooks and configuration, it looks for a `cookbooks`
277
+ directory in the parent directory if none is found in the `Rakefile`'s directory.
278
+
279
+ ### New in 0.5.0
280
+
281
+ * Support for cc1.4xlarge and t1.micro instance types.
282
+
270
283
  ## History
271
284
 
272
285
  This gem is inspired by [Awsymandias](http://github.com/bguthrie/awsymandias)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
data/lib/awsborn/rake.rb CHANGED
@@ -1,8 +1,23 @@
1
1
  module Awsborn
2
- module Chef
2
+ module Chef #:nodoc:
3
+ # Just add a `Rakefile` in the same directory as your server definition file.
4
+ #
5
+ # require 'awsborn'
6
+ # include Awsborn::Chef::Rake
7
+ # require './servers'
8
+ #
9
+ # You are now able to run `rake` to start all servers and run Chef on each of them.
10
+ # Other rake tasks include:
11
+ #
12
+ # * `rake chef` - Run chef on all servers, or the ones specified with `host=name1,name2`.
13
+ # * `rake chef:debug` - Ditto, but with chef's log level set to `debug`.
14
+ # * `rake start` - Start all servers (or host=name1,name2) but don't run `chef`.
15
+ #
16
+ # You can use `server=name1,name2` as a synonym for `host=...`
17
+ #
3
18
  module Rake
4
19
 
5
- def default_cluster
20
+ def default_cluster #:nodoc:
6
21
  default_klass = Awsborn::Server.children.first
7
22
  default_klass.clusters.first
8
23
  end
@@ -16,8 +31,15 @@ module Awsborn
16
31
 
17
32
  desc "Start all servers (or host=name1,name2) but don't run chef."
18
33
  task :start do |t,args|
19
- hosts = args[:host] && args[:host].split(',')
20
- default_cluster.launch hosts
34
+ default_cluster.launch get_hosts(args)
35
+ end
36
+
37
+ desc "Update .ssh/known_hosts with data from all servers (or host=host1,host2)"
38
+ task :update_known_hosts do |t,args|
39
+ hosts = get_hosts(args)
40
+ default_cluster.each do |server|
41
+ server.running? && server.update_known_hosts if hosts.nil? || hosts.include?(server.name.to_s)
42
+ end
21
43
  end
22
44
 
23
45
  desc "Run chef on all servers (or host=name1,name2)."
@@ -25,9 +47,11 @@ module Awsborn
25
47
 
26
48
  namespace :chef do
27
49
  task :run => [:check_syntax] do |t,args|
28
- hosts = args[:host] && args[:host].split(',')
50
+ hosts = get_hosts(args)
29
51
  default_cluster.each do |server|
30
- server.cook if hosts.nil? || hosts.include?(server.name.to_s)
52
+ next unless hosts.nil? || hosts.include?(server.name.to_s)
53
+ puts framed("Running chef on '#{server.name}'")
54
+ server.cook
31
55
  end
32
56
  end
33
57
 
@@ -54,7 +78,7 @@ module Awsborn
54
78
  end
55
79
  end
56
80
 
57
- def create_cookbook(dir)
81
+ def create_cookbook(dir) #:nodoc:
58
82
  raise "Must provide a cookbook=" unless ENV["cookbook"]
59
83
  puts "** Creating cookbook #{ENV["cookbook"]}"
60
84
  sh "mkdir -p #{File.join(dir, ENV["cookbook"], "attributes")}"
@@ -75,6 +99,14 @@ EOH
75
99
  end
76
100
  end
77
101
  end
102
+
103
+ def get_hosts (args) #:nodoc:
104
+ args[:host] && args[:host].split(',') || args[:server] && args[:server].split(',')
105
+ end
106
+
107
+ def framed (message) #:nodoc:
108
+ '*' * (4 + message.length) + "\n* #{message} *\n" + '*' * (4 + message.length)
109
+ end
78
110
  end
79
111
  end
80
112
  end
@@ -177,10 +177,16 @@ module Awsborn
177
177
 
178
178
  def upload_cookbooks
179
179
  logger.info "Uploading cookbooks to #{host_name}"
180
+
181
+ cookbooks_dir = '../cookbooks' # Hard coded for now
182
+ temp_link = File.directory?(cookbooks_dir) && ! File.directory?('cookbooks')
183
+ File.symlink(cookbooks_dir, 'cookbooks') if temp_link
184
+
180
185
  File.open("config/dna.json", "w") { |f| f.write(chef_dna.to_json) }
181
- sh "rsync -rL --delete --exclude '.*' ./ root@#{host_name}:#{Awsborn.remote_chef_path}"
186
+ system "rsync -rL --delete --exclude '.*' ./ root@#{host_name}:#{Awsborn.remote_chef_path}"
182
187
  ensure
183
188
  File.delete("config/dna.json")
189
+ File.delete("cookbooks") if temp_link
184
190
  end
185
191
 
186
192
  def run_chef
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awsborn
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 9
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 5
8
- - 0
9
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - David Vrensk
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-09-10 00:00:00 +02:00
18
+ date: 2010-11-02 00:00:00 +01:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: icehouse-right_aws
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 59
27
30
  segments:
28
31
  - 1
29
32
  - 11
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: json_pure
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 25
41
46
  segments:
42
47
  - 1
43
48
  - 2
@@ -49,9 +54,11 @@ dependencies:
49
54
  name: rake
50
55
  prerelease: false
51
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
52
58
  requirements:
53
59
  - - ">="
54
60
  - !ruby/object:Gem::Version
61
+ hash: 3
55
62
  segments:
56
63
  - 0
57
64
  version: "0"
@@ -61,9 +68,11 @@ dependencies:
61
68
  name: rspec
62
69
  prerelease: false
63
70
  requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
64
72
  requirements:
65
73
  - - ">="
66
74
  - !ruby/object:Gem::Version
75
+ hash: 13
67
76
  segments:
68
77
  - 1
69
78
  - 2
@@ -75,9 +84,11 @@ dependencies:
75
84
  name: webmock
76
85
  prerelease: false
77
86
  requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
78
88
  requirements:
79
89
  - - ">="
80
90
  - !ruby/object:Gem::Version
91
+ hash: 57
81
92
  segments:
82
93
  - 0
83
94
  - 9
@@ -127,23 +138,27 @@ rdoc_options:
127
138
  require_paths:
128
139
  - lib
129
140
  required_ruby_version: !ruby/object:Gem::Requirement
141
+ none: false
130
142
  requirements:
131
143
  - - ">="
132
144
  - !ruby/object:Gem::Version
145
+ hash: 3
133
146
  segments:
134
147
  - 0
135
148
  version: "0"
136
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
+ none: false
137
151
  requirements:
138
152
  - - ">="
139
153
  - !ruby/object:Gem::Version
154
+ hash: 3
140
155
  segments:
141
156
  - 0
142
157
  version: "0"
143
158
  requirements: []
144
159
 
145
160
  rubyforge_project:
146
- rubygems_version: 1.3.6
161
+ rubygems_version: 1.3.7
147
162
  signing_key:
148
163
  specification_version: 3
149
164
  summary: Awsborn defines servers as instances with a certain disk volume, which makes it easy to restart missing servers.