solutious-rudy 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES.txt +61 -4
- data/README.rdoc +91 -53
- data/Rakefile +0 -92
- data/Rudyfile +15 -25
- data/bin/rudy +52 -41
- data/examples/gem-test.rb +92 -0
- data/lib/rudy.rb +15 -7
- data/lib/rudy/aws.rb +2 -2
- data/lib/rudy/aws/ec2.rb +2 -2
- data/lib/rudy/aws/ec2/instance.rb +3 -3
- data/lib/rudy/aws/ec2/volume.rb +4 -4
- data/lib/rudy/cli/aws/ec2/candy.rb +13 -13
- data/lib/rudy/cli/base.rb +10 -4
- data/lib/rudy/cli/config.rb +13 -3
- data/lib/rudy/cli/disks.rb +1 -1
- data/lib/rudy/cli/execbase.rb +5 -2
- data/lib/rudy/cli/machines.rb +231 -30
- data/lib/rudy/cli/networks.rb +34 -0
- data/lib/rudy/cli/routines.rb +1 -1
- data/lib/rudy/cli/status.rb +60 -0
- data/lib/rudy/config.rb +42 -14
- data/lib/rudy/exceptions.rb +5 -1
- data/lib/rudy/global.rb +29 -13
- data/lib/rudy/huxtable.rb +2 -2
- data/lib/rudy/machines.rb +2 -2
- data/lib/rudy/metadata/disk.rb +2 -1
- data/lib/rudy/routines.rb +3 -3
- data/lib/rudy/routines/base.rb +7 -4
- data/lib/rudy/routines/handlers/disks.rb +16 -6
- data/lib/rudy/routines/handlers/group.rb +5 -3
- data/lib/rudy/routines/handlers/host.rb +14 -16
- data/lib/rudy/routines/handlers/script.rb +2 -2
- data/lib/rudy/routines/handlers/user.rb +4 -0
- data/lib/rudy/routines/reboot.rb +26 -9
- data/lib/rudy/routines/shutdown.rb +4 -0
- data/lib/rudy/routines/startup.rb +3 -2
- data/lib/rudy/utils.rb +23 -9
- data/rudy.gemspec +10 -29
- data/tryouts/10_require_time/10_rudy_tryouts.rb +1 -1
- data/tryouts/{misc/console_tryout.rb → exploration/console.rb} +0 -0
- data/tryouts/{misc/usage_tryout.rb → exploration/machine.rb} +0 -0
- data/tryouts/failer +1 -1
- metadata +8 -70
- data/tryouts/misc/disks_tryout.rb +0 -48
- data/tryouts/misc/drydock_tryout.rb +0 -48
- data/tryouts/misc/nested_methods.rb +0 -103
- data/tryouts/misc/session_tryout.rb +0 -46
- data/tryouts/misc/tryouts.rb +0 -33
data/bin/rudy
CHANGED
@@ -30,33 +30,35 @@ class RudyCLI < Rudy::CLI::Base
|
|
30
30
|
global :r, :role, String, "Connect to a machine with the specified role (e.g. #{Rudy::DEFAULT_ROLE})"
|
31
31
|
global :p, :position, String, "Position in the machine in its group"
|
32
32
|
global :b, :bucket, String, "An S3 bucket name (used when creating images)"
|
33
|
-
global :t, :testrun, "Test run. Don't execute action (
|
34
|
-
global :P, :parallel, "Execute remote commands in parallel (
|
33
|
+
global :t, :testrun, "Test run. Don't execute action (PARTIALLY SUPPORTED)."
|
34
|
+
global :P, :parallel, "Execute remote commands in parallel (PARTIALLY SUPPORTED)."
|
35
35
|
global :F, :force, "Force an action despite warnings"
|
36
36
|
|
37
|
+
|
37
38
|
# ------------------------------------------ RUDY OBJECTS --------
|
38
39
|
# ------------------------------------------------------------------
|
39
40
|
|
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
|
-
|
47
41
|
about "View Machines"
|
48
42
|
usage "rudy"
|
49
43
|
usage "rudy machines"
|
50
44
|
usage "rudy machines -l"
|
45
|
+
usage "rudy machines -U"
|
46
|
+
usage "rudy machines -A"
|
47
|
+
usage "rudy machines -S [static ip address]"
|
48
|
+
usage "rudy machines -D"
|
51
49
|
option :l, :all, "Display machines for all environments and roles"
|
52
|
-
action :W, :wash, "Wash machine metadata
|
50
|
+
action :W, :wash, "Wash machine metadata"
|
51
|
+
action :T, :available, "Test availablity"
|
52
|
+
action :U, :update, "Update machines based on configuration"
|
53
|
+
action :A, :associate, "Associate static IP addresses or display existing ones"
|
54
|
+
action :N, :disassociate, "Disassociate static IP addresses"
|
53
55
|
command :machines => Rudy::CLI::Machines
|
54
56
|
command_alias :machines, :m
|
55
57
|
|
56
58
|
about "View Disks"
|
57
59
|
usage "rudy disks"
|
58
60
|
usage "rudy disks -l"
|
59
|
-
action :W, :wash, "Wash disk metadata
|
61
|
+
action :W, :wash, "Wash disk metadata"
|
60
62
|
option :b, :backups, "Display backups"
|
61
63
|
option :l, :all, "Display all disks"
|
62
64
|
command :disks => Rudy::CLI::Disks
|
@@ -65,7 +67,7 @@ class RudyCLI < Rudy::CLI::Base
|
|
65
67
|
about "View Backups"
|
66
68
|
usage "rudy backups"
|
67
69
|
usage "rudy backups -l"
|
68
|
-
action :W, :wash, "Wash
|
70
|
+
action :W, :wash, "Wash backup metadata"
|
69
71
|
option :l, :all, "Display all backups"
|
70
72
|
command :backups => Rudy::CLI::Backups
|
71
73
|
command_alias :backups, :b
|
@@ -80,18 +82,30 @@ class RudyCLI < Rudy::CLI::Base
|
|
80
82
|
argv :oid
|
81
83
|
command :metadata => Rudy::CLI::Metadata
|
82
84
|
|
83
|
-
about "
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
about "View Network configuration (local network only)"
|
86
|
+
usage "rudy networks"
|
87
|
+
usage "rudy networks -L"
|
88
|
+
usage "rudy networks -L -i"
|
89
|
+
usage "rudy networks -L -e"
|
90
|
+
usage "rudy networks -U"
|
91
|
+
option :e, :external, "Display only external IP address"
|
92
|
+
option :i, :internal, "Display only internal IP address"
|
93
|
+
action :U, :update, "Update networks based on configuration"
|
94
|
+
action :L, :local, "Show local network configuration"
|
95
|
+
command :networks => Rudy::CLI::Networks
|
96
|
+
command_alias :networks, :n
|
90
97
|
|
91
98
|
|
92
99
|
# ----------------------------------------- RUDY ROUTINES --------
|
93
100
|
# ------------------------------------------------------------------
|
94
101
|
|
102
|
+
about "View Routines"
|
103
|
+
usage "rudy routines"
|
104
|
+
usage "rudy routines -l"
|
105
|
+
option :l, :all, "Display routines for all environments and roles"
|
106
|
+
command :routines => Rudy::CLI::Routines
|
107
|
+
command_alias :routines, :r
|
108
|
+
|
95
109
|
# A "do nothing" routine. Passthrough simply executes a routine
|
96
110
|
# config block. Drydock's trawler uses this for unknown commands.
|
97
111
|
about "A passthrough for custom routines"
|
@@ -117,7 +131,19 @@ class RudyCLI < Rudy::CLI::Base
|
|
117
131
|
|
118
132
|
# ------------------------------------ RUDY MISCELLANEOUS --------
|
119
133
|
# ------------------------------------------------------------------
|
120
|
-
|
134
|
+
|
135
|
+
about "Display existing environment objects"
|
136
|
+
option :l, :all, "Include all regions"
|
137
|
+
command :status => Rudy::CLI::Status
|
138
|
+
|
139
|
+
about "Log in to a machine"
|
140
|
+
command :ssh => Rudy::CLI::Machines
|
141
|
+
|
142
|
+
#about "Open the machine in your default browser (OSX only)"
|
143
|
+
#option :s, :https, "Use HTTPS"
|
144
|
+
#option :p, :port, Integer, "Port"
|
145
|
+
#command :open => Rudy::CLI::Candy
|
146
|
+
|
121
147
|
usage "rudy [-f config-file] config [param-name]"
|
122
148
|
about "Check Rudy configuration."
|
123
149
|
option :l, :all, "Display all configs for all machines"
|
@@ -132,10 +158,12 @@ class RudyCLI < Rudy::CLI::Base
|
|
132
158
|
#option :g, :group, String, "Display configuration for a specific group"
|
133
159
|
argv :name
|
134
160
|
command :config => Rudy::CLI::Config
|
161
|
+
command_alias :config, :configs
|
135
162
|
|
136
163
|
command :print_global => Rudy::CLI::Config
|
164
|
+
command_alias :print_global, :globals
|
137
165
|
command_alias :print_global, :global
|
138
|
-
|
166
|
+
|
139
167
|
about "Initialize Rudy configuration"
|
140
168
|
command :init do |obj|
|
141
169
|
|
@@ -165,7 +193,7 @@ class RudyCLI < Rudy::CLI::Base
|
|
165
193
|
Rudy::NoConfig => ex
|
166
194
|
puts "AWS credentials must be configured to continue."
|
167
195
|
puts "You can modify these in #{Rudy::CONFIG_FILE}"
|
168
|
-
exit
|
196
|
+
exit 0
|
169
197
|
end
|
170
198
|
|
171
199
|
obj.global.quiet = true # don't print elapsed time
|
@@ -177,24 +205,7 @@ class RudyCLI < Rudy::CLI::Base
|
|
177
205
|
t = obj.option.local ? Time.now : Time.now.utc
|
178
206
|
puts '%s' % t.strftime("%Y-%m-%d %T %Z (%z)")
|
179
207
|
end
|
180
|
-
|
181
|
-
usage "rudy myaddress [-i] [-e]"
|
182
|
-
about "Displays you current internal and external IP addresses"
|
183
|
-
option :e, :external, "Display only external IP address"
|
184
|
-
option :i, :internal, "Display only internal IP address"
|
185
|
-
command :myaddress do |obj|
|
186
|
-
ea = Rudy::Utils::external_ip_address || ''
|
187
|
-
ia = Rudy::Utils::internal_ip_address || ''
|
188
|
-
if obj.global.quiet
|
189
|
-
puts ia unless obj.option.external && !obj.option.internal
|
190
|
-
puts ea unless obj.option.internal && !obj.option.external
|
191
|
-
else
|
192
|
-
puts "%10s: %s" % ['Internal', ia] unless obj.option.external && !obj.option.internal
|
193
|
-
puts "%10s: %s" % ['External', ea] unless obj.option.internal && !obj.option.external
|
194
|
-
end
|
195
|
-
obj.global.quiet = true # don't print elapsed time
|
196
|
-
end
|
197
|
-
|
208
|
+
|
198
209
|
usage "rudy [global options] annoy [-h -m -l] [-e]"
|
199
210
|
about "Play around with Rudy's annoying challenges"
|
200
211
|
option :s, :string, "A numeric challenge"
|
@@ -229,7 +240,7 @@ class RudyCLI < Rudy::CLI::Base
|
|
229
240
|
end
|
230
241
|
end
|
231
242
|
|
232
|
-
|
243
|
+
about "Display basic system information"
|
233
244
|
command :sysinfo do
|
234
245
|
puts Rudy.sysinfo.to_yaml
|
235
246
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# Rudy Gem Test
|
2
|
+
#
|
3
|
+
# This configuration is used to
|
4
|
+
# test installing the Rudy gem.
|
5
|
+
|
6
|
+
defaults do
|
7
|
+
color true
|
8
|
+
environment :test
|
9
|
+
role :rudy
|
10
|
+
end
|
11
|
+
|
12
|
+
machines do
|
13
|
+
env :test do
|
14
|
+
role :rudy do
|
15
|
+
ami 'ami-e348af8a' # Alestic Debian 5.0, 32-bit (US)
|
16
|
+
user :root
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
commands do
|
22
|
+
allow :apt_get, "apt-get", :y, :q
|
23
|
+
allow :gem_install, "/usr/bin/gem", "install", :n, '/usr/bin', :y, :V, "--no-rdoc", "--no-ri"
|
24
|
+
allow :gem_sources, "/usr/bin/gem", "sources"
|
25
|
+
allow :gem_uninstall, "/usr/bin/gem", "uninstall", :V, :y
|
26
|
+
allow :update_rubygems
|
27
|
+
allow :rake
|
28
|
+
allow :rm
|
29
|
+
end
|
30
|
+
|
31
|
+
routines do
|
32
|
+
|
33
|
+
|
34
|
+
install_rubyforge do
|
35
|
+
remote :root do
|
36
|
+
gem_install 'rudy', :V
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
install_github do
|
41
|
+
remote :root do
|
42
|
+
gem_sources :a, "http://gems.github.com"
|
43
|
+
gem_install 'solutious-rudy'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
package_gem do
|
48
|
+
local do
|
49
|
+
rm :r, :f, 'pkg'
|
50
|
+
rake 'package'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
install_gem do
|
55
|
+
before :package_gem
|
56
|
+
remote :root do
|
57
|
+
file_upload "pkg/rudy-#{Rudy::VERSION}.gem", "/tmp/"
|
58
|
+
gem_install "/tmp/rudy-#{Rudy::VERSION}.gem"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
remove_rudy do
|
63
|
+
remote :root do
|
64
|
+
gem_uninstall 'rudy'
|
65
|
+
rm :r, :f, '.rudy'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
init_rudy do
|
70
|
+
remote do
|
71
|
+
disable_safe_mode
|
72
|
+
rudy :v, :v, 'init' # create home directory
|
73
|
+
file_upload File.expand_path('~/.rudy/config'), '.rudy/'
|
74
|
+
ls :l, '.rudy/config'
|
75
|
+
rudy :v, :v, 'init'
|
76
|
+
rudy 'status', :l
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
sysupdate do
|
81
|
+
remote :root do
|
82
|
+
apt_get "update"
|
83
|
+
apt_get "install", "build-essential", "git-core"
|
84
|
+
apt_get "install", "ruby1.8-dev", "rdoc", "libzlib-ruby", "rubygems"
|
85
|
+
mkdir :p, "/var/lib/gems/1.8/bin" # Doesn't get created, but causes Rubygems to fail
|
86
|
+
gem_install "builder", "session"
|
87
|
+
gem_install 'rubygems-update', "-v=1.3.4" # circular issue with 1.3.5 and hoe
|
88
|
+
update_rubygems
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
data/lib/rudy.rb
CHANGED
@@ -4,7 +4,7 @@ unless defined?(RUDY_HOME)
|
|
4
4
|
RUDY_LIB = File.join(File.dirname(__FILE__), '..', 'lib')
|
5
5
|
end
|
6
6
|
|
7
|
-
local_libs = %w{net-ssh net-scp
|
7
|
+
local_libs = %w{net-ssh net-scp aws-s3 caesars drydock rye storable sysinfo annoy gibbler}
|
8
8
|
local_libs.each { |dir| $:.unshift File.join(RUDY_HOME, '..', dir, 'lib') }
|
9
9
|
#require 'rubygems'
|
10
10
|
|
@@ -16,6 +16,7 @@ require 'ostruct'
|
|
16
16
|
require 'yaml'
|
17
17
|
require 'logger'
|
18
18
|
require 'socket'
|
19
|
+
require 'resolv'
|
19
20
|
require 'timeout'
|
20
21
|
require 'gibbler'
|
21
22
|
require 'tempfile'
|
@@ -27,7 +28,6 @@ require 'attic'
|
|
27
28
|
require 'annoy'
|
28
29
|
require 'rye'
|
29
30
|
|
30
|
-
|
31
31
|
# = Rudy
|
32
32
|
#
|
33
33
|
#
|
@@ -42,7 +42,7 @@ module Rudy
|
|
42
42
|
unless defined?(MAJOR)
|
43
43
|
MAJOR = 0.freeze
|
44
44
|
MINOR = 9.freeze
|
45
|
-
TINY =
|
45
|
+
TINY = 1.freeze
|
46
46
|
end
|
47
47
|
def self.to_s; [MAJOR, MINOR, TINY].join('.'); end
|
48
48
|
def self.to_f; self.to_s.to_f; end
|
@@ -51,7 +51,7 @@ module Rudy
|
|
51
51
|
unless defined? Rudy::DOMAIN # We can assume all constants are defined
|
52
52
|
|
53
53
|
@@quiet = false
|
54
|
-
@@
|
54
|
+
@@auto = false
|
55
55
|
@@debug = false
|
56
56
|
@@sysinfo = SysInfo.new.freeze
|
57
57
|
|
@@ -100,9 +100,9 @@ module Rudy
|
|
100
100
|
def Rudy.enable_quiet; @@quiet = true; end
|
101
101
|
def Rudy.disable_quiet; @@quiet = false; end
|
102
102
|
|
103
|
-
def Rudy.
|
104
|
-
def Rudy.
|
105
|
-
def Rudy.
|
103
|
+
def Rudy.auto?; @@auto == true; end
|
104
|
+
def Rudy.enable_auto; @@auto = true; end
|
105
|
+
def Rudy.disable_auto; @@auto = false; end
|
106
106
|
|
107
107
|
def Rudy.debug?; @@debug == true; end
|
108
108
|
def Rudy.enable_debug; @@debug = true; end
|
@@ -114,6 +114,14 @@ module Rudy
|
|
114
114
|
|
115
115
|
end
|
116
116
|
|
117
|
+
if Rudy.sysinfo.vm == :java
|
118
|
+
require 'java'
|
119
|
+
module Java
|
120
|
+
include_class java.net.Socket unless defined?(Java::Socket)
|
121
|
+
include_class java.net.InetSocketAddress unless defined?(Java::InetSocketAddress)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
117
125
|
require 'rudy/exceptions'
|
118
126
|
require 'rudy/utils' # The
|
119
127
|
require 'rudy/global' # order
|
data/lib/rudy/aws.rb
CHANGED
@@ -8,10 +8,10 @@ module Rudy
|
|
8
8
|
extend self
|
9
9
|
|
10
10
|
unless defined?(Rudy::AWS::VALID_REGIONS)
|
11
|
-
VALID_REGIONS = ['eu-west-1', 'us-east-1'].freeze
|
11
|
+
VALID_REGIONS = [:'eu-west-1', :'us-east-1'].freeze
|
12
12
|
end
|
13
13
|
|
14
|
-
def valid_region?(r); VALID_REGIONS.member?(r.
|
14
|
+
def valid_region?(r); VALID_REGIONS.member?(r.to_sym || ''); end
|
15
15
|
|
16
16
|
# Modifies +str+ by removing <tt>[\0\n\r\032\\\\]</tt> and escaping <tt>[\'\"]</tt>
|
17
17
|
def escape(str)
|
data/lib/rudy/aws/ec2.rb
CHANGED
@@ -4,7 +4,7 @@ module Rudy; module AWS
|
|
4
4
|
# include Rudy::Huxtable
|
5
5
|
|
6
6
|
def self.connect(access_key=nil, secret_key=nil, region=nil, logger=nil)
|
7
|
-
|
7
|
+
|
8
8
|
if region
|
9
9
|
raise InvalidRegion, region unless Rudy::AWS.valid_region?(region)
|
10
10
|
host = "#{region}.ec2.amazonaws.com"
|
@@ -15,7 +15,7 @@ module Rudy; module AWS
|
|
15
15
|
host ||= DEFAULT_EC2_HOST
|
16
16
|
port ||= DEFAULT_EC2_PORT
|
17
17
|
|
18
|
-
@@ec2
|
18
|
+
@@ec2 = ::EC2::Base.new(:port => port, :server=> host, :access_key_id => access_key, :secret_access_key => secret_key)
|
19
19
|
@@logger = logger
|
20
20
|
end
|
21
21
|
|
@@ -7,7 +7,7 @@ module Rudy::AWS
|
|
7
7
|
field :aki
|
8
8
|
field :ari
|
9
9
|
field :launch_index => Time
|
10
|
-
field :
|
10
|
+
field :created
|
11
11
|
field :keyname
|
12
12
|
field :size
|
13
13
|
field :ami
|
@@ -263,7 +263,7 @@ module Rudy::AWS
|
|
263
263
|
instances = nil if instances.empty? # Don't return an empty hash
|
264
264
|
instances
|
265
265
|
end
|
266
|
-
|
266
|
+
|
267
267
|
# System console output.
|
268
268
|
#
|
269
269
|
# * +inst_id+ instance ID (String) or Instance object.
|
@@ -374,7 +374,7 @@ module Rudy::AWS
|
|
374
374
|
inst = Rudy::AWS::EC2::Instance.new
|
375
375
|
inst.aki = h['kernelId']
|
376
376
|
inst.ami = h['imageId']
|
377
|
-
inst.
|
377
|
+
inst.created = h['launchTime']
|
378
378
|
inst.keyname = h['keyName']
|
379
379
|
inst.launch_index = h['amiLaunchIndex']
|
380
380
|
inst.size = h['instanceType']
|
data/lib/rudy/aws/ec2/volume.rb
CHANGED
@@ -10,8 +10,8 @@ module Rudy::AWS
|
|
10
10
|
field :size => Integer
|
11
11
|
field :snapid
|
12
12
|
field :zone => Symbol
|
13
|
-
field :
|
14
|
-
field :
|
13
|
+
field :created => Time
|
14
|
+
field :attached => Time
|
15
15
|
field :instid
|
16
16
|
field :device
|
17
17
|
|
@@ -212,12 +212,12 @@ module Rudy::AWS
|
|
212
212
|
vol.snapid = h['snapshotId']
|
213
213
|
vol.zone = h['availabilityZone']
|
214
214
|
vol.awsid = h['volumeId']
|
215
|
-
vol.
|
215
|
+
vol.created = h['createTime']
|
216
216
|
if h['attachmentSet'].is_a?(Hash)
|
217
217
|
item = h['attachmentSet']['item'].first
|
218
218
|
vol.status = item['status'] # Overwrite "available status". Possibly a bad idea.
|
219
219
|
vol.device = item['device']
|
220
|
-
vol.
|
220
|
+
vol.attached = item['attachTime']
|
221
221
|
vol.instid = item['instanceId']
|
222
222
|
end
|
223
223
|
vol.postprocess
|
@@ -64,11 +64,11 @@ module AWS; module EC2;
|
|
64
64
|
opts[:id] = @option.instid if @option.instid
|
65
65
|
|
66
66
|
# Options to be sent to Rye::Box
|
67
|
-
|
67
|
+
rye_opts = { :user => @global.user || Rudy.sysinfo.user, :debug => nil }
|
68
68
|
if @@global.pkey
|
69
69
|
raise "Cannot find file #{@@global.pkey}" unless File.exists?(@@global.pkey)
|
70
70
|
raise InsecureKeyPermissions, @@global.pkey unless File.stat(@@global.pkey).mode == 33152
|
71
|
-
|
71
|
+
rye_opts[:keys] = @@global.pkey
|
72
72
|
end
|
73
73
|
|
74
74
|
|
@@ -88,20 +88,20 @@ module AWS; module EC2;
|
|
88
88
|
|
89
89
|
# Print header
|
90
90
|
if @@global.quiet
|
91
|
-
print "You are #{
|
91
|
+
print "You are #{rye_opts[:user].bright}. " if !checked # only the 1st
|
92
92
|
else
|
93
|
-
print "Connecting #{
|
93
|
+
print "Connecting #{rye_opts[:user].bright}@#{inst.dns_public} "
|
94
94
|
puts "(#{inst.awsid}, groups: #{inst.groups.join(', ')})"
|
95
95
|
end
|
96
96
|
|
97
97
|
# Make sure we want to run this command on all instances
|
98
98
|
if !checked && command != :interactive_ssh
|
99
|
-
execute_check(:medium) if
|
99
|
+
execute_check(:medium) if rye_opts[:user] == "root"
|
100
100
|
checked = true
|
101
101
|
end
|
102
102
|
|
103
103
|
# Open the connection and run the command
|
104
|
-
rbox = Rye::Box.new(inst.dns_public,
|
104
|
+
rbox = Rye::Box.new(inst.dns_public, rye_opts)
|
105
105
|
ret = rbox.send(command, command_args)
|
106
106
|
puts ret unless command == :interactive_ssh
|
107
107
|
end
|
@@ -123,11 +123,11 @@ module AWS; module EC2;
|
|
123
123
|
opts[:id] &&= [opts[:id]].flatten
|
124
124
|
|
125
125
|
# Options to be sent to Net::SSH
|
126
|
-
|
126
|
+
rye_opts = { :user => @global.user || Rudy.sysinfo.user, :debug => nil }
|
127
127
|
if @@global.pkey
|
128
128
|
raise "Cannot find file #{@@global.pkey}" unless File.exists?(@@global.pkey)
|
129
129
|
raise InsecureKeyPermissions, @@global.pkey unless File.stat(@@global.pkey).mode == 33152
|
130
|
-
|
130
|
+
rye_opts[:keys] = @@global.pkey
|
131
131
|
end
|
132
132
|
|
133
133
|
opts[:paths] = @argv
|
@@ -141,11 +141,11 @@ module AWS; module EC2;
|
|
141
141
|
|
142
142
|
# Options to be sent to Rye::Box
|
143
143
|
info = @@global.quiet ? nil : STDERR
|
144
|
-
|
144
|
+
rye_opts = { :user => @global.user || Rudy.sysinfo.user, :info => info }
|
145
145
|
if @@global.pkey
|
146
146
|
raise "Cannot find file #{@@global.pkey}" unless File.exists?(@@global.pkey)
|
147
147
|
raise InsecureKeyPermissions, @@global.pkey unless File.stat(@@global.pkey).mode == 33152
|
148
|
-
|
148
|
+
rye_opts[:keys] = @@global.pkey
|
149
149
|
end
|
150
150
|
|
151
151
|
|
@@ -159,9 +159,9 @@ module AWS; module EC2;
|
|
159
159
|
|
160
160
|
# Print header
|
161
161
|
if @@global.quiet
|
162
|
-
print "You are #{
|
162
|
+
print "You are #{rye_opts[:user].bright}. " if !checked # only the 1st
|
163
163
|
else
|
164
|
-
print "Connecting #{
|
164
|
+
print "Connecting #{rye_opts[:user].bright}@#{inst.dns_public} "
|
165
165
|
puts "(#{inst.awsid}, groups: #{inst.groups.join(', ')})"
|
166
166
|
end
|
167
167
|
|
@@ -172,7 +172,7 @@ module AWS; module EC2;
|
|
172
172
|
end
|
173
173
|
|
174
174
|
# Open the connection and run the command
|
175
|
-
rbox = Rye::Box.new(inst.dns_public,
|
175
|
+
rbox = Rye::Box.new(inst.dns_public, rye_opts)
|
176
176
|
rbox.send(opts[:task], opts[:paths], opts[:dest])
|
177
177
|
end
|
178
178
|
|