rudy 0.6.8 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/CHANGES.txt +15 -2
  2. data/README.rdoc +30 -23
  3. data/Rakefile +5 -5
  4. data/Rudyfile +87 -66
  5. data/bin/rudy +120 -167
  6. data/bin/rudy-ec2 +17 -13
  7. data/bin/rudy-s3 +6 -4
  8. data/bin/rudy-sdb +5 -4
  9. data/lib/annoy.rb +1 -1
  10. data/lib/console.rb +1 -3
  11. data/lib/rudy.rb +11 -25
  12. data/lib/rudy/aws/ec2/instance.rb +1 -1
  13. data/lib/rudy/aws/ec2/volume.rb +2 -2
  14. data/lib/rudy/aws/sdb/error.rb +2 -1
  15. data/lib/rudy/cli.rb +10 -1
  16. data/lib/rudy/cli/aws/ec2/addresses.rb +1 -1
  17. data/lib/rudy/cli/aws/ec2/images.rb +3 -1
  18. data/lib/rudy/cli/aws/ec2/instances.rb +2 -2
  19. data/lib/rudy/cli/candy.rb +11 -0
  20. data/lib/rudy/cli/config.rb +25 -44
  21. data/lib/rudy/cli/machines.rb +30 -10
  22. data/lib/rudy/cli/routines.rb +67 -19
  23. data/lib/rudy/config.rb +30 -13
  24. data/lib/rudy/config/objects.rb +135 -10
  25. data/lib/rudy/disks.rb +8 -52
  26. data/lib/rudy/global.rb +9 -5
  27. data/lib/rudy/guidelines.rb +18 -0
  28. data/lib/rudy/huxtable.rb +29 -19
  29. data/lib/rudy/machines.rb +10 -7
  30. data/lib/rudy/mixins/hash.rb +25 -0
  31. data/lib/rudy/routines.rb +160 -10
  32. data/lib/rudy/routines/helper.rb +50 -0
  33. data/lib/rudy/routines/helpers/diskhelper.rb +44 -18
  34. data/lib/rudy/routines/helpers/scmhelper.rb +39 -0
  35. data/lib/rudy/routines/helpers/scripthelper.rb +86 -35
  36. data/lib/rudy/routines/helpers/userhelper.rb +37 -0
  37. data/lib/rudy/routines/passthrough.rb +36 -0
  38. data/lib/rudy/routines/release.rb +38 -22
  39. data/lib/rudy/routines/shutdown.rb +20 -49
  40. data/lib/rudy/routines/startup.rb +20 -47
  41. data/lib/rudy/scm.rb +75 -0
  42. data/lib/rudy/scm/git.rb +215 -0
  43. data/lib/rudy/scm/svn.rb +7 -6
  44. data/lib/rudy/utils.rb +12 -30
  45. data/lib/storable.rb +4 -1
  46. data/lib/sysinfo.rb +10 -0
  47. data/rudy.gemspec +21 -9
  48. data/test/01_mixins/10_hash_test.rb +25 -0
  49. data/test/{05_config → 10_config}/00_setup_test.rb +1 -1
  50. data/test/{05_config → 10_config}/30_machines_test.rb +1 -1
  51. data/test/15_scm/00_setup_test.rb +20 -0
  52. data/test/15_scm/20_git_test.rb +61 -0
  53. data/test/helper.rb +1 -1
  54. data/vendor/highline-1.5.1/Rakefile +3 -3
  55. metadata +41 -12
  56. data/bin/ird +0 -175
data/CHANGES.txt CHANGED
@@ -2,10 +2,23 @@ RUDY, CHANGES
2
2
 
3
3
  * TODO: Remove string messages for non-string output formats
4
4
  * TODO: Support for reserved instances
5
- * TODO: Test for zone and region support
5
+ * TODO: Tests for zone and region support
6
6
  * TODO: Support for machine image attributes
7
7
  * TODO: Support for product codes
8
- * TODO: HTTPS
8
+ * TODO: Tests for AWS HTTPS
9
+
10
+
11
+ #### 0.7.0 (2009-04-??) ###############################
12
+
13
+ * CHANGE: Upgrade to Drydock 0.6, Caesars 0.6, and Rye 0.6
14
+ * CHANGE: Updated Routines configuration syntax for specifying shell commands
15
+ * ADDED: Releases via local git repository
16
+ * ADDED: authorize and adduser directives to routines config.
17
+ * ADDED: Improved CLI output for routines.
18
+ * ADDED: Commands configuration for custom SSH commands
19
+ * ADDED: Auto-set hostname to machine name
20
+ * ADDED: Support for arbitrary routines via passthrough
21
+
9
22
 
10
23
 
11
24
  #### 0.6.8 (2009-04-24) ###############################
