solutious-rudy 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +20 -6
- data/README.rdoc +3 -3
- data/Rudyfile +27 -41
- data/bin/rudy +8 -3
- data/lib/rudy.rb +2 -2
- data/lib/rudy/cli/routines.rb +4 -20
- data/lib/rudy/config.rb +1 -0
- data/lib/rudy/config/objects.rb +29 -33
- data/lib/rudy/huxtable.rb +9 -1
- data/lib/rudy/routines.rb +121 -104
- data/lib/rudy/routines/helper.rb +26 -5
- data/lib/rudy/routines/helpers/scripthelper.rb +56 -31
- data/lib/rudy/routines/helpers/userhelper.rb +2 -2
- data/lib/rudy/routines/passthrough.rb +11 -11
- data/lib/rudy/routines/reboot.rb +1 -1
- data/lib/rudy/routines/startup.rb +1 -1
- data/rudy.gemspec +5 -16
- metadata +4 -24
- data/examples/README.md +0 -10
- data/examples/debian-sinatra-passenger/commands.rb +0 -19
- data/examples/debian-sinatra-passenger/machines.rb +0 -32
- data/examples/debian-sinatra-passenger/routines.rb +0 -30
- data/examples/debian-sinatra-thin/commands.rb +0 -17
- data/examples/debian-sinatra-thin/machines.rb +0 -35
- data/examples/debian-sinatra-thin/routines.rb +0 -72
- data/lib/rudy/scm.rb +0 -75
- data/lib/rudy/scm/git.rb +0 -217
- data/lib/rudy/scm/svn.rb +0 -110
data/CHANGES.txt
CHANGED
@@ -1,13 +1,26 @@
|
|
1
1
|
RUDY, CHANGES
|
2
2
|
|
3
3
|
|
4
|
+
#### 0.8.3 (2009-06-03) ###############################
|
4
5
|
|
5
|
-
|
6
|
+
* CHANGE: Now requires rye-0.7.3 (disable_safe_mode method)
|
7
|
+
* CHANGE: Rye safe-mode is enabled after each routines script block to force disabling it
|
8
|
+
explicitly in every block it's needed.
|
9
|
+
* CHANGE: Removed grit dependency
|
10
|
+
|
11
|
+
|
12
|
+
#### 0.8.2 (2009-06-01) ###############################
|
6
13
|
|
7
14
|
* CHANGE: Removed release routine code (it's now a passthrough) and scmhelper. All release stuff should
|
8
15
|
be implemented using the routine blocks.
|
9
16
|
* CHANGE: Passthrough routines no longer check if machine group is running.
|
10
17
|
* CHANGE: Local routines blocks now run from current working directory
|
18
|
+
* CHANGE: Removed SCM classes (moved logic to the Arcade)
|
19
|
+
* CHANGE: Moved examples to the Arcade (experimental)
|
20
|
+
* CHANGE: Command output in routines is now displayed only when verbose is 1 or more.
|
21
|
+
* ADDED: Routine blocks now receive command line options and arguments
|
22
|
+
* ADDED: Commands configuration now supports inline blocks
|
23
|
+
* ADDED: Rudy now looks for ~/.rudy/*.rb config files.
|
11
24
|
|
12
25
|
|
13
26
|
#### 0.8.1 (2009-05-18) ###############################
|
@@ -31,8 +44,9 @@ RUDY, CHANGES
|
|
31
44
|
#### 0.7.4 (2009-05-10) ###############################
|
32
45
|
|
33
46
|
* CHANGE: Keypairs now include zone. This was necessary to allow US and EU keypairs to
|
34
|
-
be stored in the same directory.
|
35
|
-
* CHANGE: Moved non-rudy specific modules to separate projects (storable, sysinfo, annoy,
|
47
|
+
be stored in the same directory.
|
48
|
+
* CHANGE: Moved non-rudy specific modules to separate projects (storable, sysinfo, annoy,
|
49
|
+
console -> Drydock, escape -> Rye, tryouts -> tryouts/).
|
36
50
|
* CHANGE: Renamed restart routine to reboot to make it clear it's about the machine
|
37
51
|
* CHANGE: Renamed Rudy::Disk to Rudy::MetaData::Disk
|
38
52
|
* CHANGE: Short alias for rudy-ec2 snapshot is now 's' (instead of 't')
|
@@ -96,7 +110,7 @@ to maintain consistency in documentation.
|
|
96
110
|
|
97
111
|
* ADDED: rudy-ec2 status can now display EU status
|
98
112
|
* FIXED: Fixed bug on instance create. Instance.groups was nil, now it returns
|
99
|
-
empty Array.
|
113
|
+
empty Array.
|
100
114
|
|
101
115
|
#### 0.6.6 (2009-04-22) ###############################
|
102
116
|
|
@@ -185,9 +199,9 @@ NOTE: This is a complete re-write from 0.1
|
|
185
199
|
* CHANGE: upgrade to drydock 0.3.3
|
186
200
|
* ADDED: All time references are converted to UTC
|
187
201
|
* ADDED: Safer "Are you sure?". Number of characters to enter is
|
188
|
-
|
202
|
+
commiserate with amount of danger.
|
189
203
|
* ADDED: CLIs: myaddress, addresses, images, instances,
|
190
|
-
|
204
|
+
disks, connect, copy, stage, backups, volumes
|
191
205
|
* ADDED: Metadata storage to SimpleDB for disks, backups
|
192
206
|
* ADDED: Creates EBS volumes based on startup from metadata
|
193
207
|
* ADDED: Automated release process
|
data/README.rdoc
CHANGED
@@ -52,9 +52,9 @@ The routines configuration describes repeatable processes that you can execute o
|
|
52
52
|
end
|
53
53
|
|
54
54
|
after :rudy do # Run remote SSH commands
|
55
|
-
mkdir :p, "great"
|
56
|
-
touch "great/scott"
|
57
|
-
ls :l, :a
|
55
|
+
mkdir :p, "great" # $ mkdir -p great
|
56
|
+
touch "great/scott" # $ touch great/scott
|
57
|
+
ls :l, :a # $ ls -l -a
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
data/Rudyfile
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
# ./.rudy/config
|
7
7
|
# ~/.rudy/config
|
8
8
|
#
|
9
|
+
# ~/.rudy/*.rb
|
9
10
|
# ./Rudyfile
|
10
11
|
# ./machines.rb, ./routines.rb, ./commands.rb
|
11
12
|
# ./config/rudy/*.rb
|
@@ -48,9 +49,9 @@ machines do
|
|
48
49
|
#addresses '11.22.33.44' # Define an elastic IP to reuse
|
49
50
|
|
50
51
|
disks do # Define EBS volumes
|
51
|
-
path
|
52
|
+
path '/rudy/disk1' do # The paths can be anything but
|
52
53
|
size 2 # they must be unique.
|
53
|
-
device
|
54
|
+
device '/dev/sdr' # Devices must be unique too.
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
@@ -92,11 +93,12 @@ end
|
|
92
93
|
#
|
93
94
|
commands do
|
94
95
|
allow :make
|
95
|
-
allow :gem_install,
|
96
|
-
allow :apt_get,
|
96
|
+
allow :gem_install, '/usr/bin/gem', 'install', :V, '--no-rdoc', '--no-ri'
|
97
|
+
allow :apt_get, 'apt-get', :y, :q
|
98
|
+
allow :floo, :time, 1 do
|
99
|
+
end
|
97
100
|
end
|
98
101
|
|
99
|
-
|
100
102
|
# ----------------------------------------------------------- ROUTINES --------
|
101
103
|
# The routines block describes the repeatable processes for each machine group.
|
102
104
|
# To run a routine, specify its name on the command-line: rudy startup
|
@@ -104,28 +106,28 @@ routines do
|
|
104
106
|
|
105
107
|
env :stage, :prod do # We'll define routines for the stage-app
|
106
108
|
role :app do # and prod-app machine groups
|
107
|
-
|
109
|
+
|
108
110
|
startup do # $ rudy startup
|
109
|
-
adduser :rudy # Create a user called
|
111
|
+
adduser :rudy # Create a user called 'rudy'
|
110
112
|
authorize :rudy # Enable passwordless logins as rudy
|
111
113
|
#
|
112
114
|
disks do # Define EBS volume routines
|
113
|
-
create
|
115
|
+
create '/rudy/disk1' # Create an EBS volume, attach it, give
|
114
116
|
end # it a filesystem, and mount it.
|
115
117
|
#
|
116
118
|
after :rudy do # Run remote SSH commands after startup
|
117
|
-
mkdir :p,
|
118
|
-
touch
|
119
|
-
ls :l, :a
|
119
|
+
mkdir :p, 'great' # $ mkdir -p great
|
120
|
+
touch 'great/scott' # $ touch great/scott
|
121
|
+
ls :l, :a, '*' # $ ls -l -a *
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
123
125
|
shutdown do # $ rudy shutdown
|
124
|
-
|
126
|
+
script :root do # Run remote SSH commands before shutdown
|
125
127
|
uptime
|
126
128
|
end
|
127
129
|
disks do
|
128
|
-
destroy
|
130
|
+
destroy '/rudy/disk1' # Unmount and destroy the EBS volume
|
129
131
|
end
|
130
132
|
end
|
131
133
|
|
@@ -140,14 +142,14 @@ routines do
|
|
140
142
|
|
141
143
|
backup do # $ rudy backup
|
142
144
|
disks do # A simple routine that creates an EBS
|
143
|
-
snapshot
|
145
|
+
snapshot '/rudy/disk1' # snapshot of the specified volume.
|
144
146
|
end
|
145
147
|
end
|
146
148
|
|
147
|
-
|
149
|
+
restore do # $ rudy restore
|
148
150
|
disks do # A contrived example of restoring a
|
149
|
-
destroy
|
150
|
-
restore
|
151
|
+
destroy '/rudy/disk1' # disk from a backup. NOTE: You'll need
|
152
|
+
restore '/rudy/disk1' # to run 'rudy backup' at least once
|
151
153
|
end # before otherise there are no backups
|
152
154
|
end # to restore from.
|
153
155
|
|
@@ -157,43 +159,27 @@ routines do
|
|
157
159
|
# Define global routines available to all machine groups
|
158
160
|
# This routine will update a basic Debian machine and
|
159
161
|
# install essential libraries.
|
160
|
-
# See
|
162
|
+
# See http://github.com/rudy/arcade
|
161
163
|
sysupdate do # $ rudy sysupdate
|
162
164
|
before :root do
|
163
|
-
apt_get
|
164
|
-
apt_get
|
165
|
-
apt_get
|
165
|
+
apt_get 'update' # Update debian / ubuntu
|
166
|
+
apt_get 'install', 'build-essential', 'sqlite3', 'libsqlite3-dev'
|
167
|
+
apt_get 'install', 'apache2-prefork-dev', 'libapr1-dev'
|
166
168
|
gem_install 'rudy'
|
167
169
|
end
|
168
170
|
end
|
169
171
|
|
170
|
-
|
171
172
|
anything do # $ rudy anything
|
172
|
-
before :
|
173
|
-
|
173
|
+
before :uptime # Specify a dependency
|
174
|
+
script_local do # This is Ruby, so any valid syntax
|
174
175
|
ls :l # can be used in the definitions.
|
175
176
|
end # See: SysInfo gem for more info.
|
176
177
|
end
|
177
178
|
|
178
|
-
|
179
|
-
script :rudy do # NOTE: You can use 'dashes' on the
|
180
|
-
uptime # command-line instead of underscores
|
181
|
-
end
|
182
|
-
end
|
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
|
179
|
+
uptime do # $ rudy uptime
|
193
180
|
script_local do
|
194
|
-
|
181
|
+
uptime
|
195
182
|
end
|
196
183
|
end
|
197
|
-
|
198
184
|
end
|
199
185
|
|
data/bin/rudy
CHANGED
@@ -21,8 +21,8 @@ require 'rudy/cli'
|
|
21
21
|
class RudyCLI < Rudy::CLI::Base
|
22
22
|
|
23
23
|
debug :off
|
24
|
-
default :machines
|
25
|
-
trawler :passthrough
|
24
|
+
default :machines # when no command is provided
|
25
|
+
trawler :passthrough # unknown command names will forward here.
|
26
26
|
|
27
27
|
# ------------------------------------------ RUDY GLOBALS --------
|
28
28
|
# ------------------------------------------------------------------
|
@@ -62,19 +62,24 @@ class RudyCLI < Rudy::CLI::Base
|
|
62
62
|
|
63
63
|
# A "do nothing" routine. Passthrough simply executes a routine
|
64
64
|
# config block. Drydock's trawler uses this for unknown commands.
|
65
|
-
about "A
|
65
|
+
about "A passthrough for custom routines"
|
66
|
+
usage "rudy [custom-routine]"
|
67
|
+
option :m, :message, String, "A message"
|
66
68
|
command :passthrough => Rudy::CLI::Routines
|
67
69
|
|
68
70
|
about "Startup a machine group"
|
69
71
|
usage "rudy startup"
|
72
|
+
option :m, :message, String, "A message"
|
70
73
|
command :startup => Rudy::CLI::Routines
|
71
74
|
|
72
75
|
about "Shutdown a machine group"
|
73
76
|
usage "rudy shutdown"
|
77
|
+
option :m, :message, String, "A message"
|
74
78
|
command :shutdown => Rudy::CLI::Routines
|
75
79
|
|
76
80
|
about "Reboot a machine group"
|
77
81
|
usage "rudy reboot"
|
82
|
+
option :m, :message, String, "A message"
|
78
83
|
command :reboot => Rudy::CLI::Routines
|
79
84
|
|
80
85
|
|
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 =
|
41
|
+
TINY = 3.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
|
@@ -163,6 +163,6 @@ require 'rudy/aws' # is
|
|
163
163
|
require 'rudy/metadata' # important
|
164
164
|
require 'rudy/machines'
|
165
165
|
require 'rudy/routines'
|
166
|
-
|
166
|
+
|
167
167
|
|
168
168
|
|
data/lib/rudy/cli/routines.rb
CHANGED
@@ -4,7 +4,7 @@ module Rudy; module CLI;
|
|
4
4
|
class Routines < Rudy::CLI::CommandBase
|
5
5
|
|
6
6
|
def startup_valid?
|
7
|
-
@rr = Rudy::Routines::Startup.new
|
7
|
+
@rr = Rudy::Routines::Startup.new(@alias, @option, @argv)
|
8
8
|
@rr.raise_early_exceptions
|
9
9
|
true
|
10
10
|
end
|
@@ -17,7 +17,7 @@ module Rudy; module CLI;
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def reboot_valid?
|
20
|
-
@rr = Rudy::Routines::Reboot.new
|
20
|
+
@rr = Rudy::Routines::Reboot.new(@alias, @option, @argv)
|
21
21
|
@rr.raise_early_exceptions
|
22
22
|
true
|
23
23
|
end
|
@@ -29,24 +29,8 @@ module Rudy; module CLI;
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def release_valid?
|
33
|
-
@rr = Rudy::Routines::Release.new(@alias) # Important: could be rerelease
|
34
|
-
@rr.raise_early_exceptions
|
35
|
-
true
|
36
|
-
end
|
37
|
-
def release
|
38
|
-
machines = @rr.execute
|
39
|
-
|
40
|
-
unless machines.empty?
|
41
|
-
puts $/, "The following machines were processed:"
|
42
|
-
machines.each do |machine|
|
43
|
-
puts machine.to_s
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
32
|
def passthrough_valid?
|
49
|
-
@rr = Rudy::Routines::Passthrough.new(@alias)
|
33
|
+
@rr = Rudy::Routines::Passthrough.new(@alias, @option, @argv)
|
50
34
|
@rr.raise_early_exceptions
|
51
35
|
true
|
52
36
|
end
|
@@ -76,7 +60,7 @@ module Rudy; module CLI;
|
|
76
60
|
end
|
77
61
|
|
78
62
|
def shutdown_valid?
|
79
|
-
@rr = Rudy::Routines::Shutdown.new
|
63
|
+
@rr = Rudy::Routines::Shutdown.new(@alias, @option, @argv)
|
80
64
|
@rr.raise_early_exceptions
|
81
65
|
true
|
82
66
|
end
|
data/lib/rudy/config.rb
CHANGED
@@ -64,6 +64,7 @@ module Rudy
|
|
64
64
|
typelist = self.keys.collect { |g| "#{g}.rb" }.join(',')
|
65
65
|
|
66
66
|
# Rudy then looks for the rest of the config in these locations
|
67
|
+
@paths += Dir.glob(File.join(Rudy.sysinfo.home, '.rudy', '*.rb')) || []
|
67
68
|
@paths += Dir.glob(File.join(cwd, 'Rudyfile')) || []
|
68
69
|
@paths += Dir.glob(File.join(cwd, 'config', 'rudy', '*.rb')) || []
|
69
70
|
@paths += Dir.glob(File.join(cwd, '.rudy', '*.rb')) || []
|
data/lib/rudy/config/objects.rb
CHANGED
@@ -33,11 +33,14 @@ class Rudy::Config
|
|
33
33
|
@@processed = false
|
34
34
|
forced_array :allow
|
35
35
|
forced_array :deny
|
36
|
+
chill :allow
|
37
|
+
|
36
38
|
def init
|
37
39
|
# We can't process the Rye::Cmd commands here because the
|
38
40
|
# DSL hasn't been parsed yet so Rudy::Config.postprocess
|
39
41
|
# called the following postprocess method after parsing.
|
40
42
|
end
|
43
|
+
|
41
44
|
# Process the directives specified in the commands config.
|
42
45
|
# NOTE: This affects the processing of the routines config
|
43
46
|
# which only works if commands is parsed first. This works
|
@@ -54,52 +57,45 @@ class Rudy::Config
|
|
54
57
|
# commands do
|
55
58
|
# allow :kill
|
56
59
|
# allow :custom_script, '/full/path/2/custom_script'
|
57
|
-
# allow :git_clone,
|
60
|
+
# allow :git_clone, '/usr/bin/git', 'clone'
|
58
61
|
# end
|
59
62
|
#
|
60
63
|
# * Tells Routines to force_array on the command name.
|
61
64
|
# This is important b/c of the way we parse commands
|
62
65
|
self.allow.each do |cmd|
|
63
|
-
cmd,
|
64
|
-
|
65
|
-
# If no path was specified, we can assume cmd is in the remote path so
|
66
|
-
# when we add the method to Rye::Cmd, we'll it the path is "cmd".
|
67
|
-
path ||= cmd.to_s
|
68
|
-
|
69
|
-
# We cannot allow new commands to be defined that conflict use known
|
70
|
-
# routines keywords. This is based on keywords in the current config.
|
71
|
-
# NOTE: We can't check for this right now b/c the routines config
|
72
|
-
# won't necessarily have been parsed yet. TODO: Figure it out!
|
73
|
-
#if Caesars.known_symbol_by_glass?(:routines, cmd)
|
74
|
-
# raise ReservedKeyword.new(:commands, cmd)
|
75
|
-
#end
|
66
|
+
cmd, *args = *cmd
|
76
67
|
|
77
68
|
# We can allow existing commands to be overridden but we
|
78
69
|
# print a message to STDERR so the user knows what's up.
|
79
|
-
STDERR.puts "
|
80
|
-
|
81
|
-
# The second argument if supplied must be a filesystem path
|
82
|
-
raise PathNotString.new(:commands, cmd) if path && !path.is_a?(String)
|
70
|
+
STDERR.puts "Redefining #{cmd}" if Rye::Cmd.can?(cmd)
|
83
71
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
72
|
+
if args.last.is_a?(Proc)
|
73
|
+
block = args.pop
|
74
|
+
Rye::Cmd.add_command(cmd, nil, args, &block)
|
75
|
+
else
|
76
|
+
# If no path was specified, we can assume cmd is in the remote path so
|
77
|
+
# when we add the method to Rye::Cmd, we'll it the path is "cmd".
|
78
|
+
path = args.shift || cmd.to_s
|
79
|
+
|
80
|
+
raise PathNotString.new(:commands, cmd) if path && !path.is_a?(String)
|
81
|
+
|
82
|
+
Rye::Cmd.add_command cmd, path, args
|
83
|
+
|
92
84
|
end
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
85
|
+
|
86
|
+
|
87
|
+
## We cannot allow new commands to be defined that conflict use known
|
88
|
+
## routines keywords. This is based on keywords in the current config.
|
89
|
+
## NOTE: We can't check for this right now b/c the routines config
|
90
|
+
## won't necessarily have been parsed yet. TODO: Figure it out!
|
91
|
+
##if Caesars.known_symbol_by_glass?(:routines, cmd)
|
92
|
+
## raise ReservedKeyword.new(:commands, cmd)
|
93
|
+
##end
|
99
94
|
|
100
95
|
end
|
96
|
+
|
101
97
|
## NOTE: We now process command blocks as Procs rather than individual commands.
|
102
|
-
|
98
|
+
## There's currently no need to ForceRefresh here
|
103
99
|
##raise Caesars::Config::ForceRefresh.new(:routines)
|
104
100
|
end
|
105
101
|
end
|
data/lib/rudy/huxtable.rb
CHANGED
@@ -241,6 +241,7 @@ module Rudy
|
|
241
241
|
# That's how Rudy knows the current group is defined.
|
242
242
|
def known_machine_group?
|
243
243
|
raise NoConfig unless @@config
|
244
|
+
return true if default_machine_group?
|
244
245
|
raise NoMachinesConfig unless @@config.machines
|
245
246
|
return false if !@@config && !@@global
|
246
247
|
zon, env, rol = @@global.zone, @@global.environment, @@global.role
|
@@ -327,13 +328,20 @@ module Rudy
|
|
327
328
|
def fetch_machine_param(parameter)
|
328
329
|
raise "No parameter specified" unless parameter
|
329
330
|
raise NoConfig unless @@config
|
330
|
-
|
331
|
+
return if !@@config.machines && default_machine_group?
|
332
|
+
raise NoMachinesConfig if !@@config.machines
|
331
333
|
raise NoGlobal unless @@global
|
332
334
|
top_level = @@config.machines.find(parameter)
|
333
335
|
mc = fetch_machine_config
|
334
336
|
mc[parameter] || top_level || nil
|
335
337
|
end
|
336
338
|
|
339
|
+
# Returns true if this is the default machine environment and role
|
340
|
+
def default_machine_group?
|
341
|
+
@@global.environment == @@config.defaults.environment &&
|
342
|
+
@@global.role == @@config.defaults.role
|
343
|
+
end
|
344
|
+
|
337
345
|
def fetch_machine_config
|
338
346
|
raise NoConfig unless @@config
|
339
347
|
raise NoMachinesConfig unless @@config.machines
|