solutious-rudy 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGES.txt +9 -3
  2. data/README.rdoc +43 -1
  3. data/Rudyfile +15 -0
  4. data/bin/rudy +0 -12
  5. data/examples/debian-sinatra-thin/routines.rb +1 -1
  6. data/lib/rudy.rb +1 -1
  7. data/lib/rudy/routines.rb +4 -1
  8. data/lib/rudy/routines/helper.rb +1 -1
  9. data/lib/rudy/routines/helpers/dependshelper.rb +1 -1
  10. data/lib/rudy/routines/helpers/diskhelper.rb +3 -3
  11. data/lib/rudy/routines/helpers/scripthelper.rb +11 -14
  12. data/lib/rudy/routines/helpers/userhelper.rb +3 -3
  13. data/lib/rudy/routines/passthrough.rb +3 -3
  14. data/lib/rudy/scm.rb +1 -1
  15. data/lib/rudy/scm/git.rb +4 -4
  16. data/rudy.gemspec +1 -24
  17. metadata +1 -24
  18. data/lib/rudy/routines/helpers/scmhelper.rb +0 -39
  19. data/lib/rudy/routines/release.rb +0 -48
  20. data/test/01_mixins/10_hash_test.rb +0 -25
  21. data/test/10_config/00_setup_test.rb +0 -20
  22. data/test/10_config/30_machines_test.rb +0 -69
  23. data/test/15_scm/00_setup_test.rb +0 -20
  24. data/test/15_scm/20_git_test.rb +0 -61
  25. data/test/20_sdb/00_setup_test.rb +0 -16
  26. data/test/20_sdb/10_domains_test.rb +0 -115
  27. data/test/25_ec2/00_setup_test.rb +0 -29
  28. data/test/25_ec2/10_keypairs_test.rb +0 -41
  29. data/test/25_ec2/20_groups_test.rb +0 -131
  30. data/test/25_ec2/30_addresses_test.rb +0 -38
  31. data/test/25_ec2/40_volumes_test.rb +0 -49
  32. data/test/25_ec2/50_snapshots_test.rb +0 -74
  33. data/test/26_ec2_instances/00_setup_test.rb +0 -28
  34. data/test/26_ec2_instances/10_instances_test.rb +0 -83
  35. data/test/26_ec2_instances/50_images_test.rb +0 -13
  36. data/test/30_sdb_metadata/00_setup_test.rb +0 -21
  37. data/test/30_sdb_metadata/10_disks_test.rb +0 -109
  38. data/test/30_sdb_metadata/20_backups_test.rb +0 -102
  39. data/test/coverage.txt +0 -51
  40. data/test/helper.rb +0 -36
data/CHANGES.txt CHANGED
@@ -1,11 +1,19 @@
1
1
  RUDY, CHANGES
2
2
 
3
3
 