data/README.rdoc CHANGED
@@ -1,8 +1,8 @@
1
- = Rudy - v0.6 ALPHA
1
+ = Rudy - v0.7 BETA
2
2
 
3
- *Rudy is a command-line development and deployment tool for Amazon Web Services.*
3
+ <b>Not your grandparents' EC2 deployment tool.</b>
4
4
 
5
- It helps you build and manage machines in EC2 by organizing them into groups of _environments_ and _roles_. These are called _machine_ _groups_. <tt>stage</tt> is the default environment and <tt>app</tt> is the default role. You can run multiple machines with the same role. These are called _positions_. Rudy also supports running machine groups across availability _zones_.
5
+ Rudy is a command-line development and deployment tool for Amazon Web Services. It helps you build and manage machines in EC2 by organizing them into groups of _environments_ and _roles_. These are called _machine_ _groups_. <tt>stage</tt> is the default environment and <tt>app</tt> is the default role. You can run multiple machines with the same role. These are called _positions_. Rudy also supports running machine groups across availability _zones_.
6
6
 
7
7
  When you put all this together, you have a unique name for every machine. The default machine is:
8
8
 
@@ -14,16 +14,22 @@ When you put all this together, you have a unique name for every machine. The de
14
14
 
15
15
  All configuration is organized into the zones, environments, and roles that you specify (Rudy assumes positions are identical which is important for backups and scaling). And as you'd expect, the defaults can be changed too (in <tt>~/.rudy/config</tt>).
16
16
 
17
- <b>NOTE: This is an ALPHA release. That means Rudy's not ready for production use! See Alpha Notice.</b>
17
+ <b>See Getting-Started[http://wiki.github.com/solutious/rudy/getting-started] for more info.</b>
18
+
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>
18
20
 
19
21
  == Features
20
22
 
21
23
  * Create complex environments with a single command
22
- * Launch multiple instances
24
+ * Launch multiple instances
23
25
  * Assign elastic IP addresses
24
26
  * Create EBS volumes, attach to instances, format, and mount
25
27
  * Run scripts locally and remotely automatically
26
- * Supports any Amazon machine image (AMI)
28
+ * Organize instances into environments and roles
29
+ * Powerful command-line tools
30
+ * <tt>$ rudy -u root ssh</tt>
31
+ * <tt>$ rudy -e testing -r database startup</tt>
32
+ * Use _any_ Amazon machine image (AMI)
27
33
  * Complete command-line interface for EC2. See <tt>bin/rudy-ec2</tt>.
28
34
 
29
35
  == Installation
@@ -39,7 +45,8 @@ or via download:
39
45
 
40
46
  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>
41
47
 
42
- See Getting-Started[http://wiki.github.com/solutious/rudy/getting-started] for more info.
48
+ <b>See Getting-Started[http://wiki.github.com/solutious/rudy/getting-started] for more info.</b>
49
+
43
50
 
44
51
  == Pre-Requisites
45
52
 
@@ -48,7 +55,7 @@ See Getting-Started[http://wiki.github.com/solutious/rudy/getting-started] for m
48
55
  * SimpleDB[http://aws.amazon.com/simpledb/]
49
56
  * S3[http://aws.amazon.com/s3/]
50
57
  * OpenSSH[http://www.openssh.com/]
51
- * Ruby 1.8.x, 1.9.x, or JRuby 1.2
58
+ * Ruby[http://ruby-lang.org] 1.8.x, 1.9.x, or JRuby[http://jruby.codehaus.org] 1.2
52
59
  * Net::SSH[http://net-ssh.rubyforge.org/]
53
60
  * Net::SCP[http://net-ssh.rubyforge.org/]
54
61
  * amazon-ec2[http://github.com/grempe/amazon-ec2]
@@ -58,21 +65,15 @@ See Getting-Started[http://wiki.github.com/solutious/rudy/getting-started] for m
58
65
  * Caesars[http://github.com/delano/caesars]
59
66
 
60
67
 
61
- == Alpha Notice
62
-
63
- Rudy has been well tested and is currently being used in production in a private beta, but it's not ready for general production use. There are a few things to keep in mind while Rudy is in alpha status.
64
-
65
- * If you already have private SSH keys, back them up. Rudy is quite safe but hasn't been audited so backup your keys as a precaution.
66
- * If you're running EC2 instances in production, create a new set of AWS credentials (access key and secret key) to use with Rudy. This will ensure that Rudy has no access to your production instances.
67
- * Rudy commands and APIs may change in later releases. This means that if you create an environment with an alpha release and later upgrade Rudy, some things may not work as expected.
68
-
69
-
70
68
  == More Info
71
69
 
72
- * GitHub[http://github.com/solutious/rudy]
73
- * Documentation[http://wiki.github.com/solutious/rudy]
74
- * Issues[http://github.com/solutious/rudy/issues]
75
- * Inspiration[http://www.youtube.com/watch?v=CgaiIW5Rzes]
70
+ * Fork at GitHub[http://github.com/solutious/rudy]
71
+ * Read the Documentation[http://wiki.github.com/solutious/rudy]
72
+ * Submit issues to the IssueTracker[http://github.com/solutious/rudy/issues]
73
+ * Start a discussion on the GoogleGroup[http://groups.google.com/group/rudy-deployment]
74
+ * Find some Inspiration[http://www.youtube.com/watch?v=CgaiIW5Rzes]
75
+ * For all other inquires, email me directly: delano@solutious.com
76
+
76
77
 
77
78
  == Thanks
78
79
 
@@ -84,11 +85,17 @@ Rudy has been well tested and is currently being used in production in a private
84
85
  * Sam Aaron
85
86
  * Everyone at Utrecht.rb[http://groups.google.com/group/utrecht-rb]
86
87
  * Jamis Buck for Net::SSH and friends
88
+ * Glenn Rempe for amazon-ec2
89
+ * Marcel Molina Jr. for aws-s3
87
90
  * Keshia Knight Pulliam
88
91
 
92
+
89
93
  == Contributions
90
94
 
91
- I'm very open to contributions! For bigger features please fork the git repo and send me a pull request. For small or single file changes, send me an email with the details <tt>delano@solutious.com</tt>
95
+ I'm very open to contributions!
96
+
97
+ * For bigger features please fork the git repo and send me a pull request.
98
+ * For small or single file changes, send me an email with the details: <tt>delano@solutious.com</tt>
92
99
 
93
100
 
94
101
  == Credits
@@ -100,4 +107,4 @@ I'm very open to contributions! For bigger features please fork the git repo and
100
107
 
101
108
  == License
102
109
 
103
- See: LICENSE.txt
110
+ See: LICENSE.txt
data/Rakefile CHANGED
@@ -25,7 +25,7 @@ end
25
25
 
26
26
 
27
27
  namespace :test do
28
- desc 'Measures test coverage'
28
+ #about 'Measures test coverage'
29
29
  task :coverage do
30
30
  rm_f "coverage"
31
31
  rm_f "coverage.data"
@@ -71,7 +71,7 @@ end
71
71
 
72
72
  # From: shoulda/tasks/list_tests.rake
73
73
  namespace :shoulda do
74
- desc "List the names of the test methods in a specification like format"
74
+ #about "List the names of the test methods in a specification like format"
75
75
  task :list_fixed do
76
76
  $LOAD_PATH.unshift("test")
77
77
 
@@ -113,7 +113,7 @@ Rake::GemPackageTask.new(@spec) do |p|
113
113
  p.need_tar = true if RUBY_PLATFORM !~ /mswin/
114
114
  end
115
115
 
116
- task :release => [ :rdoc, :package ] do
116
+ task :release => [ "publish:gem", :clean, "publish:rdoc" ] do
117
117
  $: << File.join(File.dirname(__FILE__), 'lib')
118
118
  require "rudy"
119
119
  abort if Drydock.debug?
@@ -130,12 +130,12 @@ end
130
130
 
131
131
  # Rubyforge Release / Publish Tasks ==================================
132
132
 
133
- desc 'Publish website to rubyforge'
133
+ #about 'Publish website to rubyforge'
134
134
  task 'publish:rdoc' => 'doc/index.html' do
135
135
  sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/"
136
136
  end
137
137
 
138
- desc 'Public release to rubyforge'
138
+ #about 'Public release to rubyforge'
139
139
  task 'publish:gem' => [:package] do |t|
140
140
  sh <<-end
141
141
  rubyforge add_release -o Any -a CHANGES.txt -f -n README.rdoc #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem &&
data/Rudyfile CHANGED
@@ -1,9 +1,7 @@
1
- # = Rudy
1
+ # = Rudy -- Example configuration
2
2
  #
3
- # This is an example Rudy configuration.
4
- #
5
- # Rudy automatically looks for configuration files in the
6
- # following locations (in this order):
3
+ # Rudy automatically looks for configuration files in the following
4
+ # locations (in this order):
7
5
  #
8
6
  # ./.rudy/config
9
7
  # ~/.rudy/config
@@ -13,15 +11,15 @@
13
11
  # ./.rudy/*.rb
14
12
  # /etc/rudy/*.rb
15
13
  #
16
- # When multuple files are found, the configuration is
17
- # NOT OVERRIDDEN. It's ADDED / APPENDED. This means you can
18
- # split configuration across many files as you please.
14
+ # When multuple files are found, the configuration is NOT OVERRIDDEN,
15
+ # it's ADDED or APPENDED depending on context. This means you can split
16
+ # configuration across many files as you please.
19
17
  #
20
- # There are three sections: accounts, defaults, machines, and routines.
18
+ # There are four sections: accounts, defaults, machines, commands and routines.
21
19
  #
22
20
  # By convention, accounts and defaults go in ~/.rudy/config or ./.rudy/config
23
- # machines and routines configuration goes in ./Rudyfile or
24
- # ./config/rudy/machines.rb and ./config/rudy/routines.rb
21
+ # machines, commands and routines configuration go in ./Rudyfile or into
22
+ # separate files in ./.rudy or ./config/rudy (machines.rb, commands.rb, ...)
25
23
  #
26
24
 
27
25
  # --------------------------------------------------------- MACHINES --------
@@ -29,51 +27,44 @@
29
27
  # of your environments.
30
28
  machines do
31
29
 
32
- users do
33
- # If you already have private keys for logging in to your EC2 instances
34
- # EC2 instances you can specify them here and Rudy will use these instead.
35
- # root :keypair => "/#{Rudy.sysinfo.home}/.rudy/root-private-key"
36
- end
37
-
38
30
  zone :"us-east-1b" do
39
- ami 'ami-235fba4a' # Amazon Getting Started AMI (US)
31
+ ami 'ami-235fba4a' # Amazon Getting Started AMI (US)
40
32
  end
41
33
  zone :"eu-west-1b" do
42
- ami 'ami-e40f2790' # Amazon Getting Started AMI (EU)
34
+ ami 'ami-e40f2790' # Amazon Getting Started AMI (EU)
43
35
  end
44
-
36
+
37
+ hostname :rudy # One of: :default, :rudy, "your-name"
38
+
45
39
  # We've defined an environment called "stage" with one role: "app".
46
40
  # The configuration inside the env block is available to all its
47
41
  # roles. The configuration inside the role blocks is available only
48
42
  # to machines in that specific role.
49
43
  env :stage do
50
- ami "ami-5394733a" # ec2onrails/ec2onrails-v0_9_9_1-i386.manifest.xml
51
- size 'm1.small'
52
-
44
+ ami "ami-e348af8a" # Debian 5.0, 32-bit (Alestic)
45
+ size 'm1.small' # EC2 machine type for all machines
46
+ # in the "stage" environment
53
47
  role :app do
54
- positions 1
55
- #addresses '11.22.33.44', '55.66.77.88'
48
+ positions 1 # Only 1 machine in stage-app
49
+ #addresses '11.22.33.44' # Define an elastic IP to reuse
56
50
 
57
- # You can define disks for the stage-app machines. Rudy uses
58
- # this configuration when it executes a routine (see below).
59
- disks do
60
- path "/rudy/disk1" do
61
- size 2
62
- device "/dev/sdr"
51
+ disks do # Define EBS volumes
52
+ path "/rudy/disk1" do # The paths can be anything but
53
+ size 2 # they must be unique.
54
+ device "/dev/sdr" # Devices must be unique too.
63
55
  end
64
56
  end
65
-
66
- end
67
-
68
- # Here are some examples of other roles. You can use these or
69
- # remove them and create your own.
70
- role :db do
71
57
  end
72
58
 
73
- role :analysis do
59
+ role :db do # You can define as many roles
60
+ end # as you like. These are just
61
+ role :balancer do # a couple examples.
74
62
  end
75
63
 
76
- role :balancer do
64
+ users do # Specify existing private keys per user
65
+ #root do
66
+ # keypair "/path/2/private-key"
67
+ #end
77
68
  end
78
69
 
79
70
  end
@@ -82,43 +73,73 @@ machines do
82
73
  # scripts. The config contained in this block is made available
83
74
  # those scripts in the form of a yaml file. The file is called
84
75
  # rudy-config.yml.
85
- config do
76
+ config do
86
77
  dbmaster 'localhost'
87
78
  newparam 573114
88
79
  end
89
-
90
-
91
80
  end
92
81
 
82
+
83
+ # ----------------------------------------------------------- COMMANDS --------
84
+ # The commands block defines shell commands to be allowed or denied from the
85
+ # default list defined by Rye::Cmd (Rudy executes all SSH commands via Rye).
86
+ # Commands can have any name except for keywords already used by Rudy.
87
+ commands do
88
+ allow :gem_install, "/usr/bin/gem", "install", :V, "--no-rdoc", "--no-ri"
89
+ allow :apt_get, "/usr/bin/apt-get", :y, :q
90
+ deny :kill
91
+ end
92
+
93
+
93
94
  # ----------------------------------------------------------- ROUTINES --------
94
95
  # The routines block describes the repeatable processes for each machine group.
96
+ # To run a routine, specify its name on the command-line: rudy startup
95
97
  routines do
96
98
 
97
- env :stage do
98
- role :app do
99
-
100
- # This routine will be executed when you run "rudy startup"
101
- startup do
102
- disks do
103
- # Rudy creates an EBS volume for each instance, attaches
104
- # it, gives it a filesystem, and mounts it.
105
- create "/rudy/disk1"
106
- end
107
- # You can execute a shell command on each instance after
108
- # it's created. This touch command will run as root.
109
- after :root => [:touch, '/rudy/disk1/rudy-was-here']
110
- end
111
-
112
- # This routine will be executed when you run "rudy shutdown"
113
- shutdown do
114
- before :root => '/a/nonexistent/script'
115
- disks do
116
- # Rudy unounts the EBS volume and deletes it. Careful!
117
- destroy "/rudy/disk1"
118
- end
119
- end
120
-
99
+ env :stage do # We'll define routines for the
100
+ role :app do # stage-app machine group
101
+
102
+ startup do # $ rudy startup
103
+ adduser :rudy # Create a user called "rudy"
104
+ authorize :rudy # Enable passwordless logins as rudy
105
+
106
+ disks do # Define EBS volume routines
107
+ create "/rudy/disk1" # Create an EBS volume, attach it, give
108
+ end # it a filesystem, and mount it.
109
+
110
+ after :rudy do # Run remote SSH commands after startup
111
+ mkdir :p, "great" # $ mkdir -p great
112
+ touch "great/scott" # $ touch great/scott
113
+ ls :l, :a # $ ls -l -a
114
+ end
115
+ end
116
+
117
+ shutdown do # $ rudy shutdown
118
+ before :root do # Run remote SSH commands before shutdown
119
+ mysqld_initd
120
+ end
121
+
122
+ disks do
123
+ destroy "/rudy/disk1" # Unmount and destroy the EBS volume
124
+ end
125
+ end
126
+
127
+ end
128
+ end
129
+
130
+ # Define global routines available
131
+ # to every environment and role.
132
+ sysupdate do # $ rudy sysupdate
133
+ before :root do
134
+ apt_get "update" # Update debian / ubuntu
135
+ apt_get "install", "apache2-prefork-dev", "libapr1-dev"
136
+ apt_get "install", "build-essential", "sqlite3", "libsqlite3-dev"
137
+ gem_install 'rudy'
121
138
  end
122
139
  end
140
+
141
+ # Define your own routines
142
+ anything do # $ rudy anything
143
+ end
123
144
  end
124
145
 
data/bin/rudy CHANGED
@@ -10,7 +10,7 @@
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 drydock rye}.each { |dir| $:.unshift File.join(File.dirname(__FILE__), '..', '..', dir, 'lib') }
13
+ #%w{net-ssh amazon-ec2 caesars drydock rye}.each { |dir| $:.unshift File.join(File.dirname(__FILE__), '..', '..', dir, 'lib') }
14
14
  #require 'rubygems'
15
15
 
16
16
  #$SAFE = 1 # require is unsafe in Ruby 1.9??
@@ -23,74 +23,139 @@ require 'rudy/cli'
23
23
  # Command-line interface for /bin/rudy
24
24
  class RudyCLI < Rudy::CLI::Base
25
25
 
26
+ debug :on
27
+ default :machines
28
+ trawler :passthrough
29
+
26
30
  # ------------------------------------------ RUDY GLOBALS --------
27
31
  # ------------------------------------------------------------------
28
32
 
29
33
  global :e, :environment, String, "Connect to the specified environment (ie: #{Rudy::DEFAULT_ENVIRONMENT})"
30
34
  global :r, :role, String, "Connect to a machine with the specified role (ie: #{Rudy::DEFAULT_ROLE})"
31
35
  global :p, :position, String, "Position in the machine in its group (ie: #{Rudy::DEFAULT_POSITION})"
32
-
33
-
34
36
 
35
- # --------------------------------- RUDY MACHINE COMMANDS --------
36
- # ------------------------------------------------------------------
37
37
 
38
+ # ------------------------------------------ RUDY OBJECTS --------
39
+ # ------------------------------------------------------------------
38
40
 
39
- #desc "Machine Status"
40
- #usage "rudy [global options] status [-g group-name] [-s state] [--all] [instance-ID]"
41
- #option :g, :group, String, "A security group name"
42
- #option :s, :state, String, "Machine state. One of: running (default), pending, terminated"
43
- #option :l, :all, "Show all machines in this group, regardless of state."
44
- #argv :awsid
45
- #command :status => Rudy::CLI::Machines
46
- #
47
- #usage "rudy [global options] connect [-g group-name] [-i instance-ID] [cmd]"
48
- #desc "Open an SSH connection"
49
- #option :print, "Only print the SSH command, don't connect"
50
- #option :g, :group, String, "A security group name"
51
- #option :i, :awsid, String, "An instance ID"
52
- #argv :cmd
53
- #command :connect => Rudy::CLI::Machines
54
- #command_alias :connect, :ssh
55
- #
56
- #usage "rudy [global options] copy [-p] [-r] source target"
57
- #desc "Copy files to or from machines. NOTE: You must use quotes when using a tilda for your remote dir ('~/')."
58
- #option :r, :recursive, "Recursively copy entire directories"
59
- #option :p, :preserve, "Preserve atimes and ctimes."
60
- #option :d, :download, "Download FROM the remote machine to the local machine"
61
- #option :print, "Only print the SSH command, don't connect"
62
- #option :g, :group, String, "A security group name"
63
- #option :i, :awsid, String, "An instance ID"
64
- #command :copy => Rudy::CLI::Machines
65
- #command_alias :copy, :scp
66
- #command_alias :copy, :upload
67
- #command_alias :copy, :download
41
+ #usage "rudy [global options] backups [-C] [disk name]"
42
+ #about "Manage Backups"
43
+ #option :s, :snapshot, String, "Create a backup entry from an existing snapshot"
44
+ #action :Z, :sync, "Check for and delete backup metadata with no snapshot. DOES NOT delete snapshots."
45
+ ##action :T, :tidy, "Tidy existing backups"
46
+ #action :D, :destroy, "Destroy a backup and DELETE its snapshots."
47
+ #action :C, :create, "Create a backup"
48
+ #argv :disk
49
+ #command :'backup' => Rudy::CLI::Backups
50
+ #command_alias :backup, :bu
51
+
52
+ about "Manage Machines"
53
+ option :l, :all, "Display all machines"
54
+ action :W, :wash, "Wash machine metadata."
55
+ command :machines => Rudy::CLI::Machines
56
+ command_alias :machines, :m
57
+
58
+ about "Manage Disks"
59
+ action :W, :wash, "Wash disk metadata."
60
+ command :disks => Rudy::CLI::Disks
61
+ command_alias :disks, :d
62
+
63
+ about "Log in to a machine"
64
+ command :ssh => Rudy::CLI::Machines
65
+
66
+ #about "Open the machine in your default browser (OSX only)"
67
+ #option :s, :https, "Use HTTPS"
68
+ #option :p, :port, Integer, "Port"
69
+ #command :open => Rudy::CLI::Candy
70
+
71
+
72
+ # ----------------------------------------- RUDY ROUTINES --------
73
+ # ------------------------------------------------------------------
74
+
75
+ # A "do nothing" routine. Passthrough simply executes a routine
76
+ # config block. Drydock's trawler uses this for unknown commands.
77
+ about "A skeleton routine"
78
+ command :passthrough => Rudy::CLI::Routines
68
79
 
80
+ about "Startup a machine group"
81
+ usage "rudy startup"
82
+ command :startup => Rudy::CLI::Routines
83
+ command_alias :startup, :s
69
84
 
85
+ about "Shutdown a machine group"
86
+ usage "rudy shutdown"
87
+ command :shutdown => Rudy::CLI::Routines
88
+
89
+ about "Create a release"
90
+ usage "rudy release"
91
+ command :release => Rudy::CLI::Routines
92
+ command_alias :release, :r
93
+ command_alias :release, :rerelease
94
+
95
+ #about "Update the release currently running in a machine group"
96
+ #command :rerelease => Rudy::CLI::Routines
97
+ #command_alias :rerelease, :rere
70
98
 
99
+ #about "Deploy disk snapshots from one machine to another"
100
+ #command :deploy => Rudy::CLI::Routines
101
+
71
102
 
72
- # -------------------------------- MISCELLANEOUS COMMANDS --------
103
+ # ------------------------------------ RUDY MISCELLANEOUS --------
73
104
  # ------------------------------------------------------------------
105
+
106
+ usage "rudy [-f config-file] config [param-name]"
107
+ about "Check Rudy configuration."
108
+ option :l, :all, "Display all configs for all machines"
109
+ option :commands, "Display commands configuration"
110
+ option :defaults, "Display defaults configuration"
111
+ option :machines, "Display machines configuration"
112
+ option :accounts, "Display accounts configuration"
113
+ option :routines, "Display routines configuration"
114
+ option :script, "Output configuration identical to what is provided to scripts called in routines"
115
+ option :project, "Output a skeleton Rudyfile"
116
+ #option :d, :defaults, "Display the default value for the supplied parameter"
117
+ #option :g, :group, String, "Display configuration for a specific group"
118
+ argv :name
119
+ command :config => Rudy::CLI::Config
120
+
121
+
122
+ about "Initialize Rudy configuration"
123
+ command :init do |obj|
74
124
 
75
- desc "Display time (in UTC)"
125
+ unless File.exists?(Rudy::CONFIG_FILE)
126
+ Rudy::Config.init_config_dir
127
+ end
128
+
129
+ begin
130
+
131
+ unless Rudy::Huxtable.domain_exists?
132
+ puts "Creating SimpleDB domain #{Rudy::Huxtable.domain}"
133
+ Rudy::Huxtable.create_domain
134
+ puts "Initialized"
135
+ else
136
+ puts "Already Initialized"
137
+ end
138
+
139
+ rescue Rudy::AWS::SDB::NoSecretKey,
140
+ Rudy::AWS::SDB::NoAccessKey,
141
+ Rudy::NoConfig => ex
142
+ puts "AWS credentials must be configured to continue."
143
+ puts "You can modify these in #{Rudy::CONFIG_FILE}"
144
+ exit 1
145
+ end
146
+
147
+ obj.global.quiet = true # don't print elapsed time
148
+ end
149
+
150
+ about "Display time (in UTC)"
76
151
  option :l, :local, "Display local time"
77
152
  command :time do |obj|
78
153
  t = obj.option.local ? Time.now : Time.now.utc
79
154
  puts '%s' % t.strftime("%Y-%m-%d %T %Z (%z)")
80
155
  end
81
-
82
- usage "rudy [-f config-file] config [param-name]"
83
- desc "Check Rudy configuration."
84
- option :l, :all, "Display configs for all machines"
85
- option :s, :script, "Output configuration identical to what is provided to scripts called in routines"
86
- option :p, :project, "Output a skeleton Rudyfile"
87
- #option :d, :defaults, "Display the default value for the supplied parameter"
88
- #option :g, :group, String, "Display configuration for a specific group"
89
- argv :name
90
- command :config => Rudy::CLI::Config
91
156
 
92
157
  usage "rudy myaddress [-i] [-e]"
93
- desc "Displays you current internal and external IP addresses"
158
+ about "Displays you current internal and external IP addresses"
94
159
  option :e, :external, "Display only external IP address"
95
160
  option :i, :internal, "Display only internal IP address"
96
161
  command :myaddress do |obj|
@@ -107,7 +172,7 @@ class RudyCLI < Rudy::CLI::Base
107
172
  end
108
173
 
109
174
  usage "rudy [global options] annoy [-h -m -l] [-e]"
110
- desc "Play around with Rudy's annoying challenges"
175
+ about "Play around with Rudy's annoying challenges"
111
176
  option :s, :string, "A numeric challenge"
112
177
  option :n, :numeric, "A numeric challenge"
113
178
  option :i, :insane, "Insane annoyance factor"
@@ -124,13 +189,13 @@ class RudyCLI < Rudy::CLI::Base
124
189
  obj.global.quiet = true # don't print elapsed time
125
190
  end
126
191
 
127
- desc "Display the current Rudy slogan"
192
+ about "Display the current Rudy slogan"
128
193
  command :slogan do |obj|
129
194
  puts "Rudy: Not your grandparent's deployment tool!"
130
195
  obj.global.quiet = true # don't print elapsed time
131
196
  end
132
197
 
133
- desc "Generates a configuration template to #{Rudy::CONFIG_FILE}"
198
+ about "Generates a configuration template to #{Rudy::CONFIG_FILE}"
134
199
  command :generate_config do |obj|
135
200
  unless File.exists?(Rudy::CONFIG_FILE)
136
201
  Rudy::Config.init_config_dir
@@ -139,122 +204,6 @@ class RudyCLI < Rudy::CLI::Base
139
204
  puts "#{Rudy::CONFIG_FILE} already exists"
140
205
  end
141
206
  end
142
-
143
-
144
- desc "Initialize Rudy configuration"
145
- command :init do |obj|
146
-
147
- unless File.exists?(Rudy::CONFIG_FILE)
148
- Rudy::Config.init_config_dir
149
- end
150
-
151
- begin
152
-
153
- unless Rudy::Huxtable.domain_exists?
154
- puts "Creating SimpleDB domain #{Rudy::Huxtable.domain}"
155
- Rudy::Huxtable.create_domain
156
- puts "Initialized"
157
- else
158
- puts "Already Initialized"
159
- end
160
-
161
- rescue Rudy::AWS::SDB::NoSecretKey,
162
- Rudy::AWS::SDB::NoAccessKey,
163
- Rudy::NoConfig => ex
164
- puts "AWS credentials must be configured to continue."
165
- puts "You can modify these in #{Rudy::CONFIG_FILE}"
166
- exit 1
167
- end
168
-
169
- obj.global.quiet = true # don't print elapsed time
170
- end
171
-
172
-
173
- # --------------------------------- RUDY MANAGER COMMANDS --------
174
- # ------------------------------------------------------------------
175
-
176
- #usage "rudy [global options] backups [-C] [disk name]"
177
- #desc "Manage Backups"
178
- #option :s, :snapshot, String, "Create a backup entry from an existing snapshot"
179
- #action :Z, :sync, "Check for and delete backup metadata with no snapshot. DOES NOT delete snapshots."
180
- ##action :T, :tidy, "Tidy existing backups"
181
- #action :D, :destroy, "Destroy a backup and DELETE its snapshots."
182
- #action :C, :create, "Create a backup"
183
- #argv :disk
184
- #command :'backup' => Rudy::CLI::Backups
185
- #command_alias :backup, :bu
186
-
187
- desc "Startup a machine group"
188
- usage "rudy startup"
189
- command :startup => Rudy::CLI::Routines
190
- command_alias :startup, :s
191
-
192
- desc "Shutdown a machine group"
193
- usage "rudy shutdown"
194
- command :shutdown => Rudy::CLI::Routines
195
-
196
- desc "Create a release"
197
- usage "rudy release"
198
- command :release => Rudy::CLI::Routines
199
- command_alias :release, :r
200
-
201
- desc "Manage Machines"
202
- action :W, :wash, "Wash machine metadata."
203
- command :machines => Rudy::CLI::Machines
204
- command_alias :machines, :m
205
-
206
- desc "Log in to a machine"
207
- command :ssh => Rudy::CLI::Machines
208
-
209
- desc "Manage Disks"
210
- action :W, :wash, "Wash disk metadata."
211
- command :disks => Rudy::CLI::Disks
212
- command_alias :disks, :d
213
-
214
- # -------------------------- RUDY RELEASE/DEPLOY COMMANDS --------
215
- # ------------------------------------------------------------------
216
-
217
- #desc "Release to a Machine Group"
218
- #option :g, :group, String, "A security group name"
219
- #option :s, :switch, "Switch to the release branch/tag"
220
- #option :m, :msg, String, "A short release note"
221
- #command :release => Rudy::CLI::Release
222
-
223
- #desc "Update the release currently running in a machine group"
224
- #command :rerelease => Rudy::CLI::Release
225
- #command_alias :rerelease, :rere
226
-
227
- #desc "Deploy disk snapshots from one machine to another"
228
- #command :deploy => Rudy::CLI::Deploy
229
-
230
-
231
- #desc "Shutdown a Machine Group"
232
- #usage "rudy [global options] shutdown [-g group-name] [instance-ID]"
233
- #option :g, :group, String, "A security group name"
234
- #argv :awsid
235
- #command :shutdown => Rudy::CLI::Routines
236
- #
237
- #
238
- #desc "Start a Machine Group"
239
- #usage "rudy [global options] startup [-g group-name] [-i image-ID]"
240
- #option :ami, String, "EC2 image ID (AMI)"
241
- #option :g, :group, String, "A security group name"
242
- #command :startup => Rudy::CLI::Routines
243
- #command_alias :startup, :start
244
-
245
- #desc "Restart a Machine Group"
246
- #option :g, :group, String, "A security group name"
247
- #argv :awsid
248
- #command :restart => Rudy::CLI::Routines
249
- #
250
-
251
-
252
- # ------------------------------------------- UGLY STUFFS --------
253
- # ------------------------------------------------------------------
254
- debug :on
255
- default :machines
256
-
257
-
258
207
 
259
208
  end
260
209
 
@@ -264,11 +213,15 @@ end
264
213
  # will run after Rye shuts down the ssh-agent.
265
214
  begin
266
215
  Drydock.run!(ARGV, STDIN) if Drydock.run? && !Drydock.has_run?
267
- rescue Drydock::ArgError, Drydock::OptError=> ex
216
+
217
+ rescue Drydock::ArgError, Drydock::OptError => ex
268
218
  STDERR.puts ex.message
269
219
  STDERR.puts ex.usage
220
+ rescue Drydock::InvalidArgument => ex
221
+ STDERR.puts ex.message
270
222
  rescue Rudy::Error => ex
271
223
  STDERR.puts ex.message
224
+ STDERR.puts ex.backtrace if Drydock.debug?
272
225
  rescue => ex
273
226
  STDERR.puts "ERROR (#{ex.class.to_s}): #{ex.message}"
274
227
  STDERR.puts ex.backtrace if Drydock.debug?