puppet_litmus 0.20.0 → 0.21.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/exe/matrix_from_metadata +43 -6
- data/lib/puppet_litmus/puppet_helpers.rb +8 -8
- data/lib/puppet_litmus/rake_helper.rb +36 -11
- data/lib/puppet_litmus/rake_tasks.rb +47 -35
- data/lib/puppet_litmus/version.rb +1 -1
- data/spec/lib/puppet_litmus/{version_spec.rb → puppet_litmus_version_spec.rb} +0 -0
- data/spec/lib/puppet_litmus/rake_helper_spec.rb +36 -0
- data/spec/lib/puppet_litmus/rake_tasks_spec.rb +4 -1
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f31e0247c29a20874c704110cac6c6f9c9724624a3fc4bbe1dafd872eee85131
|
4
|
+
data.tar.gz: b940b92982bd7d55861d963ee99f3bc653888063f5d1a304686b276350b18e0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c0272e6b4f6b840b1a294832fa4a5ec8e7b1159f3c08105fbc490e40dbc7535c1297d0f544ac19ce7730b78232944edc06951c0eb3393d39d5fc66b5f49198e
|
7
|
+
data.tar.gz: 9a29fff33eddf104445edbf5b9c7e2ce31f0a67d9da9d9e4d52eb32699f822062e9dee75a2d7c52aecb7bd2a1de6d6aff866708b5dd3d719b96df0af00906b88
|
data/exe/matrix_from_metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
# this script creates a build matrix for github actions from the claimed supported platforms in metadata.json
|
4
|
+
# this script creates a build matrix for github actions from the claimed supported platforms and puppet versions in metadata.json
|
5
5
|
|
6
6
|
require 'json'
|
7
7
|
|
@@ -33,16 +33,21 @@ DOCKER_PLATFORMS = [
|
|
33
33
|
'Ubuntu-20.04',
|
34
34
|
].freeze
|
35
35
|
|
36
|
+
# This table uses the latest version in each collection for accurate
|
37
|
+
# comparison when evaluating puppet requirements from the metadata
|
38
|
+
COLLECTION_TABLE = {
|
39
|
+
'5.5.22' => 'puppet5',
|
40
|
+
'6.19.1' => 'puppet6',
|
41
|
+
'7.0.0' => 'puppet7-nightly',
|
42
|
+
}.freeze
|
43
|
+
|
36
44
|
matrix = {
|
37
45
|
platform: [],
|
38
|
-
collection:
|
39
|
-
puppet5
|
40
|
-
puppet6
|
41
|
-
puppet7-nightly
|
42
|
-
],
|
46
|
+
collection: [],
|
43
47
|
}
|
44
48
|
|
45
49
|
metadata = JSON.parse(File.read('metadata.json'))
|
50
|
+
# Set platforms based on declared operating system support
|
46
51
|
metadata['operatingsystem_support'].sort_by { |a| a['operatingsystem'] }.each do |sup|
|
47
52
|
os = sup['operatingsystem']
|
48
53
|
sup['operatingsystemrelease'].sort_by { |a| a.to_i }.each do |ver|
|
@@ -57,6 +62,38 @@ metadata['operatingsystem_support'].sort_by { |a| a['operatingsystem'] }.each do
|
|
57
62
|
end
|
58
63
|
end
|
59
64
|
|
65
|
+
# Set collections based on puppet version requirements
|
66
|
+
if metadata.key?('requirements') && metadata['requirements'].length.positive?
|
67
|
+
metadata['requirements'].each do |req|
|
68
|
+
next unless req.key?('name') && req.key?('version_requirement') && req['name'] == 'puppet'
|
69
|
+
|
70
|
+
ver_regexp = %r{^([>=<]{1,2})\s*([\d.]+)\s+([>=<]{1,2})\s*([\d.]+)$}
|
71
|
+
match = ver_regexp.match(req['version_requirement'])
|
72
|
+
if match.nil?
|
73
|
+
puts "::warning::Didn't recognize version_requirement '#{req['version_requirement']}'"
|
74
|
+
break
|
75
|
+
end
|
76
|
+
|
77
|
+
cmp_one, ver_one, cmp_two, ver_two = match.captures
|
78
|
+
reqs = ["#{cmp_one} #{ver_one}", "#{cmp_two} #{ver_two}"]
|
79
|
+
|
80
|
+
COLLECTION_TABLE.each do |key, val|
|
81
|
+
if Gem::Requirement.create(reqs).satisfied_by?(Gem::Version.new(key))
|
82
|
+
matrix[:collection] << val
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Set to defaults (all collections) if no matches are found
|
89
|
+
if matrix[:collection].empty?
|
90
|
+
matrix[:collection] = COLLECTION_TABLE.values
|
91
|
+
end
|
92
|
+
|
93
|
+
# Just to make sure there aren't any duplicates
|
94
|
+
matrix[:platform] = matrix[:platform].uniq.sort
|
95
|
+
matrix[:collection] = matrix[:collection].uniq.sort
|
96
|
+
|
60
97
|
puts "::set-output name=matrix::#{JSON.generate(matrix)}"
|
61
98
|
|
62
99
|
puts "Created matrix with #{matrix[:platform].length * matrix[:collection].length} cells."
|
@@ -9,7 +9,7 @@ module PuppetLitmus::PuppetHelpers
|
|
9
9
|
# @return [Boolean] The result of the 2 apply manifests.
|
10
10
|
def idempotent_apply(manifest)
|
11
11
|
Honeycomb.start_span(name: 'litmus.idempotent_apply') do |span|
|
12
|
-
ENV['
|
12
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
13
13
|
manifest_file_location = create_manifest_file(manifest)
|
14
14
|
apply_manifest(nil, expect_failures: false, manifest_file_location: manifest_file_location)
|
15
15
|
apply_manifest(nil, catch_changes: true, manifest_file_location: manifest_file_location)
|
@@ -39,7 +39,7 @@ module PuppetLitmus::PuppetHelpers
|
|
39
39
|
# @return [Object] A result object from the apply.
|
40
40
|
def apply_manifest(manifest, opts = {})
|
41
41
|
Honeycomb.start_span(name: 'litmus.apply_manifest') do |span|
|
42
|
-
ENV['
|
42
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
43
43
|
span.add_field('litmus.manifest', manifest)
|
44
44
|
span.add_field('litmus.opts', opts)
|
45
45
|
|
@@ -117,7 +117,7 @@ module PuppetLitmus::PuppetHelpers
|
|
117
117
|
# @return [String] The path to the location of the manifest.
|
118
118
|
def create_manifest_file(manifest)
|
119
119
|
Honeycomb.start_span(name: 'litmus.create_manifest_file') do |span|
|
120
|
-
ENV['
|
120
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
121
121
|
span.add_field('litmus.manifest', manifest)
|
122
122
|
|
123
123
|
require 'tmpdir'
|
@@ -154,7 +154,7 @@ module PuppetLitmus::PuppetHelpers
|
|
154
154
|
# @return [Bool] Success. The file was succesfully writtne on the target.
|
155
155
|
def write_file(content, destination)
|
156
156
|
Honeycomb.start_span(name: 'litmus.write_file') do |span|
|
157
|
-
ENV['
|
157
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
158
158
|
span.add_field('litmus.destination', destination)
|
159
159
|
|
160
160
|
require 'tmpdir'
|
@@ -191,7 +191,7 @@ module PuppetLitmus::PuppetHelpers
|
|
191
191
|
# @return [Object] A result object from the command.
|
192
192
|
def run_shell(command_to_run, opts = {})
|
193
193
|
Honeycomb.start_span(name: 'litmus.run_shell') do |span|
|
194
|
-
ENV['
|
194
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
195
195
|
span.add_field('litmus.command_to_run', command_to_run)
|
196
196
|
span.add_field('litmus.opts', opts)
|
197
197
|
|
@@ -228,7 +228,7 @@ module PuppetLitmus::PuppetHelpers
|
|
228
228
|
# @return [Object] A result object from the command.
|
229
229
|
def bolt_upload_file(source, destination, opts = {}, options = {})
|
230
230
|
Honeycomb.start_span(name: 'litmus.bolt_upload_file') do |span|
|
231
|
-
ENV['
|
231
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
232
232
|
span.add_field('litmus.source', source)
|
233
233
|
span.add_field('litmus.destination', destination)
|
234
234
|
span.add_field('litmus.opts', opts)
|
@@ -280,7 +280,7 @@ module PuppetLitmus::PuppetHelpers
|
|
280
280
|
# @return [Object] A result object from the task.The values available are stdout, stderr and result.
|
281
281
|
def run_bolt_task(task_name, params = {}, opts = {})
|
282
282
|
Honeycomb.start_span(name: 'litmus.run_task') do |span|
|
283
|
-
ENV['
|
283
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
284
284
|
span.add_field('litmus.task_name', task_name)
|
285
285
|
span.add_field('litmus.params', params)
|
286
286
|
span.add_field('litmus.opts', opts)
|
@@ -348,7 +348,7 @@ module PuppetLitmus::PuppetHelpers
|
|
348
348
|
# @return [Object] A result object from the script run.
|
349
349
|
def bolt_run_script(script, opts = {}, arguments: [])
|
350
350
|
Honeycomb.start_span(name: 'litmus.bolt_run_script') do |span|
|
351
|
-
ENV['
|
351
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
352
352
|
span.add_field('litmus.script', script)
|
353
353
|
span.add_field('litmus.opts', opts)
|
354
354
|
span.add_field('litmus.arguments', arguments)
|
@@ -9,8 +9,8 @@ Honeycomb.configure do |config|
|
|
9
9
|
config.client = Libhoney::NullClient.new
|
10
10
|
end
|
11
11
|
end
|
12
|
-
process_span = Honeycomb.start_span(name: "litmus: #{([$PROGRAM_NAME] + ($ARGV || [])).join(' ')}", serialized_trace: ENV['
|
13
|
-
ENV['
|
12
|
+
process_span = Honeycomb.start_span(name: "litmus: #{([$PROGRAM_NAME] + ($ARGV || [])).join(' ')}", serialized_trace: ENV['HONEYCOMB_TRACE'])
|
13
|
+
ENV['HONEYCOMB_TRACE'] = process_span.to_trace_header
|
14
14
|
Honeycomb.add_field_to_trace('litmus.pid', Process.pid)
|
15
15
|
if defined? PuppetLitmus::VERSION
|
16
16
|
Honeycomb.add_field_to_trace('litmus.version', PuppetLitmus::VERSION)
|
@@ -41,6 +41,13 @@ elsif ENV['GITHUB_ACTIONS'] == 'true'
|
|
41
41
|
Honeycomb.add_field_to_trace('ci.sha', ENV['GITHUB_SHA'])
|
42
42
|
end
|
43
43
|
at_exit do
|
44
|
+
if $ERROR_INFO.is_a?(SystemExit)
|
45
|
+
process_span.add_field('process.exit_code', $ERROR_INFO.status)
|
46
|
+
elsif $ERROR_INFO
|
47
|
+
process_span.add_field('process.exit_code', $ERROR_INFO.class.name)
|
48
|
+
else
|
49
|
+
process_span.add_field('process.exit_code', 'unknown')
|
50
|
+
end
|
44
51
|
process_span.send
|
45
52
|
end
|
46
53
|
|
@@ -96,7 +103,7 @@ module PuppetLitmus::RakeHelper
|
|
96
103
|
# @return [Object] the standard out stream.
|
97
104
|
def run_local_command(command)
|
98
105
|
Honeycomb.start_span(name: 'litmus.run_local_command') do |span|
|
99
|
-
ENV['
|
106
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
100
107
|
span.add_field('litmus.command', command)
|
101
108
|
|
102
109
|
require 'open3'
|
@@ -119,13 +126,18 @@ module PuppetLitmus::RakeHelper
|
|
119
126
|
|
120
127
|
Honeycomb.add_field_to_trace('litmus.provisioner', provisioner)
|
121
128
|
Honeycomb.start_span(name: 'litmus.provision') do |span|
|
122
|
-
ENV['
|
129
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
123
130
|
span.add_field('litmus.platform', platform)
|
124
|
-
|
131
|
+
|
132
|
+
task_name = provisioner_task(provisioner)
|
133
|
+
span.add_field('litmus.task_name', task_name)
|
134
|
+
span.add_field('litmus.params', params)
|
125
135
|
span.add_field('litmus.config', DEFAULT_CONFIG_DATA)
|
126
136
|
|
127
|
-
bolt_result = run_task(
|
137
|
+
bolt_result = run_task(task_name, 'localhost', params, config: DEFAULT_CONFIG_DATA, inventory: nil)
|
138
|
+
span.add_field('litmus.result', bolt_result)
|
128
139
|
span.add_field('litmus.node_name', bolt_result&.first&.dig('value', 'node_name'))
|
140
|
+
|
129
141
|
raise_bolt_errors(bolt_result, "provisioning of #{platform} failed.")
|
130
142
|
|
131
143
|
bolt_result
|
@@ -148,7 +160,7 @@ module PuppetLitmus::RakeHelper
|
|
148
160
|
|
149
161
|
def tear_down_nodes(targets, inventory_hash)
|
150
162
|
Honeycomb.start_span(name: 'litmus.tear_down_nodes') do |span|
|
151
|
-
ENV['
|
163
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
152
164
|
span.add_field('litmus.targets', targets)
|
153
165
|
|
154
166
|
include ::BoltSpec::Run
|
@@ -160,6 +172,18 @@ module PuppetLitmus::RakeHelper
|
|
160
172
|
next if node_name == 'litmus_localhost'
|
161
173
|
|
162
174
|
result = tear_down(node_name, inventory_hash)
|
175
|
+
# Some provisioners tear_down targets that were created as a batch job.
|
176
|
+
# These provisioners should return the list of additional targets
|
177
|
+
# removed so that we do not attempt to process them.
|
178
|
+
if result != [] && result[0]['value'].key?('removed')
|
179
|
+
removed_targets = result[0]['value']['removed']
|
180
|
+
result[0]['value'].delete('removed')
|
181
|
+
removed_targets.each do |removed_target|
|
182
|
+
targets.delete(removed_target)
|
183
|
+
results[removed_target] = result
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
163
187
|
results[node_name] = result unless result == []
|
164
188
|
end
|
165
189
|
results
|
@@ -168,7 +192,7 @@ module PuppetLitmus::RakeHelper
|
|
168
192
|
|
169
193
|
def tear_down(node_name, inventory_hash)
|
170
194
|
Honeycomb.start_span(name: 'litmus.tear_down') do |span|
|
171
|
-
ENV['
|
195
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
172
196
|
# how do we know what provisioner to use
|
173
197
|
|
174
198
|
span.add_field('litmus.node_name', node_name)
|
@@ -184,7 +208,7 @@ module PuppetLitmus::RakeHelper
|
|
184
208
|
|
185
209
|
def install_agent(collection, targets, inventory_hash)
|
186
210
|
Honeycomb.start_span(name: 'litmus.install_agent') do |span|
|
187
|
-
ENV['
|
211
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
188
212
|
span.add_field('litmus.collection', collection)
|
189
213
|
span.add_field('litmus.targets', targets)
|
190
214
|
|
@@ -276,7 +300,7 @@ module PuppetLitmus::RakeHelper
|
|
276
300
|
# @return a bolt result
|
277
301
|
def install_module(inventory_hash, target_node_name, module_tar, module_repository = nil, ignore_dependencies = false) # rubocop:disable Style/OptionalBooleanParameter
|
278
302
|
Honeycomb.start_span(name: 'install_module') do |span|
|
279
|
-
ENV['
|
303
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
280
304
|
span.add_field('litmus.target_node_name', target_node_name)
|
281
305
|
span.add_field('litmus.module_tar', module_tar)
|
282
306
|
|
@@ -332,7 +356,7 @@ module PuppetLitmus::RakeHelper
|
|
332
356
|
|
333
357
|
def check_connectivity?(inventory_hash, target_node_name)
|
334
358
|
Honeycomb.start_span(name: 'litmus.check_connectivity') do |span|
|
335
|
-
ENV['
|
359
|
+
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
336
360
|
# if we're only checking connectivity for a single node
|
337
361
|
if target_node_name
|
338
362
|
span.add_field('litmus.target_node_name', target_node_name)
|
@@ -355,6 +379,7 @@ module PuppetLitmus::RakeHelper
|
|
355
379
|
span.add_field('litmus.connectivity_failure', results.reject { |r| r['status'] == 'success' })
|
356
380
|
raise "Connectivity has failed on: #{failed}" unless failed.length.zero?
|
357
381
|
|
382
|
+
puts 'Connectivity check PASSED.'
|
358
383
|
true
|
359
384
|
end
|
360
385
|
end
|
@@ -33,12 +33,11 @@ namespace :litmus do
|
|
33
33
|
inventory_vars = provision_hash[args[:key]]['vars']
|
34
34
|
# Splat the params into environment variables to pass to the provision task but only in this runspace
|
35
35
|
provision_hash[args[:key]]['params']&.each { |k, value| ENV[k.upcase] = value.to_s }
|
36
|
-
results = []
|
37
36
|
failed_image_message = ''
|
38
|
-
provision_hash[args[:key]]['images'].
|
37
|
+
if provision_hash[args[:key]]['images'].instance_of?(Hash)
|
39
38
|
begin
|
40
|
-
spinner = start_spinner("Provisioning
|
41
|
-
result = provision(provisioner,
|
39
|
+
spinner = start_spinner("Provisioning multiple images using #{provisioner} provisioner.")
|
40
|
+
result = provision(provisioner, provision_hash[args[:key]]['images'], inventory_vars)
|
42
41
|
ensure
|
43
42
|
stop_spinner(spinner)
|
44
43
|
end
|
@@ -46,9 +45,23 @@ namespace :litmus do
|
|
46
45
|
if result.first['status'] != 'success'
|
47
46
|
failed_image_message += "=====\n#{result.first['target']}\n#{result.first['value']['_output']}\n#{result.inspect}"
|
48
47
|
else
|
49
|
-
$stdout.puts
|
48
|
+
$stdout.puts 'Success'
|
49
|
+
end
|
50
|
+
else
|
51
|
+
provision_hash[args[:key]]['images'].each do |image|
|
52
|
+
begin
|
53
|
+
spinner = start_spinner("Provisioning #{image} using #{provisioner} provisioner.")
|
54
|
+
result = provision(provisioner, image, inventory_vars)
|
55
|
+
ensure
|
56
|
+
stop_spinner(spinner)
|
57
|
+
end
|
58
|
+
|
59
|
+
if result.first['status'] != 'success'
|
60
|
+
failed_image_message += "=====\n#{result.first['target']}\n#{result.first['value']['_output']}\n#{result.inspect}"
|
61
|
+
else
|
62
|
+
$stdout.puts "#{result.first['value']['node_name']}, #{image}"
|
63
|
+
end
|
50
64
|
end
|
51
|
-
results << result
|
52
65
|
end
|
53
66
|
|
54
67
|
raise "Failed to provision with '#{provisioner}'\n #{failed_image_message}" unless failed_image_message.empty?
|
@@ -112,38 +125,37 @@ namespace :litmus do
|
|
112
125
|
|
113
126
|
results = install_agent(args[:collection], targets, inventory_hash)
|
114
127
|
results.each do |result|
|
115
|
-
|
116
|
-
|
117
|
-
raise "Failed on #{result['target']}\n#{result}\ntry running '#{command_to_run}'"
|
118
|
-
else
|
119
|
-
# validate successful install
|
120
|
-
puts "Successfull install result: #{result.inspect}" if ENV['DEBUG'] == true
|
121
|
-
retries = 0
|
122
|
-
begin
|
123
|
-
responses = run_command('puppet --version', targets, options: {}, config: DEFAULT_CONFIG_DATA, inventory: inventory_hash.clone)
|
124
|
-
responses.each do |response|
|
125
|
-
raise "Error checking puppet version on #{response.to_json}" if response['status'] != 'success'
|
126
|
-
end
|
127
|
-
rescue StandardError => e
|
128
|
-
puts "ERROR:#{e}"
|
129
|
-
# fix the path
|
130
|
-
path_changes = configure_path(inventory_hash)
|
131
|
-
if ENV['DEBUG'] == true
|
132
|
-
path_changes.each do |change|
|
133
|
-
puts "Configuring puppet path result: #{change.inspect}"
|
134
|
-
end
|
135
|
-
end
|
128
|
+
command_to_run = "bolt task run puppet_agent::install --targets #{result['target']} --inventoryfile inventory.yaml --modulepath #{DEFAULT_CONFIG_DATA['modulepath']}"
|
129
|
+
raise "Failed on #{result['target']}\n#{result}\ntry running '#{command_to_run}'" if result['status'] != 'success'
|
136
130
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
131
|
+
# validate successful install
|
132
|
+
puts "Successfull install result: #{result.inspect}" if ENV['DEBUG'] == 'true'
|
133
|
+
retries = 0
|
134
|
+
begin
|
135
|
+
responses = run_command('puppet --version', targets, options: {}, config: DEFAULT_CONFIG_DATA, inventory: inventory_hash.clone)
|
136
|
+
responses.each do |response|
|
137
|
+
raise "Error checking puppet version on #{response.to_json}" if response['status'] != 'success'
|
138
|
+
end
|
139
|
+
rescue StandardError => e
|
140
|
+
puts "ERROR:#{e}" if ENV['DEBUG'] == 'true'
|
141
|
+
# fix the path
|
142
|
+
path_changes = configure_path(inventory_hash)
|
143
|
+
if ENV['DEBUG'] == 'true'
|
144
|
+
path_changes.each do |change|
|
145
|
+
puts "Configuring puppet path result: #{change.inspect}"
|
146
|
+
end
|
141
147
|
end
|
142
148
|
|
143
|
-
|
144
|
-
|
149
|
+
retries += 1
|
150
|
+
sleep 3
|
151
|
+
retry if retries <= 300
|
152
|
+
raise 'Failed to detect installed puppet version after 5 minutes'
|
145
153
|
end
|
154
|
+
|
155
|
+
# add puppet-agent feature to successful nodes
|
156
|
+
inventory_hash = add_feature_to_node(inventory_hash, 'puppet-agent', result['target'])
|
146
157
|
end
|
158
|
+
|
147
159
|
# update the inventory with the puppet-agent feature set per node
|
148
160
|
write_to_inventory_file(inventory_hash, 'inventory.yaml')
|
149
161
|
end
|
@@ -375,7 +387,7 @@ namespace :litmus do
|
|
375
387
|
at_exit { exit! }
|
376
388
|
|
377
389
|
env = options[:env].nil? ? {} : options[:env]
|
378
|
-
env['
|
390
|
+
env['HONEYCOMB_TRACE'] = Honeycomb.current_span.to_trace_header
|
379
391
|
stdout, stderr, status = Open3.capture3(env, test)
|
380
392
|
["\n================\n#{title}\n", stdout, stderr, status]
|
381
393
|
end
|
@@ -393,7 +405,7 @@ namespace :litmus do
|
|
393
405
|
spinners = TTY::Spinner::Multi.new("[:spinner] Running against #{targets.size} targets.")
|
394
406
|
payloads.each do |title, test, options|
|
395
407
|
env = options[:env].nil? ? {} : options[:env]
|
396
|
-
env['
|
408
|
+
env['HONEYCOMB_TRACE'] = Honeycomb.current_span.to_trace_header
|
397
409
|
spinners.register("[:spinner] #{title}") do |sp|
|
398
410
|
stdout, stderr, status = Open3.capture3(env, test)
|
399
411
|
if status.to_i.zero?
|
File without changes
|
@@ -77,6 +77,42 @@ RSpec.describe PuppetLitmus::RakeHelper do
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
context 'with bulk tear_down' do
|
81
|
+
let(:inventory_hash) do
|
82
|
+
{ 'groups' =>
|
83
|
+
[{ 'name' => 'ssh_nodes', 'targets' =>
|
84
|
+
[
|
85
|
+
{ 'uri' => 'one.host', 'facts' => { 'provisioner' => 'abs', 'platform' => 'ubuntu-1604-x86_64', 'job_id' => 'iac-task-pid-21648' } },
|
86
|
+
{ 'uri' => 'two.host', 'facts' => { 'provisioner' => 'abs', 'platform' => 'ubuntu-1804-x86_64', 'job_id' => 'iac-task-pid-21648' } },
|
87
|
+
{ 'uri' => 'three.host', 'facts' => { 'provisioner' => 'abs', 'platform' => 'ubuntu-2004-x86_64', 'job_id' => 'iac-task-pid-21648' } },
|
88
|
+
{ 'uri' => 'four.host', 'facts' => { 'provisioner' => 'abs', 'platform' => 'ubuntu-2004-x86_64', 'job_id' => 'iac-task-pid-21649' } },
|
89
|
+
] }] }
|
90
|
+
end
|
91
|
+
let(:targets) { ['one.host'] }
|
92
|
+
let(:params) { { 'action' => 'tear_down', 'node_name' => 'one.host', 'inventory' => Dir.pwd } }
|
93
|
+
|
94
|
+
it 'calls function' do
|
95
|
+
allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'provision')).and_return(true)
|
96
|
+
allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('provision::abs', 'localhost', params, config: described_class::DEFAULT_CONFIG_DATA, inventory: nil).and_return(
|
97
|
+
[{ 'target' => 'localhost',
|
98
|
+
'action' => 'task',
|
99
|
+
'object' => 'provision::abs',
|
100
|
+
'status' => 'success',
|
101
|
+
'value' =>
|
102
|
+
{ 'status' => 'ok',
|
103
|
+
'removed' =>
|
104
|
+
['one.host',
|
105
|
+
'two.host',
|
106
|
+
'three.host'] } }],
|
107
|
+
)
|
108
|
+
results = tear_down_nodes(targets, inventory_hash)
|
109
|
+
expect(results.keys).to eq(['one.host', 'two.host', 'three.host'])
|
110
|
+
results.each_value do |value|
|
111
|
+
expect(value[0]['value']).to eq({ 'status' => 'ok' })
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
80
116
|
context 'with install_agent' do
|
81
117
|
let(:inventory_hash) do
|
82
118
|
{ 'groups' =>
|
@@ -68,10 +68,13 @@ describe 'litmus rake tasks' do
|
|
68
68
|
|
69
69
|
allow(File).to receive(:directory?).with(any_args).and_return(true)
|
70
70
|
allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with(any_args).and_return(results)
|
71
|
-
|
71
|
+
allow_any_instance_of(PuppetLitmus::InventoryManipulation).to receive(:inventory_hash_from_inventory_file).with(any_args).and_return({})
|
72
72
|
allow_any_instance_of(PuppetLitmus::RakeHelper).to receive(:check_connectivity?).with(any_args).and_return(true)
|
73
|
+
|
74
|
+
expect($stdout).to receive(:puts).with('Provisioning centos:7 using docker provisioner.')
|
73
75
|
expect($stdout).to receive(:puts).with("Successfully provisioned centos:7 using docker\n")
|
74
76
|
expect($stdout).to receive(:puts).with('localhost:2222, centos:7')
|
77
|
+
|
75
78
|
Rake::Task['litmus:provision'].invoke('docker', 'centos:7')
|
76
79
|
end
|
77
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet_litmus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet, Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bolt
|
@@ -185,16 +185,16 @@ files:
|
|
185
185
|
- spec/data/jim.yaml
|
186
186
|
- spec/lib/puppet_litmus/inventory_manipulation_spec.rb
|
187
187
|
- spec/lib/puppet_litmus/puppet_helpers_spec.rb
|
188
|
+
- spec/lib/puppet_litmus/puppet_litmus_version_spec.rb
|
188
189
|
- spec/lib/puppet_litmus/rake_helper_spec.rb
|
189
190
|
- spec/lib/puppet_litmus/rake_tasks_spec.rb
|
190
191
|
- spec/lib/puppet_litmus/util_spec.rb
|
191
|
-
- spec/lib/puppet_litmus/version_spec.rb
|
192
192
|
- spec/spec_helper.rb
|
193
193
|
homepage: https://github.com/puppetlabs/puppet_litmus
|
194
194
|
licenses:
|
195
195
|
- Apache-2.0
|
196
196
|
metadata: {}
|
197
|
-
post_install_message:
|
197
|
+
post_install_message:
|
198
198
|
rdoc_options: []
|
199
199
|
require_paths:
|
200
200
|
- lib
|
@@ -202,7 +202,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
202
202
|
requirements:
|
203
203
|
- - ">="
|
204
204
|
- !ruby/object:Gem::Version
|
205
|
-
version:
|
205
|
+
version: 2.5.0
|
206
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
207
|
requirements:
|
208
208
|
- - ">="
|
@@ -210,18 +210,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
version: '0'
|
211
211
|
requirements: []
|
212
212
|
rubygems_version: 3.1.4
|
213
|
-
signing_key:
|
213
|
+
signing_key:
|
214
214
|
specification_version: 4
|
215
215
|
summary: Providing a simple command line tool for puppet content creators, to enable
|
216
216
|
simple and complex test deployments.
|
217
217
|
test_files:
|
218
|
-
- spec/
|
219
|
-
- spec/
|
220
|
-
- spec/
|
218
|
+
- spec/spec_helper.rb
|
219
|
+
- spec/lib/puppet_litmus/rake_tasks_spec.rb
|
220
|
+
- spec/lib/puppet_litmus/puppet_litmus_version_spec.rb
|
221
221
|
- spec/lib/puppet_litmus/util_spec.rb
|
222
|
-
- spec/lib/puppet_litmus/version_spec.rb
|
223
222
|
- spec/lib/puppet_litmus/inventory_manipulation_spec.rb
|
224
223
|
- spec/lib/puppet_litmus/rake_helper_spec.rb
|
225
224
|
- spec/lib/puppet_litmus/puppet_helpers_spec.rb
|
226
|
-
- spec/
|
227
|
-
- spec/
|
225
|
+
- spec/data/doot.tar.gz
|
226
|
+
- spec/data/jim.yaml
|
227
|
+
- spec/data/inventory.yaml
|