doo 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/doo/stock/run_on_server.rb +18 -8
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -1,25 +1,35 @@
|
|
1
|
-
SshCommand = "ssh -S '~/.ssh/master-%l-%r@%h:%p'"
|
2
1
|
Doo::Base.class_eval do
|
3
2
|
def run_on_server(servers, variables = {}, &block)
|
4
3
|
servers.each do |host, params|
|
5
4
|
with_clone(variables.merge({:host => host}).merge(params || {})) do
|
6
5
|
def run(cmd, opt = {})
|
7
|
-
|
8
|
-
|
6
|
+
cmdopts = ["-S \"~/.ssh/master-%l-%r@%h:%p\""]
|
7
|
+
cmdopts << "-t" if opt.include? :pty || opt[:pty]
|
8
|
+
command = "ssh #{cmdopts.join(' ')} #{user}@#{host} #{cmd}"
|
9
|
+
puts "Running #{command}" if verbose
|
10
|
+
system(command) || raise("SSH Error") unless dry_run
|
9
11
|
$?
|
10
12
|
end
|
11
|
-
|
13
|
+
|
12
14
|
def put(local, remote)
|
13
15
|
puts "scp -r \"#{local}\" \"#{host}:#{remote}\"" if verbose
|
14
16
|
system("scp -r \"#{local}\" \"#{host}:#{remote}\"") || raise("SSH Error") unless dry_run
|
15
17
|
$?
|
16
18
|
end
|
17
|
-
|
19
|
+
|
18
20
|
begin
|
19
|
-
|
21
|
+
cmdopts = ["-MNf -S \"~/.ssh/master-%l-%r@%h:%p\""]
|
22
|
+
cmdopts << "-oProxyCommand=\"ssh #{gateway} exec nc %h %p\"" if defined? :gateway
|
23
|
+
command = "ssh #{cmdopts.join(' ')} #{user}@#{host}"
|
24
|
+
puts "Running #{command}" if verbose
|
25
|
+
system(command) || raise("SSH Error") unless dry_run
|
26
|
+
|
20
27
|
instance_eval &block if block_given?
|
21
28
|
ensure
|
22
|
-
|
29
|
+
cmdopts = ["-Oexit -S \"~/.ssh/master-%l-%r@%h:%p\""]
|
30
|
+
command = "ssh #{cmdopts.join(' ')} #{user}@#{host}"
|
31
|
+
puts "Running #{command}" if verbose
|
32
|
+
system(command) || raise("SSH Error") unless dry_run
|
23
33
|
end
|
24
34
|
end
|
25
35
|
end
|
@@ -30,7 +40,7 @@ Hash.class_eval do
|
|
30
40
|
def with_role(role)
|
31
41
|
reject { |k,v| ! [v[:role]].flatten.member? role }
|
32
42
|
end
|
33
|
-
|
43
|
+
|
34
44
|
def except_role(role)
|
35
45
|
reject { |k,v| [v[:role]].flatten.member? role }
|
36
46
|
end
|
metadata
CHANGED