solutious-rudy 0.8.5 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/CHANGES.txt +55 -14
  2. data/README.rdoc +26 -34
  3. data/Rudyfile +27 -32
  4. data/bin/rudy +47 -27
  5. data/bin/rudy-ec2 +2 -16
  6. data/bin/rudy-s3 +0 -10
  7. data/bin/rudy-sdb +11 -12
  8. data/lib/rudy.rb +49 -89
  9. data/lib/rudy/aws.rb +2 -43
  10. data/lib/rudy/aws/ec2.rb +57 -20
  11. data/lib/rudy/aws/ec2/address.rb +10 -11
  12. data/lib/rudy/aws/ec2/group.rb +10 -9
  13. data/lib/rudy/aws/ec2/image.rb +8 -8
  14. data/lib/rudy/aws/ec2/instance.rb +15 -16
  15. data/lib/rudy/aws/ec2/keypair.rb +14 -19
  16. data/lib/rudy/aws/ec2/snapshot.rb +16 -9
  17. data/lib/rudy/aws/ec2/volume.rb +37 -24
  18. data/lib/rudy/aws/ec2/zone.rb +5 -4
  19. data/lib/rudy/aws/s3.rb +2 -1
  20. data/lib/rudy/aws/sdb.rb +35 -86
  21. data/lib/rudy/backups.rb +24 -0
  22. data/lib/rudy/cli.rb +5 -131
  23. data/lib/rudy/cli/aws/ec2/addresses.rb +19 -27
  24. data/lib/rudy/cli/aws/ec2/candy.rb +32 -7
  25. data/lib/rudy/cli/aws/ec2/groups.rb +9 -13
  26. data/lib/rudy/cli/aws/ec2/images.rb +5 -133
  27. data/lib/rudy/cli/aws/ec2/instances.rb +25 -25
  28. data/lib/rudy/cli/aws/ec2/keypairs.rb +7 -11
  29. data/lib/rudy/cli/aws/ec2/snapshots.rb +5 -9
  30. data/lib/rudy/cli/aws/ec2/volumes.rb +22 -23
  31. data/lib/rudy/cli/aws/ec2/zones.rb +2 -3
  32. data/lib/rudy/cli/aws/sdb/domains.rb +5 -6
  33. data/lib/rudy/cli/aws/sdb/objects.rb +33 -0
  34. data/lib/rudy/cli/aws/sdb/select.rb +23 -0
  35. data/lib/rudy/cli/backups.rb +38 -0
  36. data/lib/rudy/cli/base.rb +98 -0
  37. data/lib/rudy/cli/candy.rb +1 -2
  38. data/lib/rudy/cli/config.rb +7 -4
  39. data/lib/rudy/cli/disks.rb +6 -8
  40. data/lib/rudy/cli/execbase.rb +53 -0
  41. data/lib/rudy/cli/machines.rb +14 -18
  42. data/lib/rudy/cli/metadata.rb +24 -10
  43. data/lib/rudy/cli/routines.rb +31 -5
  44. data/lib/rudy/config.rb +17 -22
  45. data/lib/rudy/config/objects.rb +44 -30
  46. data/lib/rudy/disks.rb +25 -0
  47. data/lib/rudy/exceptions.rb +95 -0
  48. data/lib/rudy/global.rb +46 -23
  49. data/lib/rudy/guidelines.rb +3 -2
  50. data/lib/rudy/huxtable.rb +66 -57
  51. data/lib/rudy/machines.rb +41 -263
  52. data/lib/rudy/metadata.rb +212 -38
  53. data/lib/rudy/metadata/backup.rb +123 -78
  54. data/lib/rudy/metadata/disk.rb +152 -170
  55. data/lib/rudy/metadata/machine.rb +179 -0
  56. data/lib/rudy/mixins.rb +2 -1
  57. data/lib/rudy/mixins/hash.rb +3 -1
  58. data/lib/rudy/mixins/symbol.rb +8 -0
  59. data/lib/rudy/routines.rb +127 -344
  60. data/lib/rudy/routines/base.rb +226 -0
  61. data/lib/rudy/routines/handlers/base.rb +48 -0
  62. data/lib/rudy/routines/handlers/depends.rb +49 -0
  63. data/lib/rudy/routines/handlers/disks.rb +239 -0
  64. data/lib/rudy/routines/handlers/group.rb +42 -0
  65. data/lib/rudy/routines/handlers/host.rb +72 -0
  66. data/lib/rudy/routines/handlers/keypair.rb +70 -0
  67. data/lib/rudy/routines/handlers/machines.rb +15 -0
  68. data/lib/rudy/routines/handlers/script.rb +85 -0
  69. data/lib/rudy/routines/handlers/user.rb +41 -0
  70. data/lib/rudy/routines/passthrough.rb +19 -23
  71. data/lib/rudy/routines/reboot.rb +82 -51
  72. data/lib/rudy/routines/shutdown.rb +61 -14
  73. data/lib/rudy/routines/startup.rb +111 -17
  74. data/lib/rudy/utils.rb +12 -59
  75. data/rudy.gemspec +85 -25
  76. data/tryouts/01_mixins/01_hash_tryouts.rb +20 -0
  77. data/tryouts/10_require_time/10_rudy_tryouts.rb +33 -0
  78. data/tryouts/10_require_time/15_global_tryouts.rb +58 -0
  79. data/tryouts/12_config/10_load_config_tryouts.rb +43 -0
  80. data/tryouts/12_config/20_defaults_tryouts.rb +16 -0
  81. data/tryouts/12_config/30_accounts_tryouts.rb +17 -0
  82. data/tryouts/12_config/40_machines_tryouts.rb +53 -0
  83. data/tryouts/12_config/50_commands_tryouts.rb +17 -0
  84. data/tryouts/12_config/60_routines_tryouts.rb +16 -0
  85. data/tryouts/15_huxtable/10_huxtable_tryouts.rb +47 -0
  86. data/tryouts/15_huxtable/20_user_tryouts.rb +47 -0
  87. data/tryouts/20_simpledb/10_domains_tryouts.rb +36 -0
  88. data/tryouts/20_simpledb/20_objects_tryouts.rb +56 -0
  89. data/tryouts/25_ec2/10_keypairs_tryouts.rb +54 -0
  90. data/tryouts/25_ec2/20_groups_tryouts.rb +56 -0
  91. data/tryouts/25_ec2/21_groups_authorize_address_tryouts.rb +53 -0
  92. data/tryouts/25_ec2/22_groups_authorize_account_tryouts.rb +54 -0
  93. data/tryouts/25_ec2/30_addresses_tryouts.rb +42 -0
  94. data/tryouts/25_ec2/40_volumes_tryouts.rb +53 -0
  95. data/tryouts/25_ec2/50_snapshots_tryouts.rb +75 -0
  96. data/tryouts/26_ec2_instances/10_instance_tryouts.rb +107 -0
  97. data/tryouts/26_ec2_instances/50_images_tryouts.rb +7 -0
  98. data/tryouts/30_metadata/10_include_tryouts.rb +45 -0
  99. data/tryouts/30_metadata/13_object_tryouts.rb +19 -0
  100. data/tryouts/30_metadata/50_disk_tryouts.rb +115 -0
  101. data/tryouts/30_metadata/51_disk_digest_tryouts.rb +24 -0
  102. data/tryouts/30_metadata/53_disk_list_tryouts.rb +35 -0
  103. data/tryouts/30_metadata/56_disk_volume_tryouts.rb +68 -0
  104. data/tryouts/30_metadata/60_backup_tryouts.rb +101 -0
  105. data/tryouts/30_metadata/63_backup_list_tryouts.rb +38 -0
  106. data/tryouts/30_metadata/64_backup_disk_tryouts.rb +65 -0
  107. data/tryouts/30_metadata/66_backup_snapshot_tryouts.rb +76 -0
  108. data/tryouts/30_metadata/70_machine_tryouts.rb +85 -0
  109. data/tryouts/30_metadata/73_machine_list_tryouts.rb +58 -0
  110. data/tryouts/30_metadata/76_machine_instance_tryouts.rb +64 -0
  111. data/tryouts/30_metadata/77_machines_tryouts.rb +45 -0
  112. data/tryouts/40_routines/10_keypair_handler_tryouts.rb +52 -0
  113. data/tryouts/40_routines/11_group_handler_tryouts.rb +36 -0
  114. data/tryouts/80_cli/10_rudyec2_tryouts.rb +8 -0
  115. data/tryouts/80_cli/60_rudy_tryouts.rb +41 -0
  116. data/tryouts/failer +6 -0
  117. data/tryouts/misc/console_tryout.rb +91 -0
  118. data/tryouts/misc/disks_tryout.rb +48 -0
  119. data/tryouts/misc/drydock_tryout.rb +48 -0
  120. data/tryouts/misc/nested_methods.rb +103 -0
  121. data/tryouts/misc/session_tryout.rb +46 -0
  122. data/tryouts/misc/tryouts.rb +33 -0
  123. data/tryouts/misc/usage_tryout.rb +23 -0
  124. metadata +119 -31
  125. data/bin/ird +0 -153
  126. data/lib/rudy/metadata/backups.rb +0 -67
  127. data/lib/rudy/metadata/debug.rb +0 -38
  128. data/lib/rudy/metadata/disks.rb +0 -67
  129. data/lib/rudy/metadata/objectbase.rb +0 -108
  130. data/lib/rudy/routines/helper.rb +0 -76
  131. data/lib/rudy/routines/helpers/dependshelper.rb +0 -34
  132. data/lib/rudy/routines/helpers/diskhelper.rb +0 -403
  133. data/lib/rudy/routines/helpers/scripthelper.rb +0 -197
  134. data/lib/rudy/routines/helpers/userhelper.rb +0 -37
  135. data/support/rudy-ec2-startup +0 -200
