kdeploy 1.0.7 → 1.0.9
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.
- checksums.yaml +4 -4
- data/lib/kdeploy/cli.rb +45 -34
- data/lib/kdeploy/runner.rb +11 -4
- data/lib/kdeploy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '079548e82a360553e00c1aecb5967fd7d57320dbf5d89684a992885444e0e5ac'
|
4
|
+
data.tar.gz: 4b639818b4116f7111fe44ef3d983abf8fdc0c24ac0ee558f35e09d9d3592722
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f07494332413308f446e39e91f75f856ee1b0484c662ac299d2c2300e01b5ece8d32e072cd727371b53d0542df48a1e8678d0de5889696b09903bda6438005a5
|
7
|
+
data.tar.gz: 91ecd8ede72319bf7693424fe6e2efcee9f9ddb7e82ce2db28ae52f69ed622ec57ba019c49c70d3a7aacbc5357b02d4b5c9861dc294fdd4b15e55540b324fa83
|
data/lib/kdeploy/cli.rb
CHANGED
@@ -177,49 +177,60 @@ module Kdeploy
|
|
177
177
|
|
178
178
|
def print_results(results, task_name)
|
179
179
|
pastel = Pastel.new
|
180
|
-
puts pastel.
|
180
|
+
puts pastel.cyan("\nPLAY [#{task_name}] " + ('*' * 64))
|
181
181
|
|
182
182
|
results.each do |host, result|
|
183
|
-
status = result[:status]
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
end
|
183
|
+
status = case result[:status]
|
184
|
+
when :success then pastel.green('ok')
|
185
|
+
when :changed then pastel.yellow('changed')
|
186
|
+
else pastel.red('failed')
|
187
|
+
end
|
188
|
+
puts pastel.bright_white("\n#{host.ljust(24)} : #{status}")
|
189
|
+
|
190
|
+
if %i[success changed].include?(result[:status])
|
191
|
+
result[:output].each do |step|
|
192
|
+
if step[:command].to_s.start_with?('upload:')
|
193
|
+
puts pastel.green(" [upload] #{step[:command].sub('upload: ', '')}")
|
194
|
+
elsif step[:command].to_s.start_with?('upload_template:')
|
195
|
+
puts pastel.yellow(" [template] #{step[:command].sub('upload_template: ', '')}")
|
197
196
|
else
|
198
|
-
puts pastel.
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
end
|
208
|
-
|
209
|
-
# 显示错误输出
|
210
|
-
if cmd[:output].is_a?(Hash) && !cmd[:output][:stderr].empty?
|
211
|
-
cmd[:output][:stderr].each_line do |line|
|
212
|
-
puts pastel.red(" #{line.rstrip}") unless line.strip.empty?
|
197
|
+
puts pastel.cyan(" [run] #{step[:command].to_s.lines.first.strip}")
|
198
|
+
if step[:output].is_a?(Hash) && step[:output][:stdout]
|
199
|
+
step[:output][:stdout].each_line do |line|
|
200
|
+
puts " > #{line.strip}" unless line.strip.empty?
|
201
|
+
end
|
202
|
+
elsif step[:output].is_a?(String)
|
203
|
+
step[:output].each_line do |line|
|
204
|
+
puts " > #{line.strip}" unless line.strip.empty?
|
205
|
+
end
|
213
206
|
end
|
214
207
|
end
|
215
|
-
|
216
|
-
puts
|
217
208
|
end
|
218
209
|
else
|
219
|
-
|
220
|
-
|
210
|
+
# 失败主机高亮错误
|
211
|
+
err = result[:error] || (if result[:output].is_a?(Array)
|
212
|
+
result[:output].map do |o|
|
213
|
+
o[:output][:stderr] if o[:output].is_a?(Hash)
|
214
|
+
end.compact.join("\n")
|
215
|
+
else
|
216
|
+
result[:output].to_s
|
217
|
+
end)
|
218
|
+
puts pastel.red(" ERROR: #{err}")
|
221
219
|
end
|
222
220
|
end
|
221
|
+
|
222
|
+
# summary
|
223
|
+
puts pastel.cyan("\nPLAY RECAP #{'*' * 64}")
|
224
|
+
max_host_len = results.keys.map(&:length).max || 16
|
225
|
+
results.each do |host, result|
|
226
|
+
ok = %i[success changed].include?(result[:status]) ? result[:output].size : 0
|
227
|
+
failed = result[:status] == :failed ? 1 : 0
|
228
|
+
changed = result[:status] == :changed ? result[:output].size : 0
|
229
|
+
ok_str = pastel.green("ok=#{ok.to_s.ljust(3)}")
|
230
|
+
changed_str = pastel.yellow("changed=#{changed.to_s.ljust(3)}")
|
231
|
+
failed_str = pastel.red("failed=#{failed.to_s.ljust(3)}")
|
232
|
+
puts "#{host.ljust(max_host_len)} : #{ok_str} #{changed_str} #{failed_str}"
|
233
|
+
end
|
223
234
|
end
|
224
235
|
end
|
225
236
|
end
|
data/lib/kdeploy/runner.rb
CHANGED
@@ -24,16 +24,23 @@ module Kdeploy
|
|
24
24
|
task[:block].call.each do |command|
|
25
25
|
case command[:type]
|
26
26
|
when :run
|
27
|
-
|
28
|
-
|
27
|
+
# 美化输出
|
28
|
+
pastel = Pastel.new
|
29
|
+
puts pastel.bright_white("\n#{name.ljust(24)} : ")
|
30
|
+
puts pastel.cyan(" [run] #{command[:command].lines.first.strip}")
|
31
|
+
command[:command].lines[1..].each { |line| puts " > #{line.strip}" unless line.strip.empty? }
|
29
32
|
output = executor.execute(command[:command])
|
30
33
|
result[:output] << { command: command[:command], output: output }
|
31
34
|
when :upload
|
32
|
-
|
35
|
+
pastel = Pastel.new
|
36
|
+
puts pastel.bright_white("\n#{name.ljust(24)} : ")
|
37
|
+
puts pastel.green(" [upload] #{command[:source]} -> #{command[:destination]}")
|
33
38
|
executor.upload(command[:source], command[:destination])
|
34
39
|
result[:output] << { command: "upload: #{command[:source]} -> #{command[:destination]}" }
|
35
40
|
when :upload_template
|
36
|
-
|
41
|
+
pastel = Pastel.new
|
42
|
+
puts pastel.bright_white("\n#{name.ljust(24)} : ")
|
43
|
+
puts pastel.yellow(" [template] #{command[:source]} -> #{command[:destination]}")
|
37
44
|
executor.upload_template(command[:source], command[:destination], command[:variables])
|
38
45
|
result[:output] << { command: "upload_template: #{command[:source]} -> #{command[:destination]}" }
|
39
46
|
end
|
data/lib/kdeploy/version.rb
CHANGED