doo 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/doo/stock/run_on_server.rb +18 -8
  3. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
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
- puts "Running ssh #{(!opt.include? :pty || opt[:pty])? '-t' : ''} #{host} \"#{cmd}\"" if verbose
8
- system("#{SshCommand} #{(!opt.include? :pty || opt[:pty])? '-t' : ''} #{host} \"#{cmd}\"") || raise("SSH Error") unless dry_run
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
- system("#{SshCommand} -MNf #{host}") || raise("SSH Error") unless dry_run
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
- system("#{SshCommand} -Oexit #{host}") || raise("SSH Error") unless dry_run
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
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
8
  - 2
10
- version: 0.1.2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mat Trudel