rudy 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -7,6 +7,13 @@ RUDY, CHANGES
7
7
  * TODO: Support for product codes
8
8
  * TODO: HTTPS
9
9
 
10
+ #### 0.6.5 (2009-04-??) ###############################
11
+
12
+ * FIXED: Startup and Shutdown routines now check machine group status first
13
+ * FIXED: Misc release process issues between 0.6.0 and 0.6.4
14
+ * ADDED: Better error handling during startup and shutdown.
15
+ * ADDED: Support for assigning addresses on startup
16
+
10
17
 
11
18
  #### 0.6.0 (2009-04-19) ###############################
12
19
 
data/README.rdoc CHANGED
@@ -33,8 +33,8 @@ Via Rubygems, one of:
33
33
  $ sudo gem install solutious-rudy --source http://gems.github.com/
34
34
 
35
35
  or via download:
36
- * rudy-0.6.0.tar.gz[http://github.com/solutious/rudy/tarball/rudy-0.6.0]
37
- * rudy-0.6.0.zip[http://github.com/solutious/rudy/zipball/rudy-0.6.0]
36
+ * rudy-0.6.4.tar.gz[http://github.com/solutious/rudy/tarball/rudy-0.6.4]
37
+ * rudy-0.6.4.zip[http://github.com/solutious/rudy/zipball/rudy-0.6.4]
38
38
 
39
39
  NOTE: <em>If you are not installing via RubyGems, you need to make sure the dependencies are in your LOAD_PATH (<tt>$:</tt>). Ryan Tomayko wrote a gist[http://gist.github.com/54177] about it.</em>
40
40
 
data/Rudyfile CHANGED
@@ -50,8 +50,10 @@ machines do
50
50
  ami "ami-5394733a" # ec2onrails/ec2onrails-v0_9_9_1-i386.manifest.xml
51
51
  size 'm1.small'
52
52
 
53
+
53
54
  role :app do
54
- positions 1
55
+ positions 2
56
+ addresses '174.129.208.127', '174.129.208.169'
55
57
 
56
58
  # We define two disks for the stage-app machines
57
59
  disks do
@@ -66,10 +68,15 @@ machines do
66
68
  end
67
69
 
68
70
  end
69
-
70
71
 
71
- role :SUCCESS do
72
-
72
+ # Here are some examples of other roles. These can be anything.
73
+ role :db do
74
+ end
75
+
76
+ role :analysis do
77
+ end
78
+
79
+ role :balancer do
73
80
  end
74
81
 
75
82
  end
data/bin/rudy CHANGED
@@ -10,8 +10,8 @@
10
10
 
11
11
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') # Put our local lib in first place
12
12
  $:.unshift File.join(File.dirname(__FILE__), '..', 'vendor', 'highline-1.5.1', 'lib')
13
- #%w{amazon-ec2 rye}.each { |dir| $:.unshift File.join(File.dirname(__FILE__), '..', '..', dir, 'lib') }
14
- #require 'rubygems'
13
+ %w{amazon-ec2 rye}.each { |dir| $:.unshift File.join(File.dirname(__FILE__), '..', '..', dir, 'lib') }
14
+ require 'rubygems'
15
15
 
16
16
  #$SAFE = 1 # require is unsafe in Ruby 1.9??
17
17
 
@@ -251,7 +251,7 @@ class RudyCLI < Rudy::CLI::Base
251
251
 
252
252
  # ------------------------------------------- UGLY STUFFS --------
253
253
  # ------------------------------------------------------------------
254
- debug :off
254
+ debug :on
255
255
  default :machines
256
256
 
257
257
 
@@ -71,6 +71,7 @@ module Rudy::AWS
71
71
  address = address.ipaddress if address.is_a?(Rudy::AWS::EC2::Address)
72
72
  instance = instance.awsid if instance.is_a?(Rudy::AWS::EC2::Instance)
73
73
  raise UnknownAddress unless exists?(address)
74
+ p address
74
75
  raise AddressNotAssociated unless associated?(address)
75
76
 
76
77
  opts ={
@@ -79,8 +79,7 @@ module Rudy::AWS
79
79
  # * +:ami+
80
80
  # * +:group+
81
81
  # * +:size+
82
- # * +:keypair+
83
- # * +:address+
82
+ # * +:keypair+
84
83
  # * +:private+ true or false (default)
85
84
  # * +:machine_data+
86
85
  # * +:min+ count
data/lib/rudy/huxtable.rb CHANGED
@@ -188,10 +188,12 @@ module Rudy
188
188
  fetch_machine_param(:size) || 'm1.small'
189
189
  end
190
190
 
191
- def current_machine_address
191
+ def current_machine_address(position='01')
192
192
  raise "No configuration" unless @@config
193
193
  raise "No machines configuration" unless @@config.machines
194
- @@config.machines.find_deferred(@@global.environment, @@global.role, :address)
194
+ raise "Position cannot be nil" if position.nil?
195
+ addresses = [fetch_machine_param(:addresses)].flatten.compact
196
+ addresses[position.to_i-1]
195
197
  end
196
198
 
197
199
  # TODO: fix machine_group to include zone
@@ -225,6 +227,18 @@ module Rudy
225
227
  #name.gsub(/key-/, '') # We keep the key- now
226
228
  end
227
229
 
230
+
231
+ # Looks for ENV-ROLE configuration in machines. There must be
232
+ # at least one definition in the config for this to return true
233
+ # That's how Rudy knows the current group is defined.
234
+ def known_machine_group?
235
+ return false if !@@config && !@@global
236
+ zon, env, rol = @@global.zone, @@global.environment, @@global.role
237
+ conf = @@config.machines.find_deferred(@@global.region, zon, [env, rol])
238
+ conf ||= @@config.machines.find_deferred(zon, [env, rol])
239
+ !conf.nil?
240
+ end
241
+
228
242
  private
229
243
 
230
244
 
@@ -279,16 +293,6 @@ module Rudy
279
293
  routine
280
294
  end
281
295
 
282
- # Looks for ENV-ROLE configuration in machines. There must be
283
- # at least one definition in the config for this to return true
284
- # That's how Rudy knows the current group is defined.
285
- def known_machine_group?
286
- return false if !@@config && !@@global
287
- zon, env, rol = @@global.zone, @@global.environment, @@global.role
288
- conf = @@config.machines.find_deferred(@@global.region, zon, [env, rol])
289
- conf ||= @@config.machines.find_deferred(zon, [env, rol])
290
- !conf.nil?
291
- end
292
296
 
293
297
  def fetch_machine_param(parameter)
294
298
  raise "No configuration" unless @@config
data/lib/rudy/machines.rb CHANGED
@@ -113,7 +113,6 @@ module Rudy
113
113
  :group => current_group_name,
114
114
  :keypair => root_keypairname,
115
115
  :zone => @@global.zone.to_s,
116
- :address => current_machine_address,
117
116
  :machine_data => Machine.generate_machine_data.to_yaml
118
117
  }.merge(opts)
119
118
 
@@ -121,6 +120,17 @@ module Rudy
121
120
  @awsid = inst.awsid
122
121
  @created = @starts = Time.now
123
122
  @state = inst.state
123
+ # Assign IP address to only the first instance
124
+ if current_machine_address(@position)
125
+ address = current_machine_address(@position)
126
+ puts "Associating #{address} to #{inst.awsid}"
127
+ begin
128
+ @radd.associate(address, inst.awsid)
129
+ rescue => ex
130
+ STDERR.puts "Error while associating address."
131
+ Rudy::Utils.bug()
132
+ end
133
+ end
124
134
  end
125
135
 
126
136
  self.save
@@ -201,8 +211,8 @@ module Rudy
201
211
 
202
212
 
203
213
  def destroy(&each_mach)
204
- raise MachineGroupNotRunning, current_machine_group unless running?
205
214
  raise MachineGroupNotDefined, current_machine_group unless known_machine_group?
215
+ raise MachineGroupNotRunning, current_machine_group unless running?
206
216
  list.each { |m| each_mach.call(m); } if each_mach
207
217
  list do |mach|
208
218
  puts "Destroying #{mach.name}"
data/lib/rudy/metadata.rb CHANGED
@@ -10,6 +10,7 @@ module Rudy
10
10
  @sdb = Rudy::AWS::SDB.new(a, s, r)
11
11
  @ec2inst = Rudy::AWS::EC2::Instances.new(a, s, r)
12
12
  @rvol = Rudy::AWS::EC2::Volumes.new(a, s, r)
13
+ @radd = Rudy::AWS::EC2::Addresses.new(a, s, r)
13
14
  init(*args)
14
15
  end
15
16
 
@@ -46,16 +46,26 @@ module Rudy; module Routines;
46
46
  # "No such file or directory while trying to determine filesystem size"
47
47
  sleep 2
48
48
 
49
- print "Creating ext3 filesystem for #{disk.device}... "
50
- @rbox.mkfs(:t, "ext3", :F, disk.device)
51
- @rbox.mkdir(:p, disk.path)
52
- puts "done"
49
+ begin
50
+ print "Creating ext3 filesystem for #{disk.device}... "
51
+ @rbox.mkfs(:t, "ext3", :F, disk.device)
52
+ @rbox.mkdir(:p, disk.path)
53
+ puts "done"
53
54
 
54
- print "Mounting at #{disk.path}... "
55
+ print "Mounting at #{disk.path}... "
55
56
 
56
- @rbox.mount(:t, 'ext3', disk.device, disk.path)
57
- disk.mounted = true
58
- disk.save
57
+ @rbox.mount(:t, 'ext3', disk.device, disk.path)
58
+ disk.mounted = true
59
+ disk.save
60
+ rescue Net::SSH::AuthenticationFailed, Net::SSH::HostKeyMismatch => ex
61
+ STDERR.puts "Error creating disk".color(:red)
62
+ STDERR.puts ex.message.color(:red)
63
+ rescue Rye::CommandNotFound => ex
64
+ puts " CommandNotFound: #{ex.message}".color(:red)
65
+ rescue
66
+ STDERR.puts "Error creating disk" .color(:red)
67
+ Rudy::Utils.bug
68
+ end
59
69
  puts "done"
60
70
 
61
71
  end
@@ -47,22 +47,30 @@ module Rudy; module Routines;
47
47
  # add the method on for the instance of rbox we are using.
48
48
  def rbox.rm(*args); cmd('rm', args); end
49
49
 
50
+
50
51
  if routine.is_a?(Caesars::Hash) && routine.has_key?(timing)
51
52
  puts "Connecting to #{hostname}"
52
- rbox.connect
53
+ begin
54
+ rbox.connect
55
+ rescue Net::SSH::AuthenticationFailed, Net::SSH::HostKeyMismatch => ex
56
+ STDERR.puts "Error connecting: #{ex.message}".color(:red)
57
+ STDERR.puts "Skipping scripts".color(:red)
58
+ end
59
+
53
60
  original_user = rbox.user
54
61
  scripts = [routine[timing]].flatten
55
62
  scripts.each do |script|
56
- user, command, *args = script.to_a.flatten.compact
57
- rbox.switch_user user # does nothing if it's the same user
58
- puts "Creating #{@@script_config_file}"
59
- rbox.safe = false
60
- puts rbox.echo("'#{sconf.to_hash.to_yaml}' > #{@@script_config_file}")
61
- rbox.safe = true
62
- rbox.chmod(600, @@script_config_file)
63
- puts %Q{Running (as #{user}): #{rbox.preview_command(command, args)}}
64
63
 
65
64
  begin
65
+ user, command, *args = script.to_a.flatten.compact
66
+ rbox.switch_user user # does nothing if it's the same user
67
+ puts "Creating #{@@script_config_file}"
68
+ rbox.safe = false
69
+ puts rbox.echo("'#{sconf.to_hash.to_yaml}' > #{@@script_config_file}")
70
+ rbox.safe = true
71
+ rbox.chmod(600, @@script_config_file)
72
+ puts %Q{Running (as #{user}): #{rbox.preview_command(command, args)}}
73
+
66
74
  ret = rbox.send(command, args)
67
75
  if ret.exit_code > 0
68
76
  puts " Exit code: #{ret.exit_code}".color(:red)
@@ -5,8 +5,11 @@ module Rudy; module Routines;
5
5
  class Shutdown < Rudy::Routines::Base
6
6
 
7
7
  def execute
8
- raise Rudy::PrivateKeyNotFound, root_keypairpath unless has_keypair?(:root)
9
8
  rmach = Rudy::Machines.new
9
+ raise Rudy::PrivateKeyNotFound, root_keypairpath unless has_keypair?(:root)
10
+ raise MachineGroupNotDefined, current_machine_group unless known_machine_group?
11
+ raise MachineGroupNotRunning, current_machine_group unless rmach.running?
12
+
10
13
  routine = fetch_routine_config(:shutdown)
11
14
  rbox_local = Rye::Box.new('localhost')
12
15
  sconf = fetch_script_config
@@ -5,9 +5,12 @@ module Rudy; module Routines;
5
5
  class Startup < Rudy::Routines::Base
6
6
 
7
7
  def execute
8
- # There's no keypair check here because Rudy::Machines will attempt
9
- # to create one.
10
8
  rmach = Rudy::Machines.new
9
+ # There's no keypair check here because Rudy::Machines will attempt
10
+ # to create one.
11
+ raise MachineGroupNotDefined, current_machine_group unless known_machine_group?
12
+ raise MachineGroupAlreadyRunning, current_machine_group if rmach.running?
13
+
11
14
  routine = fetch_routine_config(:startup)
12
15
  rbox_local = Rye::Box.new('localhost')
13
16
  sconf = fetch_script_config
data/lib/rudy.rb CHANGED
@@ -65,7 +65,7 @@ module Rudy
65
65
  unless defined?(MAJOR)
66
66
  MAJOR = 0.freeze
67
67
  MINOR = 6.freeze
68
- TINY = 4.freeze
68
+ TINY = 5.freeze
69
69
  end
70
70
  def self.to_s; [MAJOR, MINOR, TINY].join('.'); end
71
71
  def self.to_f; self.to_s.to_f; end
data/rudy.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = "rudy"
3
3
  s.rubyforge_project = 'rudy'
4
- s.version = "0.6.4"
4
+ s.version = "0.6.5"
5
5
  s.summary = "Rudy: Not your grandparent's deployment tool."
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
@@ -16,7 +16,7 @@
16
16
 
17
17
  s.add_dependency 'drydock', '>= 0.5.5'
18
18
  s.add_dependency 'caesars', '>= 0.5.4'
19
- s.add_dependency 'rye', '>= 0.5.1'
19
+ s.add_dependency 'rye', '>= 0.5.3'
20
20
 
21
21
  s.add_dependency 'echoe'
22
22
  s.add_dependency 'amazon-ec2', '>= 0.3.8' # region fix
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 0.5.1
43
+ version: 0.5.3
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: echoe