@@ -1,18 +1,45 @@
1
1
  RUDY, CHANGES
2
2
 
3
- #### 0.9.0 (TBD) ###############################
4
3
 
5
- NOTE: The following changes are planned for the 0.9.0 release.
6
-
7
- * group identifier will be changed to 'grp' from 'g'
8
- * machine identifier will be changes to 'mach' from 'm'
9
- * private keys are stored in ~/.ssh/
10
- * zone is now a single letter: a, b, c, etc... The long form (us-east-1b) will set the region too.
11
- * Disk syntax in the routines DSL will change. The DSL no longer accepts arguments, just the action (create, destroy, ...).
12
- * Disk backups will be removed (temporarily -- probably until on of the early 1.x releases).
13
-
14
-
15
- #### 0.8.5 (2009-06-??) ###############################
4
+ #### 0.9.0-RC1 (2009-08-01) ###########################
5
+
6
+ NOTE: This is a significant re-write from 0.8 (routines, metadata)
7
+
8
+ * FIXED: Routine blocks now process directives in the order their given (in Ruby 1.8 and 1.9).
9
+ * FIXED: Region is now based on the zone. Corrects ambiguity when specifying zone and region.
10
+ * FIXED: Reboot routines are now fully supported
11
+ * FIXED: Unless position (-p) is specified, it's assumed that a command applies to the entire machine group.
12
+ * CHANGE: Rudy::Machine#inspect now prints in a standard Ruby inspect format
13
+ * CHANGE: Routines have been completely rebuilt
14
+ * CHANGE: Now requires Rye 0.8
15
+ * CHANGE: before / after routine actions are now used for dependencies only.
16
+ * CHANGE: Removed script_local, after_local, before_local from passthrough routines
17
+ * CHANGE: Support before_local for startup routines
18
+ * CHANGE: Support before_local and before_remote for reboot routines
19
+ * CHANGE: Support after_local for shutdown routines
20
+ * CHANGE: Removed machines config (now recommend uploading local files)
21
+ * CHANGE: Group names now take the form: grp-us-east-1b-stage-app
22
+ * CHANGE: private keys are now stored in ~/.ssh/
23
+ * CHANGE: Removed create_image and prepare_image actions from rudy-ec2
24
+ * CHANGE: local routine blocks now share a single Rye::Box instance
25
+ * CHANGE: remote routine blocks now share a single Rye::Set instance
26
+ * CHANGE: "privatekey" in accounts config is renamed to "pkey"
27
+ * CHANGE: Reduced Rudy::AWS#execute_request timeout to 15 seconds.
28
+ * CHANGE: Rudy:Disks, Rudy::Machines, and Rudy::Backups now use class methods
29
+ * CHANGE: Rudy::AWS::EC2 now uses class methods
30
+ * CHANGE: Renamed disk action 'snapshot' to 'archive'
31
+ * ADDED: routines command for displaying available routines
32
+ * ADDED: "rudy init" now authorizes public keys for user@localhost
33
+ * ADDED: Parallel processing for remote machines
34
+ * ADDED: Routines now have access to $global and $option (which are frozen)
35
+ * ADDED: xremote and xlocal routine actions for quick skipping
36
+ * ADDED: Dependency Attic 0.4
37
+ * ADDED: New 'objects' and 'query' commands for rudy-sdb
38
+ * ADDED: Execute routines on individual machines in a group
39
+ * ADDED: rudy backups command
40
+
41
+
42
+ #### 0.8.5 (2009-06-08) ###############################
16
43
 
