puppet_litmus 0.22.0 → 0.25.1
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 +2 -4
- data/exe/matrix_from_metadata_v2 +105 -0
- data/lib/puppet_litmus/inventory_manipulation.rb +1 -5
- data/lib/puppet_litmus/puppet_helpers.rb +15 -12
- data/lib/puppet_litmus/version.rb +1 -1
- data/spec/lib/puppet_litmus/rake_tasks_spec.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 228833b61d086ab7b01341ce03eb1169c309855209ca8a1345d55525fbe6403b
|
4
|
+
data.tar.gz: 9e1f9a8f180f047bf49ac493b00871294bf22adccc134fbea6aa7c46fa8b6769
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efc5c864bf1781678e2cfd729bbbe2e5bdbe1f0eb03b244f135d892629c6e404aa01c1290fb001bb5616f8149800ff05e55fb57abb78b4f2041d1539ab18864d
|
7
|
+
data.tar.gz: 1b12e3fcd6b1d9def5040c720a543a44df317538dcfe9058930a205412c709ff6160215edacaa4f6c22e6c2223b543d9f6d7ccc884b059ce849c5c83ce3079e1
|
data/exe/matrix_from_metadata
CHANGED
@@ -6,7 +6,6 @@
|
|
6
6
|
require 'json'
|
7
7
|
|
8
8
|
IMAGE_TABLE = {
|
9
|
-
'RedHat-6' => 'rhel-6',
|
10
9
|
'RedHat-7' => 'rhel-7',
|
11
10
|
'RedHat-8' => 'rhel-8',
|
12
11
|
'SLES-12' => 'sles-12',
|
@@ -36,9 +35,8 @@ DOCKER_PLATFORMS = [
|
|
36
35
|
# This table uses the latest version in each collection for accurate
|
37
36
|
# comparison when evaluating puppet requirements from the metadata
|
38
37
|
COLLECTION_TABLE = {
|
39
|
-
'
|
40
|
-
'
|
41
|
-
'7.0.0' => 'puppet7-nightly',
|
38
|
+
'6.21.0' => 'puppet6-nightly',
|
39
|
+
'7.4.0' => 'puppet7-nightly',
|
42
40
|
}.freeze
|
43
41
|
|
44
42
|
matrix = {
|
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# this script creates a build matrix for github actions from the claimed supported platforms and puppet versions in metadata.json
|
5
|
+
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
IMAGE_TABLE = {
|
9
|
+
'RedHat-7' => 'rhel-7',
|
10
|
+
'RedHat-8' => 'rhel-8',
|
11
|
+
'SLES-12' => 'sles-12',
|
12
|
+
'SLES-15' => 'sles-15',
|
13
|
+
'Windows-2012 R2' => 'windows-2012-r2-core',
|
14
|
+
'Windows-2016' => 'windows-2016',
|
15
|
+
'Windows-2019' => 'windows-2019-core',
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
DOCKER_PLATFORMS = {
|
19
|
+
'CentOS-6' => 'litmusimage/centos:6',
|
20
|
+
'CentOS-7' => 'litmusimage/centos:7',
|
21
|
+
'CentOS-8' => 'litmusimage/centos:8',
|
22
|
+
'Debian-10' => 'litmusimage/debian:10',
|
23
|
+
# 'Debian-8' => 'litmusimage/debian:8', Removing from testing: https://puppet.com/docs/pe/2021.0/supported_operating_systems.html
|
24
|
+
'Debian-9' => 'litmusimage/debian:9',
|
25
|
+
'OracleLinux-6' => 'litmusimage/oraclelinux:6',
|
26
|
+
'OracleLinux-7' => 'litmusimage/oraclelinux:7',
|
27
|
+
'Scientific-6' => 'litmusimage/scientificlinux:6',
|
28
|
+
'Scientific-7' => 'litmusimage/scientificlinux:7',
|
29
|
+
# 'Ubuntu-14.04' => 'litmusimage/ubuntu:14.04', Removing from testing: https://puppet.com/docs/pe/2021.0/supported_operating_systems.html
|
30
|
+
'Ubuntu-16.04' => 'litmusimage/ubuntu:16.04',
|
31
|
+
'Ubuntu-18.04' => 'litmusimage/ubuntu:18.04',
|
32
|
+
'Ubuntu-20.04' => 'litmusimage/ubuntu:20.04',
|
33
|
+
}.freeze
|
34
|
+
|
35
|
+
# This table uses the latest version in each collection for accurate
|
36
|
+
# comparison when evaluating puppet requirements from the metadata
|
37
|
+
COLLECTION_TABLE = {
|
38
|
+
'6.24.0' => 'puppet6-nightly',
|
39
|
+
'7.4.0' => 'puppet7-nightly',
|
40
|
+
}.freeze
|
41
|
+
|
42
|
+
matrix = {
|
43
|
+
platforms: [],
|
44
|
+
collection: [],
|
45
|
+
}
|
46
|
+
|
47
|
+
metadata = JSON.parse(File.read('metadata.json'))
|
48
|
+
# Set platforms based on declared operating system support
|
49
|
+
metadata['operatingsystem_support'].sort_by { |a| a['operatingsystem'] }.each do |sup|
|
50
|
+
os = sup['operatingsystem']
|
51
|
+
sup['operatingsystemrelease'].sort_by { |a| a.to_i }.each do |ver|
|
52
|
+
image_key = "#{os}-#{ver}"
|
53
|
+
if IMAGE_TABLE.key? image_key
|
54
|
+
matrix[:platforms] << {
|
55
|
+
label: image_key,
|
56
|
+
provider: 'provision::provision_service',
|
57
|
+
image: IMAGE_TABLE[image_key],
|
58
|
+
}
|
59
|
+
elsif DOCKER_PLATFORMS.key? image_key
|
60
|
+
matrix[:platforms] << {
|
61
|
+
label: image_key,
|
62
|
+
provider: 'provision::docker',
|
63
|
+
image: DOCKER_PLATFORMS[image_key],
|
64
|
+
}
|
65
|
+
else
|
66
|
+
puts "::warning::Cannot find image for #{image_key}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Set collections based on puppet version requirements
|
72
|
+
if metadata.key?('requirements') && metadata['requirements'].length.positive?
|
73
|
+
metadata['requirements'].each do |req|
|
74
|
+
next unless req.key?('name') && req.key?('version_requirement') && req['name'] == 'puppet'
|
75
|
+
|
76
|
+
ver_regexp = %r{^([>=<]{1,2})\s*([\d.]+)\s+([>=<]{1,2})\s*([\d.]+)$}
|
77
|
+
match = ver_regexp.match(req['version_requirement'])
|
78
|
+
if match.nil?
|
79
|
+
puts "::warning::Didn't recognize version_requirement '#{req['version_requirement']}'"
|
80
|
+
break
|
81
|
+
end
|
82
|
+
|
83
|
+
cmp_one, ver_one, cmp_two, ver_two = match.captures
|
84
|
+
reqs = ["#{cmp_one} #{ver_one}", "#{cmp_two} #{ver_two}"]
|
85
|
+
|
86
|
+
COLLECTION_TABLE.each do |key, val|
|
87
|
+
if Gem::Requirement.create(reqs).satisfied_by?(Gem::Version.new(key))
|
88
|
+
matrix[:collection] << val
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Set to defaults (all collections) if no matches are found
|
95
|
+
if matrix[:collection].empty?
|
96
|
+
matrix[:collection] = COLLECTION_TABLE.values
|
97
|
+
end
|
98
|
+
|
99
|
+
# Just to make sure there aren't any duplicates
|
100
|
+
matrix[:platforms] = matrix[:platforms].uniq.sort { |a, b| a[:label] <=> b[:label] }
|
101
|
+
matrix[:collection] = matrix[:collection].uniq.sort
|
102
|
+
|
103
|
+
puts "::set-output name=matrix::#{JSON.generate(matrix)}"
|
104
|
+
|
105
|
+
puts "Created matrix with #{matrix[:platforms].length * matrix[:collection].length} cells."
|
@@ -17,10 +17,7 @@ module PuppetLitmus::InventoryManipulation
|
|
17
17
|
end
|
18
18
|
raise "There is no inventory file at '#{inventory_full_path}'." unless File.exist?(inventory_full_path)
|
19
19
|
|
20
|
-
|
21
|
-
raise "Inventory file is incompatible (version 2 and up). Try the 'bolt project migrate' command." if inventory_hash['version'].nil? || (inventory_hash['version'] < 2)
|
22
|
-
|
23
|
-
inventory_hash
|
20
|
+
YAML.load_file(inventory_full_path)
|
24
21
|
end
|
25
22
|
|
26
23
|
# Provide a default hash for executing against localhost
|
@@ -28,7 +25,6 @@ module PuppetLitmus::InventoryManipulation
|
|
28
25
|
# @return [Hash] inventory.yaml hash containing only an entry for localhost
|
29
26
|
def localhost_inventory_hash
|
30
27
|
{
|
31
|
-
'version' => 2,
|
32
28
|
'groups' => [
|
33
29
|
{
|
34
30
|
'name' => 'local',
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# helper functions for running puppet commands. They execute a target system specified by ENV['TARGET_HOST']
|
4
|
-
# heavily uses functions from here https://github.com/puppetlabs/bolt/blob/
|
4
|
+
# heavily uses functions from here https://github.com/puppetlabs/bolt/blob/main/developer-docs/bolt_spec-run.md
|
5
5
|
module PuppetLitmus::PuppetHelpers
|
6
6
|
# Applies a manifest twice. First checking for errors. Secondly to make sure no changes occur.
|
7
7
|
#
|
@@ -11,7 +11,7 @@ module PuppetLitmus::PuppetHelpers
|
|
11
11
|
Honeycomb.start_span(name: 'litmus.idempotent_apply') do |span|
|
12
12
|
ENV['HONEYCOMB_TRACE'] = span.to_trace_header
|
13
13
|
manifest_file_location = create_manifest_file(manifest)
|
14
|
-
apply_manifest(nil,
|
14
|
+
apply_manifest(nil, catch_failures: true, manifest_file_location: manifest_file_location)
|
15
15
|
apply_manifest(nil, catch_changes: true, manifest_file_location: manifest_file_location)
|
16
16
|
end
|
17
17
|
end
|
@@ -83,18 +83,21 @@ module PuppetLitmus::PuppetHelpers
|
|
83
83
|
command_to_run += ' --noop' if !opts[:noop].nil? && (opts[:noop] == true)
|
84
84
|
command_to_run += ' --detailed-exitcodes' if use_detailed_exit_codes == true
|
85
85
|
|
86
|
-
command_to_run = "try { #{command_to_run}; exit $LASTEXITCODE } catch { write-error $_ ; exit 1 }" if os[:family] == 'windows'
|
87
|
-
|
88
|
-
span.add_field('litmus.command_to_run', command_to_run)
|
89
86
|
span.add_field('litmus.target_node_name', target_node_name)
|
90
|
-
# IAC-1365 - Workaround for BOLT-1535 and bolt issue #1650
|
91
|
-
# bolt_result = run_command(command_to_run, target_node_name, config: nil, inventory: inventory_hash)
|
92
|
-
bolt_result = Tempfile.open(['temp', '.ps1']) do |script|
|
93
|
-
script.write(command_to_run)
|
94
|
-
script.close
|
95
|
-
run_script(script.path, target_node_name, [], options: {}, config: nil, inventory: inventory_hash)
|
96
|
-
end
|
97
87
|
|
88
|
+
if os[:family] == 'windows'
|
89
|
+
# IAC-1365 - Workaround for BOLT-1535 and bolt issue #1650
|
90
|
+
command_to_run = "try { #{command_to_run}; exit $LASTEXITCODE } catch { write-error $_ ; exit 1 }"
|
91
|
+
span.add_field('litmus.command_to_run', command_to_run)
|
92
|
+
bolt_result = Tempfile.open(['temp', '.ps1']) do |script|
|
93
|
+
script.write(command_to_run)
|
94
|
+
script.close
|
95
|
+
run_script(script.path, target_node_name, [], options: {}, config: nil, inventory: inventory_hash)
|
96
|
+
end
|
97
|
+
else
|
98
|
+
span.add_field('litmus.command_to_run', command_to_run)
|
99
|
+
bolt_result = run_command(command_to_run, target_node_name, config: nil, inventory: inventory_hash)
|
100
|
+
end
|
98
101
|
span.add_field('litmus.bolt_result', bolt_result)
|
99
102
|
result = OpenStruct.new(exit_code: bolt_result.first['value']['exit_code'],
|
100
103
|
stdout: bolt_result.first['value']['stdout'],
|
@@ -16,7 +16,7 @@ describe 'litmus rake tasks' do
|
|
16
16
|
'operatingsystem_support' =>
|
17
17
|
[{ 'operatingsystem' => 'RedHat', 'operatingsystemrelease' => ['5'] },
|
18
18
|
{ 'operatingsystem' => 'Ubuntu', 'operatingsystemrelease' => ['14.04', '18.04'] }],
|
19
|
-
'template-ref' => 'heads/
|
19
|
+
'template-ref' => 'heads/main-0-g7827fc2' }
|
20
20
|
expect(File).to receive(:read).with(any_args).once
|
21
21
|
expect(JSON).to receive(:parse).with(any_args).and_return(metadata)
|
22
22
|
expect($stdout).to receive(:puts).with('redhat-5-x86_64')
|
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.25.1
|
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: 2021-
|
11
|
+
date: 2021-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bolt
|
@@ -166,12 +166,14 @@ email:
|
|
166
166
|
- info@puppet.com
|
167
167
|
executables:
|
168
168
|
- matrix_from_metadata
|
169
|
+
- matrix_from_metadata_v2
|
169
170
|
extensions: []
|
170
171
|
extra_rdoc_files: []
|
171
172
|
files:
|
172
173
|
- LICENSE
|
173
174
|
- README.md
|
174
175
|
- exe/matrix_from_metadata
|
176
|
+
- exe/matrix_from_metadata_v2
|
175
177
|
- lib/puppet_litmus.rb
|
176
178
|
- lib/puppet_litmus/inventory_manipulation.rb
|
177
179
|
- lib/puppet_litmus/puppet_helpers.rb
|
@@ -194,7 +196,7 @@ homepage: https://github.com/puppetlabs/puppet_litmus
|
|
194
196
|
licenses:
|
195
197
|
- Apache-2.0
|
196
198
|
metadata: {}
|
197
|
-
post_install_message:
|
199
|
+
post_install_message:
|
198
200
|
rdoc_options: []
|
199
201
|
require_paths:
|
200
202
|
- lib
|
@@ -209,8 +211,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
211
|
- !ruby/object:Gem::Version
|
210
212
|
version: '0'
|
211
213
|
requirements: []
|
212
|
-
rubygems_version: 3.0.
|
213
|
-
signing_key:
|
214
|
+
rubygems_version: 3.0.6
|
215
|
+
signing_key:
|
214
216
|
specification_version: 4
|
215
217
|
summary: Providing a simple command line tool for puppet content creators, to enable
|
216
218
|
simple and complex test deployments.
|