4
+
5
+ #### 0.8.2 (2009-05-28) ###############################
6
+
7
+ * CHANGE: Removed release routine code (it's now a passthrough) and scmhelper. All release stuff should
8
+ be implemented using the routine blocks.
9
+ * CHANGE: Passthrough routines no longer check if machine group is running.
10
+ * CHANGE: Local routines blocks now run from current working directory
11
+
12
+
4
13
  #### 0.8.1 (2009-05-18) ###############################
5
14
 
6
15
  * FIXED: The shutdown routine was not working for Windows instances
7
16
 
8
-
9
17
  #### 0.8.0 (2009-05-18) ###############################
10
18
 
11
19
  * ADDED: Better windows instance support during routines
@@ -20,7 +28,6 @@ RUDY, CHANGES
20
28
  * CHANGE: rudy-ec2 console now displays windows password automatically if keypair is supplied.
21
29
  * ADDED: register and destroy commands to rudy-ec2 images
22
30
 
23
-
24
31
  #### 0.7.4 (2009-05-10) ###############################
25
32
 
26
33
  * CHANGE: Keypairs now include zone. This was necessary to allow US and EU keypairs to
@@ -44,7 +51,6 @@ be stored in the same directory.
44
51
  * FIXED: Corrected a few minor interface errors in rudy-ec2
45
52
  * ADDED: rudy-ec2 console can now display the decoded admin password for Windows instances.
46
53
 
47
-
48
54
  #### 0.7.2 (2009-05-04) ###############################
49
55
 
50
56
  * FIXED: cli/routine.rb release method wasn't sending command alias (which broke rerelease)
data/README.rdoc CHANGED
@@ -18,6 +18,48 @@ All configuration is organized into the zones, environments, and roles that you
18
18
 
19
19
  <em>NOTE: This is a BETA release. That means Rudy's not ready for production use! See Project-Status[http://wiki.github.com/solutious/rudy/project-status].</em>
20
20
 
21
+ == Configuration
22
+
23
+ === Machines
24
+
25
+ The machines configuration describes the "physical" characteristics of your infrastructure.
26
+
27
+ env :stage do # Define an environment
28
+ ami 'ami-e348af8a'
29
+
30
+ role :app do # Define a role
31
+ addresses '11.22.33.44' # Use elastic IPs
32
+
33
+ disks do # Create EBS volumes
34
+ path "/rudy/disk1" do
35
+ size 100
36
+ device "/dev/sdr"
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ === Routines
43
+
44
+ The routines configuration describes repeatable processes that you can execute on your machines.
45
+
46
+ startup do # $ rudy startup
47
+ adduser :rudy
48
+ authorize :rudy # Enable passwordless login
49
+
50
+ disks do # Create a disk
51
+ restore "/rudy/disk1" # from a backup
52
+ end
53
+
54
+ after :rudy do # Run remote SSH commands
55
+ mkdir :p, "great" # $ mkdir -p great
56
+ touch "great/scott" # $ touch great/scott
57
+ ls :l, :a # $ ls -l -a
58
+ end
59
+ end
60
+
61
+
62
+
21
63
  == Features
22
64
 
23
65
  * Create complex environments with a single command
@@ -112,7 +154,7 @@ I'm very open to contributions!
112
154
  * Rubber -- http://github.com/wr0ngway/rubber/wikis
113
155
  * Moonshine -- http://github.com/railsmachine/moonshine/tree
114
156
  * Boto -- http://code.google.com/p/boto/
115
-
157
+ * Fabric -- http://www.nongnu.org/fab/
116
158
 
117
159
  == License
118
160
 
data/Rudyfile CHANGED
@@ -167,6 +167,7 @@ routines do
167
167
  end
168
168
  end
169
169
 
170
+
170
171
  anything do # $ rudy anything
171
172
  before :display_uptime # Specify a dependency
172
173
  script :rudy do # This is Ruby, so any valid syntax
@@ -180,5 +181,19 @@ routines do
180
181
  end
181
182
  end
182
183
 
184
+ git_example do
185
+ before_local do
186
+ # Store variables using global variables. But be
187
+ # aware that the dollar sign variables can be set
188
+ # anywhere.
189
+ @sha = git 'rev-parse', '--short', 'HEAD'
190
+ @tagname = Time.now.strftime("%Y-%m-%d-#{Rudy.sysinfo.user}-#{@sha}")
191
+ git 'tag', :a, @tagname, :m, "Another release by Rudy"
192
+ end
193
+ script_local do
194
+ echo @tagname
195
+ end
196
+ end
197
+
183
198
  end
184
199
 
data/bin/rudy CHANGED
@@ -77,18 +77,6 @@ class RudyCLI < Rudy::CLI::Base
77
77
  usage "rudy reboot"
78
78
  command :reboot => Rudy::CLI::Routines
79
79
 
80
- about "Create a release"
81
- usage "rudy release"
82
- command :release => Rudy::CLI::Routines
83
- command_alias :release, :rerelease
84
-
85
- #about "Update the release currently running in a machine group"
86
- #command :rerelease => Rudy::CLI::Routines
87
- #command_alias :rerelease, :rere
88
-
89
- #about "Deploy disk snapshots from one machine to another"
90
- #command :deploy => Rudy::CLI::Routines
91
-
92
80
 
93
81
  # ------------------------------------ RUDY MISCELLANEOUS --------
94
82
  # ------------------------------------------------------------------
@@ -61,7 +61,7 @@ routines do
61
61
  thin :c, sinatra_home, "stop"
62
62
  end
63
63
  end
64
-
64
+
65
65
 
66
66
  end
67
67
 
data/lib/rudy.rb CHANGED
@@ -38,7 +38,7 @@ module Rudy
38
38
  unless defined?(MAJOR)
39
39
  MAJOR = 0.freeze
40
40
  MINOR = 8.freeze
41
- TINY = 1.freeze
41
+ TINY = 2.freeze
42
42
  end
43
43
  def self.to_s; [MAJOR, MINOR, TINY].join('.'); end
44
44
  def self.to_f; self.to_s.to_f; end
data/lib/rudy/routines.rb CHANGED
@@ -81,6 +81,7 @@ module Rudy
81
81
  if Rudy::Routines::ScriptHelper.before_local?(routine) # before_local
82
82
  # Runs "before_local" scripts of routines config.
83
83
  puts task_separator("LOCAL SHELL")
84
+ lbox.cd Dir.pwd # Run local command block from current working directory
84
85
  Rudy::Routines::ScriptHelper.before_local(routine, sconf, lbox)
85
86
  end
86
87
  }
