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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87713c8d6906919afa9b79624fc72f0f353ecd276f4eac20f5c02466722cd4e6
4
- data.tar.gz: b995ac965550cc9f9e244b26e2cf7d0a64dce8ab11fac81528cb8673658b845f
3
+ metadata.gz: 6a899af183eb44fcd18e470166a824da35e0ab2ed46ab25c9f001c716442edfe
4
+ data.tar.gz: 891b29051dacb1ca6e2fa801ae38f0800e8cdb7decc734590c3354bdb5d12dee
5
5
  SHA512:
6
- metadata.gz: cdaa5c4f6250950ecbc674fd5d6ff03c72075b9e7b4c20dcb4f5a566ca5db3a7f8688e8c13d146e83a232349ddeefb05a2251cbe2603efe8013f35b8bebda885
7
- data.tar.gz: 1c8ea277b331ae9f581cff8056da211b0ed8cb8c72421cd0d12043f096186702b802b661b4fc33228727c6b77a640c2f5686ba6a433295733c8c3b28d92b11a9
6
+ metadata.gz: 98a116297f7f1d4f4384042f43d0fc90b07e85ea4546a799391271dc2c2b2b0602a4e400754f795ee1c499c027b0861de3d713fea2dc132d1d8a88d6bab2f9ab
7
+ data.tar.gz: 51bd11e393b922ae49113fa6784fd24aeb31a592f093ba95b4de0e5a02973a004030233302ff401d58d01fbef411aa4c87ac98dd1a6e219c6219d61727c0181e
@@ -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
- $stdout.puts JSON.pretty_generate(results)
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.nil?
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
- #{metadata}
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Choria
4
4
  class Colt
5
- VERSION = '0.1.1'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: choria-colt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romuald Conty