17
44
  * FIXED: Bug in DiskHelper. mount method tried to attach when already attached.
18
45
  * CHANGE: rudy config now displays account info (but keeps secret key hidden)
@@ -78,7 +105,7 @@ NOTE: The following changes are planned for the 0.9.0 release.
78
105
  * CHANGE: Moved non-rudy specific modules to separate projects (storable, sysinfo, annoy,
79
106
  console -> Drydock, escape -> Rye, tryouts -> tryouts/).
80
107
  * CHANGE: Renamed restart routine to reboot to make it clear it's about the machine
81
- * CHANGE: Renamed Rudy::Disk to Rudy::MetaData::Disk
108
+ * CHANGE: Renamed Rudy::Disk to Rudy::Metadata::Disk
82
109
  * CHANGE: Short alias for rudy-ec2 snapshot is now 's' (instead of 't')
83
110
  * CHANGE: Removed highline-1.5.1 from vendor (it's now available as a gem)
84
111
  * FIXED: Bug in Huxtable when loading global. Wasn't reloaded after config was updated.
@@ -240,7 +267,21 @@ NOTE: This is a complete re-write from 0.1
240
267
  * ADDED: "rudy groups" overhaul. Display, creates, destroys groups.
241
268
 
242
269
 
243
-
244
270
  #### 0.1 (2009-02-06) ###############################
245
271
 
246
272
  * Initial public release
273
+
274
+
275
+ * TODO: Supply dns values in machines config
276
+ * TODO: Rudy::Routines::Arcade.
277
+ * install/uninstall: uses package management for the specific os impl
278
+ * compile: from source.
279
+ * e.g. rudy -a experimental install git (for ruby-unix-osx)
280
+ * How to handle multiple package managers?
281
+ * How to handle multiple app versions?
282
+ * TODO: http://opensoul.org/2009/6/24/capistrano-git-and-ssh-keys
283
+ * TODO: look for config file in ./.rudy, then ../.rudy, etc... (git-like)
284
+ * TODO: FIX: When shutting down, warns about disks even when they don't exist (CLI::Routines)
285
+ * TODO: Investigate SSH daemon on Windows
286
+ * TODO: Allow colons in place of dashes (rudy publish:gem)
287
+ * TODO: Supply machines config to routines blocks with only the specific machine group context
@@ -1,27 +1,19 @@
1
- = Rudy - v0.8 BETA
1
+ = Rudy - v0.9-RC1
2
2
 
3
3
  <b>Not your grandparents' EC2 deployment tool.</b>
4
4
 
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_.
5
+ Rudy is a development and deployment tool for Amazon Web Services. It helps you build and infrastructures in EC2 by organizing them into groups of _zones_, _environments_, and _roles_. You can run multiple machines with the same role. When you put all this together, you have a unique name for every machine. The default machine is called <tt>m-us-east-1b-stage-app-01</tt> but you can also give them custom names.
6
6
 
7
- When you put all this together, you have a unique name for every machine. The default machine is:
7
+ 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.
8
8
 
9
- zone env role
10
- v v v
11
- m-us-east-1b-stage-app-01
12
- ^ ^
13
- "machine" position
14
-
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
-
17
- <b>See Getting-Started[http://solutious.com/products/rudy/getting-started.html] for more info.</b>
9
+ <b>See Getting-Started[http://solutious.com/projects/rudy/getting-started/] for more info.</b>
18
10
 
19
11
 
20
12
  == Project Status
21
13
 
22
14
  <em>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>
23
15
 
24
- I'm currently rebuilding[http://github.com/solutious/rudy/tree/metadata-refactor] the metadata implementation. This is the part of Rudy that stores your machine, disk, and backup infoz in SimpleDB so it's pretty important! The implementation in the 0.8.4 release (and this master branch) are functional but frail so I want to re-emphasize not to use Rudy for production right now.
16
+ The 0.9 release is a major re-write and has many changes from previous releases. 0.9-RC1 is the first public release from the 0.9 branch and much of the code has not been tested. DO NOT USE IN PRODUCTION. Try it out have some fun and if you have the time send a patch or pull request!
25
17
 
26
18
 
27
19
  == Configuration
@@ -30,13 +22,13 @@ I'm currently rebuilding[http://github.com/solutious/rudy/tree/metadata-refactor
30
22
 
31
23
  The machines configuration describes the "physical" characteristics of your infrastructure.
32
24
 
33
- env :stage do # Define an environment
25
+ env :stage do # Define an environment
34
26
  ami 'ami-e348af8a'
35
27
 
36
- role :app do # Define a role
37
- addresses '11.22.33.44' # Use elastic IPs
28
+ role :app do # Define a role
29
+ addresses '11.22.33.44' # Use elastic IPs
38
30
 
39
- disks do # Create EBS volumes
31
+ disks do # Define EBS volumes
40
32
  path "/rudy/disk1" do
41
33
  size 100
42
34
  device "/dev/sdr"
@@ -49,18 +41,18 @@ The machines configuration describes the "physical" characteristics of your infr
49
41
 
50
42
  The routines configuration describes repeatable processes that you can execute on your machines.
51
43
 
52
- startup do # $ rudy startup
44
+ startup do # $ rudy startup
53
45
  adduser :rudy
54
- authorize :rudy # Enable passwordless login
46
+ authorize :rudy # Enable passwordless login
55
47
 
56
- disks do # Create a disk
57
- restore "/rudy/disk1" # from a backup
48
+ disks do
49
+ create "/rudy/disk1" # Create a disk
58
50
  end
59
51
 
60
- after :rudy do # Run remote SSH commands
61
- mkdir :p, "great" # $ mkdir -p great
62
- touch "great/scott" # $ touch great/scott
63
- ls :l, :a # $ ls -l -a
52
+ remote :rudy do # Run remote commands via SSH
53
+ mkdir :p, "great" # $ mkdir -p great
54
+ touch "great/scott" # $ touch great/scott
55
+ mysql_init :start
64
56
  end
65
57
  end
66
58
 
@@ -68,15 +60,15 @@ The routines configuration describes repeatable processes that you can execute o
68
60
 
69
61
  == Features
70
62
 
71
- * Create complex environments with a single command
63
+ * Create complex IT infrastructures from a simple configuration
72
64
  * Launch multiple instances
73
65
  * Assign elastic IP addresses
74
66
  * Create EBS volumes, attach to instances, format, and mount
75
- * Run scripts locally and remotely automatically
67
+ * Run SSH commands on machine groups in parallel
76
68
  * Organize instances into environments and roles
77
69
  * Powerful command-line tools
78
70
  * <tt>$ rudy -u root ssh</tt>
79
- * <tt>$ rudy -e testing -r database startup</tt>
71
+ * <tt>$ rudy -e testing -r database backup-mysql</tt>
80
72
  * Use _any Linux_ Amazon machine image (AMI) (partial Solaris support)
81
73
  * Complete command-line interface for EC2. See <tt>bin/rudy-ec2</tt>.
82
74
 
@@ -93,7 +85,7 @@ or via download:
93
85
 
94
86
  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>
95
87
 
96
- <b>See Getting-Started[http://solutious.com/products/rudy/getting-started.html] for more info.</b>
88
+ <b>See Getting-Started[http://solutious.com/projects/rudy/getting-started/] for more info.</b>
97
89
 
98
90
 
99
91
  == Pre-Requisites
@@ -102,8 +94,9 @@ NOTE: <em>If you are not installing via RubyGems, you need to make sure the depe
102
94
  * EC2[http://aws.amazon.com/ec2/]
103
95
  * SimpleDB[http://aws.amazon.com/simpledb/]
104
96
  * S3[http://aws.amazon.com/s3/]
97
+ * OpenSSL[http://www.openssl.org/]
105
98
  * OpenSSH[http://www.openssh.com/]
106
- * Ruby[http://ruby-lang.org] 1.8.x, 1.9.x, or JRuby[http://jruby.codehaus.org] 1.2
99
+ * Ruby[http://ruby-lang.org] 1.8.x, 1.9.x, or JRuby[http://jruby.codehaus.org] 1.3
107
100
  * Net::SSH[http://net-ssh.rubyforge.org/]
108
101
  * Net::SCP[http://net-ssh.rubyforge.org/]
109
102
  * amazon-ec2[http://github.com/grempe/amazon-ec2]
@@ -111,6 +104,7 @@ NOTE: <em>If you are not installing via RubyGems, you need to make sure the depe
111
104
  * Rye[http://github.com/delano/rye]
112
105
  * Drydock[http://github.com/delano/drydock]
113
106
  * Caesars[http://github.com/delano/caesars]
107
+ * Gibbler[http://github.com/delano/gibbler]
114
108
 
115
109
 
116
110
  == More Info
@@ -120,7 +114,7 @@ NOTE: <em>If you are not installing via RubyGems, you need to make sure the depe
120
114
  * Submit issues to the IssueTracker[http://github.com/solutious/rudy/issues]
121
115
  * Start a discussion on the GoogleGroup[http://groups.google.com/group/rudy-deployment]
122
116
  * Find some Inspiration[http://www.youtube.com/watch?v=CgaiIW5Rzes]
123
- * For all other inquires, email me directly: delano@solutious.com
117
+ * For all other inquires, email me directly: delano (@solutious.com)
124
118
 
125
119
 
126
120
  == Thanks
@@ -142,10 +136,8 @@ NOTE: <em>If you are not installing via RubyGems, you need to make sure the depe
142
136
 
143
137
  == Contributions
144
138
 
145
- I'm very open to contributions!
146
-
147
139
  * For bigger features please fork the git repo and send me a pull request.
148
- * For small or single file changes, send me an email with the details: <tt>delano@solutious.com</tt>
140
+ * For small or single file changes, send me an email with the details: Delano (@solutious.com)
149
141
 
150
142
 
151
143
  == Credits
data/Rudyfile CHANGED
@@ -25,25 +25,26 @@
25
25
  #
26
26
 
27
27
  # --------------------------------------------------------- MACHINES --------
28
- # The machines block describes the "physical" characteristics of your machines.
28
+ # The machines block describes the 'physical' characteristics of your machines.
29
29
  machines do
30
30
 
31
- zone :"us-east-1b" do
31
+ region :'us-east-1' do
32
32
  ami 'ami-e348af8a' # Alestic Debian 5.0, 32-bit (US)
33
33
  end
34
- zone :"eu-west-1b" do
34
+ region :'eu-west-1' do
35
35
  ami 'ami-6ecde51a' # Alestic Debian 5.0, 32-bit (EU)
36
36
  end
37
37
 
38
- hostname :rudy # One of: :default, :rudy, "your-name"
38
+ hostname :rudy # One of: :default, :rudy, 'your-name'
39
39
 
40
- # We've defined an environment called "stage" with one role: "app".
40
+ # We've defined an environment called 'stage' with one role: 'app'.
41
41
  # The configuration inside the env block is available to all its
42
42
  # roles. The configuration inside the role blocks is available only
43
43
  # to machines in that specific role.
44
44
  env :stage, :prod do
45
+ user :root # User to connect as
45
46
  size 'm1.small' # EC2 machine type for all machines
46
- # in the "stage" environment
47
+ # in the 'stage' environment
47
48
  role :app do
48
49
  positions 1 # Only 1 machine in stage-app
49
50
  #addresses '11.22.33.44' # Define an elastic IP to reuse
@@ -63,20 +64,12 @@ machines do
63
64
 
64
65
  users do # Specify existing private keys per user
65
66
  rudy do
66
- keypair "/path/2/private-key"
67
+ keypair '/path/2/private-key'
67
68
  end
68
69
  end
69
70
 
70
71
  end
71
72
 
72
- # The routines section below contains calls to local and remote
73
- # scripts. The config contained in this block is made available
74
- # those scripts in the form of a yaml file. The file is called
75
- # rudy-config.yml.
76
- config do
77
- dbmaster 'localhost'
78
- newparam 573114
79
- end
80
73
  end
81
74
 
82
75
 
@@ -94,7 +87,8 @@ end
94
87
  commands do
95
88
  allow :gem_install, '/usr/bin/gem', 'install', :V, '--no-rdoc', '--no-ri'
96
89
  allow :apt_get, 'apt-get', :y, :q
97
- allow :floo, :time, 1 do
90
+ allow :rubycode do
91
+ puts "Some ruby code running in #{self}"
98
92
  end
99
93
  end
100
94
 
@@ -104,17 +98,18 @@ end
104
98
  routines do
105
99
 
106
100
  env :stage, :prod do # We'll define routines for the stage-app
107
- role :app do # and prod-app machine groups
101
+ role :app do # and prod-app machine groups.
102
+
103
+ user :root # The default remote user
108
104
 
109
105
  startup do # $ rudy startup
110
106
  adduser :rudy # Create a user called 'rudy'
111
- authorize :rudy # Enable passwordless logins as rudy
112
107
  #
113
108
  disks do # Define EBS volume routines
114
109
  create '/rudy/disk1' # Create an EBS volume, attach it, give
115
110
  end # it a filesystem, and mount it.
116
111
  #
117
- after :rudy do # Run remote SSH commands after startup
112
+ remote :rudy do # Run remote SSH commands after startup
118
113
  mkdir :p, 'great' # $ mkdir -p great
119
114
  touch 'great/scott' # $ touch great/scott
120
115
  ls :l, :a # $ ls -l -a *
@@ -122,7 +117,7 @@ routines do
122
117
  end
123
118
 
124
119
  shutdown do # $ rudy shutdown
125
- before :root do # Run remote SSH commands before shutdown
120
+ remote :root do # Run remote SSH commands before shutdown
126
121
  uptime
127
122
  end
128
123
  disks do
@@ -131,10 +126,10 @@ routines do
131
126
  end
132
127
 
133
128
  reboot do # $ rudy reboot
134
- before :root do # Run any pre-reboot tasks like stopping
129
+ before_remote do # Run any pre-reboot tasks like stopping
135
130
  uptime # web servers and databases.
136
131
  end #
137
- after :root do # Run any startup tasks like starting
132
+ remote do # Run any startup tasks like starting
138
133
  uptime # processes or initializing the filesystem
139
134
  end
140
135
  end
@@ -160,7 +155,7 @@ routines do
160
155
  # install essential libraries.
161
156
  # See http://github.com/rudy/arcade
162
157
  sysupdate do # $ rudy sysupdate
163
- before :root do
158
+ remote :root do
164
159
  apt_get 'update' # Update debian / ubuntu
165
160
  apt_get 'install', 'build-essential', 'sqlite3', 'libsqlite3-dev'
166
161
  apt_get 'install', 'apache2-prefork-dev', 'libapr1-dev'
@@ -170,16 +165,15 @@ routines do
170
165
 
171
166
  anything do # $ rudy anything
172
167
  before :uptime # Specify a dependency
173
- script_local do # This is Ruby, so any valid syntax
168
+ local do # This is Ruby, so any valid syntax
174
169
  ls :l # can be used in the definitions.
175
170
  end # See: SysInfo gem for more info.
176
171
  end
177
172
 
178
173
  uptime do # $ rudy uptime
179
- script_local do
180
- uptime
181
- end
174
+ remote { uptime } # Short block syntax
182
175
  end
176
+
183
177
  end
184
178
 
185
179
 
@@ -188,12 +182,13 @@ end
188
182
  # non-boolean values are expected to be Symbols.
189
183
  #
190
184
  defaults do
191
- region :"us-east-1"
192
- zone :"us-east-1b"
185
+ zone :'us-east-1d'
193
186
  environment :stage
194
187
  role :app
195
- user Rudy.sysinfo.user.to_sym # This will be the user running Rudy
196
- color false # Terminal colors? true/false
197
- yes false # Auto-confirm? true/false
188
+ #user ENV['USER'] # The default remote user
189
+ #localhost 'hostname' # A local hostname instead of localhost
190
+ #color true # Terminal colors? true/false
191
+ #yes false # Auto-confirm? true/false
192
+ #keydir '~/.ssh/' # The path to store SSH keys
198
193
  end
199
194
 
data/bin/rudy CHANGED
@@ -9,7 +9,7 @@
9
9
  #
10
10
 
11
11
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') # Put our local lib in first place
12
- #$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'drydock', 'lib')
12
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'drydock', 'lib')
13
13
 
14
14
  #$SAFE = 1 # require is unsafe in Ruby 1.9??
15
15
 
@@ -20,43 +20,65 @@ require 'rudy/cli'
20
20
  # Command-line interface for /bin/rudy
21
21
  class RudyCLI < Rudy::CLI::Base
22
22
 
23
- debug :off
24
23
  default :machines # when no command is provided
25
24
  trawler :passthrough # unknown command names will forward here.
26
25
 
27
26
  # ------------------------------------------ RUDY GLOBALS --------
28
27
  # ------------------------------------------------------------------
29
28
 
30
- global :e, :environment, String, "Connect to the specified environment (ie: #{Rudy::DEFAULT_ENVIRONMENT})"
31
- global :r, :role, String, "Connect to a machine with the specified role (ie: #{Rudy::DEFAULT_ROLE})"
32
- global :p, :position, String, "Position in the machine in its group (ie: #{Rudy::DEFAULT_POSITION})"
33
-
34
-
29
+ global :e, :environment, String, "Connect to the specified environment (e.g. #{Rudy::DEFAULT_ENVIRONMENT})"
30
+ global :r, :role, String, "Connect to a machine with the specified role (e.g. #{Rudy::DEFAULT_ROLE})"
31
+ global :p, :position, String, "Position in the machine in its group"
32
+ global :b, :bucket, String, "An S3 bucket name (used when creating images)"
33
+ global :t, :testrun, "Test run. Don't execute action (EXPERIMENTAL)."
34
+ global :P, :parallel, "Execute remote commands in parallel (EXPERIMENTAL)."
35
+ global :F, :force, "Force an action despite warnings"
36
+
35
37
  # ------------------------------------------ RUDY OBJECTS --------
36
38
  # ------------------------------------------------------------------
37
39
 
40
+ about "View Routines"
41
+ usage "rudy routines"
42
+ usage "rudy routines -l"
43
+ option :l, :all, "Display routines for all environments and roles"
44
+ command :routines => Rudy::CLI::Routines
45
+ command_alias :routines, :r
46
+
38
47
  about "View Machines"
48
+ usage "rudy"
49
+ usage "rudy machines"
50
+ usage "rudy machines -l"
39
51
  option :l, :all, "Display machines for all environments and roles"
40
52
  action :W, :wash, "Wash machine metadata."
41
53
  command :machines => Rudy::CLI::Machines
42
54
  command_alias :machines, :m
43
55
 
44
56
  about "View Disks"
57
+ usage "rudy disks"
58
+ usage "rudy disks -l"
45
59
  action :W, :wash, "Wash disk metadata."
46
60
  option :b, :backups, "Display backups"
47
61
  option :l, :all, "Display all disks"
48
62
  command :disks => Rudy::CLI::Disks
49
63
  command_alias :disks, :d
50
-
64
+
65
+ about "View Backups"
66
+ usage "rudy backups"
67
+ usage "rudy backups -l"
68
+ action :W, :wash, "Wash backups metadata."
69
+ option :l, :all, "Display all backups"
70
+ command :backups => Rudy::CLI::Backups
71
+ command_alias :backups, :b
72
+
51
73
  about "View raw metadata"
52
74
  usage "rudy metadata"
53
- usage "rudy metadata -l -o [disk|back|m]"
75
+ usage "rudy metadata -l -r [disk|back|m]"
54
76
  usage "rudy metadata -D object-id"
55
- option :o, :otype, String, "Object type. One of: disk, back, m"
77
+ option :r, :rtype, String, "Record type. One of: disk, back, m (default)"
56
78
  option :l, :all, "Display metadata for all environments and roles"
57
79
  action :D, :delete, "Delete an object"
58
80
  argv :oid
59
- command :metadata => Rudy::CLI::MetaData
81
+ command :metadata => Rudy::CLI::Metadata
60
82
 
61
83
  about "Log in to a machine"
62
84
  command :ssh => Rudy::CLI::Machines
@@ -119,20 +141,25 @@ class RudyCLI < Rudy::CLI::Base
119
141
 
120
142
  Rudy::Huxtable.update_config
121
143
 
122
- unless File.exists?(Rudy::CONFIG_FILE)
144
+ unless File.exists? Rudy::CONFIG_FILE
123
145
  Rudy::Config.init_config_dir
124
146
  end
125
147
 
126
148
  begin
127
149
 
128
- unless Rudy::Huxtable.domain_exists?
150
+ if Rudy::Huxtable.domain_exists?
151
+ puts "SimpleDB domain #{Rudy::Huxtable.domain} already exists"
152
+ else
129
153
  puts "Creating SimpleDB domain #{Rudy::Huxtable.domain}"
130
154
  Rudy::Huxtable.create_domain
131
- puts "Initialized"
132
- else
133
- puts "Already Initialized"
134
155
  end
135
-
156
+
157
+ user, host = Rudy.sysinfo.user, Rudy::Huxtable.global.localhost
158
+
159
+ puts "Authorizing public keys for #{user}@#{host}"
160
+ rbox = Rye::Box.new host
161
+ rbox.authorize_keys_local
162
+
136
163
  rescue Rudy::AWS::SDB::NoSecretKey,
137
164
  Rudy::AWS::SDB::NoAccessKey,
138
165
  Rudy::NoConfig => ex
@@ -208,13 +235,8 @@ class RudyCLI < Rudy::CLI::Base
208
235
  end
209
236
  end
210
237
 
211
- # We call Drydock specifically otherwise it will run at_exit. Rye also
212
- # uses at_exit for shutting down the ssh-agent. Ruby executes at_exit
213
- # blocks in reverse order so if Drydock is required first, it's block
214
- # will run after Rye shuts down the ssh-agent.
215
238
  begin
216
239
  Drydock.run!(ARGV, STDIN) if Drydock.run? && !Drydock.has_run?
217
-
218
240
  rescue Drydock::ArgError, Drydock::OptError => ex
219
241
  STDERR.puts ex.message
220
242
  STDERR.puts ex.usage
@@ -223,12 +245,10 @@ rescue Drydock::InvalidArgument => ex
223
245
  rescue Rudy::Error => ex
224
246
  STDERR.puts ex.message
225
247
  STDERR.puts ex.backtrace if Drydock.debug?
226
- rescue => ex
227
- STDERR.puts "ERROR (#{ex.class.to_s}): #{ex.message}"
228
- STDERR.puts ex.backtrace if Drydock.debug?
229
248
  rescue Interrupt
230
249
  puts "#{$/}Exiting... "
231
250
  exit 1
232
- rescue SystemExit
233
- # Don't balk
251
+ rescue => ex
252
+ STDERR.puts "ERROR (#{ex.class.to_s}): #{ex.message}"
253
+ STDERR.puts ex.backtrace if Drydock.debug?
234
254
  end