@@ -90,12 +91,13 @@ module Rudy
90
91
  # Runs "script_local" scripts of routines config.
91
92
  # NOTE: This is synonymous with before_local
92
93
  puts task_separator("LOCAL SHELL")
94
+ lbox.cd Dir.pwd # Run local command block from current working directory
93
95
  Rudy::Routines::ScriptHelper.script_local(routine, sconf, lbox)
94
96
  end
95
97
  }
96
98
 
97
99
  # Execute the action (create, list, destroy, restart)
98
- machines = enjoy_every_sandwich([]) { rmach.send(machine_action) }
100
+ machines = enjoy_every_sandwich([]) { rmach.send(machine_action) } || []
99
101
 
100
102
  machines.each do |machine|
101
103
  puts machine_separator(machine.name, machine.awsid) unless skip_header
@@ -239,6 +241,7 @@ module Rudy
239
241
  enjoy_every_sandwich {
240
242
  if Rudy::Routines::ScriptHelper.after_local?(routine) # after_local
241
243
  puts task_separator("LOCAL SHELL")
244
+ lbox.cd Dir.pwd # Run local command block from current working directory
242
245
  # Runs "after_local" scripts of routines config
243
246
  Rudy::Routines::ScriptHelper.after_local(routine, sconf, lbox)
244
247
  end
@@ -5,7 +5,7 @@ module Rudy
5
5
  module HelperBase
6
6
  include Rudy::Huxtable
7
7
 
8
- def execute_rbox_command(ret=nil, &command)
8
+ def trap_rbox_errors(ret=nil, &command)
9
9
  begin
10
10
  ret = command.call if command
11
11
  return unless ret.is_a?(Rye::Rap)
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Rudy; module Routines;
3
3
  module DependsHelper
4
- include Rudy::Routines::HelperBase # TODO: use execute_rbox_command
4
+ include Rudy::Routines::HelperBase # TODO: use trap_rbox_errors
5
5
  extend self
6
6
 
7
7
  def has_depends?(timing, routine)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Rudy; module Routines;
4
4
  module DiskHelper
5
- include Rudy::Routines::HelperBase # TODO: use execute_rbox_command
5
+ include Rudy::Routines::HelperBase # TODO: use trap_rbox_errors
6
6
  extend self
7
7
 
8
8
  def disks?(routine)
@@ -271,7 +271,7 @@ module Rudy; module Routines;
271
271
 
272
272
  if disk.mounted?
273
273
  print "Unmounting #{disk.path}..."
274
- execute_rbox_command { @rbox.umount(disk.path) }
274
+ trap_rbox_errors { @rbox.umount(disk.path) }
275
275
  puts " done"
276
276
  sleep 0.5
277
277
  end
@@ -307,7 +307,7 @@ module Rudy; module Routines;
307
307
 
308
308
  if disk.mounted?
309
309
  print "Unmounting #{disk.path}..."
310
- execute_rbox_command { @rbox.umount(disk.path) }
310
+ trap_rbox_errors { @rbox.umount(disk.path) }
311
311
  puts " done"
312
312
  sleep 0.5
313
313
  end
@@ -5,11 +5,11 @@ module Rudy; module Routines;
5
5
  # TODO: Rename to ShellHelper
6
6
  #++
7
7
  module ScriptHelper
8
- include Rudy::Routines::HelperBase # TODO: use execute_rbox_command
8
+ include Rudy::Routines::HelperBase # TODO: use trap_rbox_errors
9
9
  extend self
10
10
 
11
11
  @@script_types = [:after, :before, :after_local, :before_local, :script, :script_local]
12
- @@script_config_file = "rudy-config.yml"
12
+ @@script_config_file_name = "rudy-config.yml"
13
13
 
14
14
  # TODO: refactor using this_method
15
15
 
@@ -99,8 +99,12 @@ module Rudy; module Routines;
99
99
  raise "ScriptHelper: Not a Rye::Box" unless rbox.is_a?(Rye::Box)
100
100
  raise "ScriptHelper: #{timing}?" unless @@script_types.member?(timing)
101
101
 
102
+ # The config file that gets created on each remote machine
103
+ # will be created in the user's home directory.
104
+ script_config_remote_path = File.join(rbox.getenv['HOME'], @@script_config_file_name)
105
+
102
106
  if sconf && !sconf.empty?
103
- tf = Tempfile.new(@@script_config_file)
107
+ tf = Tempfile.new(@@script_config_file_name)
104
108
  Rudy::Utils.write_to_file(tf.path, sconf.to_hash.to_yaml, 'w')
105
109
  end
106
110
 
@@ -131,7 +135,7 @@ module Rudy; module Routines;
131
135
  next
132
136
  end
133
137
 
134
- execute_rbox_command {
138
+ trap_rbox_errors {
135
139
  # We need to create the config file for every script,
136
140
  # b/c the user may change and it would not be accessible.
137
141
  # We turn off safe mode so we can write the config file via SSH.
@@ -139,8 +143,8 @@ module Rudy; module Routines;
139
143
  # TODO: Replace with rbox.upload. Make it safe again!
140
144
  conf_str = StringIO.new
141
145
  conf_str.puts sconf.to_hash.to_yaml
142
- rbox.upload(conf_str, @@script_config_file)
143
- rbox.chmod(600, @@script_config_file)
146
+ rbox.upload(conf_str, script_config_remote_path)
147
+ rbox.chmod(600, script_config_remote_path)
144
148
  }
145
149
 
146
150
  begin
@@ -172,15 +176,8 @@ module Rudy; module Routines;
172
176
  exit 12 unless keep_going?
173
177
  end
174
178
 
175
- # I was gettings errors about script_config_file not existing. There
176
- # might be a race condition when the rm command is called too quickly.
177
- # It's also quite possible I'm off my rocker!
178
- ## NOTE: I believe this was an issue with Rye. I fixed it when I was
179
- ## noticing the same error in another place. It hasn't repeated.
180
- ## sleep 0.1
181
-
182
179
  rbox.cd # reset to home dir
183
- rbox.rudy_tmp_rm(@@script_config_file)
180
+ rbox.rudy_tmp_rm(:f, script_config_remote_path) # -f to ignore errors
184
181
  end
185
182
 
186
183
  # Return the borrowed rbox instance to the user it was provided with
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Rudy; module Routines;
3
3
  module UserHelper
4
- include Rudy::Routines::HelperBase # TODO: use execute_rbox_command
4
+ include Rudy::Routines::HelperBase # TODO: use trap_rbox_errors
5
5
  extend self
6
6
 
7
7
  def adduser?(routine)
@@ -20,7 +20,7 @@ module Rudy; module Routines;
20
20
  # adduser can prompt for info which we don't want.
21
21
  # useradd does not prompt (on Debian/Ubuntu at least).
22
22
  # We need to specify bash b/c the default is /bin/sh
23
- execute_rbox_command { rbox.useradd(args) }
23
+ trap_rbox_errors { rbox.useradd(args) }
24
24
  end
25
25
 
26
26
  def authorize?(routine)
@@ -28,7 +28,7 @@ module Rudy; module Routines;
28
28
  end
29
29
  def authorize(routine, machine, rbox)
30
30
  puts command_separator(:authorize_keys_remote, rbox.user)
31
- execute_rbox_command { rbox.authorize_keys_remote(routine.authorize) }
31
+ trap_rbox_errors { rbox.authorize_keys_remote(routine.authorize) }
32
32
  end
33
33
 
34
34
 
@@ -28,9 +28,9 @@ module Rudy; module Routines;
28
28
  rmach = Rudy::Machines.new
29
29
  raise Rudy::PrivateKeyNotFound, root_keypairpath unless has_keypair?(:root)
30
30
  raise MachineGroupNotDefined, current_machine_group unless known_machine_group?
31
- if !@@global.offline && !rmach.running?
32
- raise MachineGroupNotRunning, current_machine_group
33
- end
31
+ #if !@@global.offline && !rmach.running?
32
+ # raise MachineGroupNotRunning, current_machine_group
33
+ #end
34
34
  end
35
35
 
36
36
  end
data/lib/rudy/scm.rb CHANGED
@@ -36,7 +36,7 @@ module Rudy
36
36
  def raise_early_exceptions; raise "override raise_early_exceptions"; end
37
37
 
38
38
  # copied from routines/helper.rb
39
- def execute_rbox_command(ret=nil, &command)
39
+ def trap_rbox_errors(ret=nil, &command)
40
40
  begin
41
41
  ret = command.call
42
42
  puts ' ' << ret.stdout.join("#{$/} ") if !ret.stdout.empty?
data/lib/rudy/scm/git.rb CHANGED
@@ -69,10 +69,10 @@ module Rudy
69
69
 
70
70
  def delete_rtag(rtag=nil)
71
71
  rtag ||= @rtag
72
- ret = execute_rbox_command { Rye.shell(:git, 'tag', :d, rtag) }
72
+ ret = trap_rbox_errors { Rye.shell(:git, 'tag', :d, rtag) }
73
73
  raise ret.stderr.join($/) if ret.exit_code > 0 # TODO: retest
74
74
  # Equivalent to: "git push origin :tag-name" which deletes a remote tag
75
- ret = execute_rbox_command { Rye.shell(:git, "push #{@remote} :#{rtag}") } if @remote
75
+ ret = trap_rbox_errors { Rye.shell(:git, "push #{@remote} :#{rtag}") } if @remote
76
76
  raise ret.stderr.join($/) if ret.exit_code > 0
77
77
  true
78
78
  end
@@ -144,11 +144,11 @@ module Rudy
144
144
  rbox.upload(known_hosts, '.ssh/known_hosts')
145
145
  rbox.chmod('0600', '.ssh/known_hosts')
146
146
 
147
- execute_rbox_command {
147
+ trap_rbox_errors {
148
148
  rbox.git('clone', get_remote_uri, @path)
149
149
  }
150
150
  rbox.cd(@path)
151
- execute_rbox_command {
151
+ trap_rbox_errors {
152
152
  rbox.git('checkout', :b, @rtag)
153
153
  }
154
154
  rescue Rye::CommandError => ex
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.8.1"
4
+ s.version = "0.8.2"
5
5
  s.summary = "Rudy: Not your grandparents' EC2 deployment tool."
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
@@ -106,12 +106,10 @@
106
106
  lib/rudy/routines/helper.rb
107
107
  lib/rudy/routines/helpers/dependshelper.rb
108
108
  lib/rudy/routines/helpers/diskhelper.rb
109
- lib/rudy/routines/helpers/scmhelper.rb
110
109
  lib/rudy/routines/helpers/scripthelper.rb
111
110
  lib/rudy/routines/helpers/userhelper.rb
112
111
  lib/rudy/routines/passthrough.rb
113
112
  lib/rudy/routines/reboot.rb
114
- lib/rudy/routines/release.rb
115
113
  lib/rudy/routines/shutdown.rb
116
114
  lib/rudy/routines/startup.rb
117
115
  lib/rudy/scm.rb
@@ -123,27 +121,6 @@
123
121
  support/randomize-root-password
124
122
  support/rudy-ec2-startup
125
123
  support/update-ec2-ami-tools
126
- test/01_mixins/10_hash_test.rb
127
- test/10_config/00_setup_test.rb
128
- test/10_config/30_machines_test.rb
129
- test/15_scm/00_setup_test.rb
130
- test/15_scm/20_git_test.rb
131
- test/20_sdb/00_setup_test.rb
132
- test/20_sdb/10_domains_test.rb
133
- test/25_ec2/00_setup_test.rb
134
- test/25_ec2/10_keypairs_test.rb
135
- test/25_ec2/20_groups_test.rb
136
- test/25_ec2/30_addresses_test.rb
137
- test/25_ec2/40_volumes_test.rb
138
- test/25_ec2/50_snapshots_test.rb
139
- test/26_ec2_instances/00_setup_test.rb
140
- test/26_ec2_instances/10_instances_test.rb
141
- test/26_ec2_instances/50_images_test.rb
142
- test/30_sdb_metadata/00_setup_test.rb
143
- test/30_sdb_metadata/10_disks_test.rb
144
- test/30_sdb_metadata/20_backups_test.rb
145
- test/coverage.txt
146
- test/helper.rb
147
124
  )
148
125
 
149
126
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solutious-rudy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -204,12 +204,10 @@ files:
204
204
  - lib/rudy/routines/helper.rb
205
205
  - lib/rudy/routines/helpers/dependshelper.rb
206
206
  - lib/rudy/routines/helpers/diskhelper.rb
207
- - lib/rudy/routines/helpers/scmhelper.rb
208
207
  - lib/rudy/routines/helpers/scripthelper.rb
209
208
  - lib/rudy/routines/helpers/userhelper.rb
210
209
  - lib/rudy/routines/passthrough.rb
211
210
  - lib/rudy/routines/reboot.rb
212
- - lib/rudy/routines/release.rb
213
211
  - lib/rudy/routines/shutdown.rb
214
212
  - lib/rudy/routines/startup.rb
215
213
  - lib/rudy/scm.rb
@@ -221,27 +219,6 @@ files:
221
219
  - support/randomize-root-password
222
220
  - support/rudy-ec2-startup
223
221
  - support/update-ec2-ami-tools
224
- - test/01_mixins/10_hash_test.rb
225
- - test/10_config/00_setup_test.rb
226
- - test/10_config/30_machines_test.rb
227
- - test/15_scm/00_setup_test.rb
228
- - test/15_scm/20_git_test.rb
229
- - test/20_sdb/00_setup_test.rb
230
- - test/20_sdb/10_domains_test.rb
231
- - test/25_ec2/00_setup_test.rb
232
- - test/25_ec2/10_keypairs_test.rb
233
- - test/25_ec2/20_groups_test.rb
234
- - test/25_ec2/30_addresses_test.rb
235
- - test/25_ec2/40_volumes_test.rb
236
- - test/25_ec2/50_snapshots_test.rb
237
- - test/26_ec2_instances/00_setup_test.rb
238
- - test/26_ec2_instances/10_instances_test.rb
239
- - test/26_ec2_instances/50_images_test.rb
240
- - test/30_sdb_metadata/00_setup_test.rb
241
- - test/30_sdb_metadata/10_disks_test.rb
242
- - test/30_sdb_metadata/20_backups_test.rb
243
- - test/coverage.txt
244
- - test/helper.rb
245
222
  has_rdoc: true
246
223
  homepage: http://github.com/solutious/rudy
247
224
  post_install_message: