xp5k 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xp5k/rake/dsl.rb +15 -7
- data/lib/xp5k/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e63243781dcd538f44d467d8bd3c2b852392c6dd
|
4
|
+
data.tar.gz: c6533692344df8de75efaa9f8463f22c7df642b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98a175bdcf30bfbd561b9457d10b74beb6be3cf427272f09e08436d4fd57b7fc67dc909a414c5b120add6d5bd2799e47a6fba512203d611f40d73a4696bf06c4
|
7
|
+
data.tar.gz: e5f4f5a6f520321f19c1bfcd7956a1bb94cea850a952aa74c5146ab3c3949a9bab6868c43181601552b57a6fadf87ead08c561d0cc246d1020558d13a5dffd2c
|
data/lib/xp5k/rake/dsl.rb
CHANGED
@@ -48,8 +48,8 @@ module XP5K
|
|
48
48
|
#
|
49
49
|
def on(hosts, *args, &block)
|
50
50
|
|
51
|
-
logs = Hash.new { |h,k| h[k] =
|
52
|
-
errors = Hash.new { |h,k| h[k] =
|
51
|
+
logs = Hash.new { |h,k| h[k] = [] }
|
52
|
+
errors = Hash.new { |h,k| h[k] = [] }
|
53
53
|
ssh_session = {}
|
54
54
|
current_server = ""
|
55
55
|
all_connected = false
|
@@ -66,6 +66,9 @@ module XP5K
|
|
66
66
|
cmd_env = options[:environment].map do |key, value|
|
67
67
|
"#{key}=#{value}"
|
68
68
|
end
|
69
|
+
|
70
|
+
# net/ssh specific options
|
71
|
+
options[:ssh] ||= {}
|
69
72
|
|
70
73
|
if block_given?
|
71
74
|
case result = yield
|
@@ -81,9 +84,9 @@ module XP5K
|
|
81
84
|
until all_connected
|
82
85
|
failed = false
|
83
86
|
gateway_options = {}
|
84
|
-
gateway_options[:config]
|
87
|
+
gateway_options[:config] = XP5K::Config[:ssh_config] || true
|
85
88
|
gateway_user, gateway_host = XP5K::Config[:gateway].match(/^(?:([^;,:=]+)@|)(.*?)$/)[1,2]
|
86
|
-
gateway = Net::SSH::Gateway.new(gateway_host, gateway_user)
|
89
|
+
gateway = Net::SSH::Gateway.new(gateway_host, gateway_user, gateway_options)
|
87
90
|
workq = Queue.new
|
88
91
|
hosts.each{ |host| workq << host }
|
89
92
|
workers = (0...10).map do
|
@@ -92,7 +95,7 @@ module XP5K
|
|
92
95
|
while host = workq.pop(true)
|
93
96
|
begin
|
94
97
|
timeout(5) do
|
95
|
-
ssh_session[host] = gateway.ssh(host, options[:user])
|
98
|
+
ssh_session[host] = gateway.ssh(host, options[:user], options[:ssh])
|
96
99
|
puts "Connected to #{host}..."
|
97
100
|
end
|
98
101
|
rescue Timeout::Error, Net::SSH::Disconnect, Exception => e
|
@@ -121,13 +124,15 @@ module XP5K
|
|
121
124
|
while host = workq.pop(true)
|
122
125
|
begin
|
123
126
|
commands.each do |command|
|
127
|
+
stdout = ""
|
124
128
|
command.prepend(cmd_env.join(' ') + ' ') unless cmd_env.empty?
|
125
129
|
puts "[command][#{host}] #{command}"
|
126
130
|
ssh_session[host].exec!(command) do |channel, stream, data|
|
127
|
-
|
128
|
-
errors[host] << data if stream == :err
|
131
|
+
stdout << data
|
132
|
+
errors[host] << data.chomp if stream == :err
|
129
133
|
puts "[#{stream}][#{host}] #{data}" if data.chomp != ""
|
130
134
|
end
|
135
|
+
logs[host] = stdout
|
131
136
|
end
|
132
137
|
rescue Exception => e
|
133
138
|
puts "[#{host}] " + e.message
|
@@ -158,6 +163,9 @@ module XP5K
|
|
158
163
|
end
|
159
164
|
gateway.shutdown!
|
160
165
|
|
166
|
+
# returns the output
|
167
|
+
# as a map : node => [out1, ..., outn]
|
168
|
+
return logs
|
161
169
|
end
|
162
170
|
|
163
171
|
def run(command)
|
data/lib/xp5k/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xp5k
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pascal Morillon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|