choria-colt 0.1.1 → 0.2.0
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/choria/colt/cli.rb +26 -5
- data/lib/choria/colt/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: 6a899af183eb44fcd18e470166a824da35e0ab2ed46ab25c9f001c716442edfe
|
4
|
+
data.tar.gz: 891b29051dacb1ca6e2fa801ae38f0800e8cdb7decc734590c3354bdb5d12dee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98a116297f7f1d4f4384042f43d0fc90b07e85ea4546a799391271dc2c2b2b0602a4e400754f795ee1c499c027b0861de3d713fea2dc132d1d8a88d6bab2f9ab
|
7
|
+
data.tar.gz: 51bd11e393b922ae49113fa6784fd24aeb31a592f093ba95b4de0e5a02973a004030233302ff401d58d01fbef411aa4c87ac98dd1a6e219c6219d61727c0181e
|
data/lib/choria/colt/cli.rb
CHANGED
@@ -31,7 +31,10 @@ module Choria
|
|
31
31
|
targets = nil if options['targets'] == 'all'
|
32
32
|
|
33
33
|
results = colt.run_bolt_task task_name, input: input, targets: targets
|
34
|
-
|
34
|
+
|
35
|
+
File.write 'last_run.json', JSON.pretty_generate(results)
|
36
|
+
|
37
|
+
show_results(results)
|
35
38
|
rescue Choria::Orchestrator::Error => e
|
36
39
|
raise Thor::Error, "#{e.class}: #{e}"
|
37
40
|
end
|
@@ -54,13 +57,12 @@ module Choria
|
|
54
57
|
environment = options['environment']
|
55
58
|
cache_directory = File.expand_path('.cache/colt/tasks')
|
56
59
|
FileUtils.mkdir_p cache_directory
|
57
|
-
# TODO: Support multiple infrastructure
|
58
60
|
cache = Cache.new(path: File.join(cache_directory, "#{environment}.yaml"))
|
59
61
|
|
60
62
|
tasks = colt.tasks(environment: environment, cache: cache)
|
61
63
|
|
62
|
-
if tasks_names.
|
63
|
-
show_tasks_summary
|
64
|
+
if tasks_names.empty?
|
65
|
+
show_tasks_summary(tasks)
|
64
66
|
else
|
65
67
|
tasks_names.each { |task_name| show_task_details(task_name, tasks) }
|
66
68
|
end
|
@@ -96,9 +98,28 @@ module Choria
|
|
96
98
|
Task: '#{task_name}'
|
97
99
|
#{metadata['metadata']['description']}
|
98
100
|
|
99
|
-
|
101
|
+
Parameters:
|
102
|
+
#{JSON.pretty_generate(metadata['metadata']['parameters']).gsub(/^/, ' ')}
|
100
103
|
OUTPUT
|
101
104
|
end
|
105
|
+
|
106
|
+
def show_results(results)
|
107
|
+
results.each { |result| show_result(result) }
|
108
|
+
end
|
109
|
+
|
110
|
+
def show_result(result)
|
111
|
+
return show_generic_output(result) unless result.dig(:result, '_output').nil? || (result.dig(:result, 'exit_code') != 0)
|
112
|
+
|
113
|
+
$stdout.puts JSON.pretty_generate(result)
|
114
|
+
end
|
115
|
+
|
116
|
+
def show_generic_output(result)
|
117
|
+
target = result[:sender]
|
118
|
+
|
119
|
+
output = result.dig(:result, '_output')
|
120
|
+
$stdout.puts "'#{target}':"
|
121
|
+
output.split("\n").each { |line| $stdout.puts(" #{line}") }
|
122
|
+
end
|
102
123
|
end
|
103
124
|
end
|
104
125
|
|
data/lib/choria/colt/version.rb
CHANGED