puppet_litmus 1.6.1 → 2.0.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/README.md +18 -0
- data/exe/matrix.json +1 -5
- data/exe/matrix_from_metadata_v2 +2 -1
- data/exe/matrix_from_metadata_v3 +5 -5
- data/lib/puppet_litmus/puppet_helpers.rb +3 -3
- data/lib/puppet_litmus/rake_helper.rb +11 -6
- data/lib/puppet_litmus/spec_helper_acceptance.rb +2 -2
- data/lib/puppet_litmus/version.rb +1 -1
- data/spec/exe/matrix_from_metadata_v2_spec.rb +4 -4
- data/spec/exe/matrix_from_metadata_v3_spec.rb +26 -26
- data/spec/lib/puppet_litmus/rake_helper_spec.rb +22 -1
- metadata +7 -9
- data/exe/matrix_from_metadata +0 -112
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9351e4016b6c6d4f394ac28c0f97e0b6c815963f8e387beb9d56c9358bd2f797
|
4
|
+
data.tar.gz: ca62cf15ef208854e897e6109c65c09a4d9a1913290c15f2a2340e9b6ec073ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a817ad015da1eda9b9abb01b43d882653895d4f6b992e705eddf36dbd43d27b13305cc5c37a7f104b7458b59248add0f0d2e3f0b7a5b42d3c097e370b107d3ec
|
7
|
+
data.tar.gz: d1ed5ca355583f9ea58e78c88f21bf32de414ffe2732cd81002bc7fce8099920d37a2690a026f87e469fa048f30140f58caa8a3e2264a63a534094d127d19528
|
data/README.md
CHANGED
@@ -29,6 +29,24 @@ Install Litmus as a gem by running `gem install puppet_litmus`.
|
|
29
29
|
|
30
30
|
- Note if you choose to override the `litmus_inventory.yaml` location, please ensure that the directory structure you define exists.
|
31
31
|
|
32
|
+
## Agent installs
|
33
|
+
|
34
|
+
### Install a specific puppet agent version
|
35
|
+
|
36
|
+
To install a specific version of the puppet agent, you can export the `PUPPET_VERSION` env var, like below:
|
37
|
+
```
|
38
|
+
export PUPPET_VERSION=8.8.1
|
39
|
+
```
|
40
|
+
|
41
|
+
When set, the `litmus:install_agent` rake task will install the specified version. The default is `latest`.
|
42
|
+
|
43
|
+
## Installing puppetcore agents
|
44
|
+
|
45
|
+
To install a puppetcore puppet agent through the `litmus:install_agent` rake task, you need to export your Forge API key as an env var, like below:
|
46
|
+
```
|
47
|
+
export PUPPET_FORGE_TOKEN='<your_forge_api_key>'
|
48
|
+
```
|
49
|
+
|
32
50
|
## matrix_from_metadata_v3
|
33
51
|
|
34
52
|
matrix_from_metadata_v3 tool generates a github action matrix from the supported operating systems listed in the module's metadata.json.
|
data/exe/matrix.json
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
{
|
2
2
|
"collections": [
|
3
|
-
{
|
4
|
-
"puppet": 7.24,
|
5
|
-
"ruby": 2.7
|
6
|
-
},
|
7
3
|
{
|
8
4
|
"puppet": 8.0,
|
9
5
|
"ruby": 3.2
|
@@ -90,7 +86,7 @@
|
|
90
86
|
},
|
91
87
|
"github_runner": {
|
92
88
|
"docker": {
|
93
|
-
"^(AmazonLinux-2|(CentOS|OracleLinux|Scientific)-7|Ubuntu-18|Debian-10)": "ubuntu-
|
89
|
+
"^(AmazonLinux-2|(CentOS|OracleLinux|Scientific)-7|Ubuntu-18|Debian-10)": "ubuntu-22.04"
|
94
90
|
}
|
95
91
|
}
|
96
92
|
}
|
data/exe/matrix_from_metadata_v2
CHANGED
@@ -217,7 +217,7 @@ if metadata.key?('requirements') && metadata['requirements'].length.positive?
|
|
217
217
|
# This assumes that such a boundary will always allow the latest actually existing puppet version of a release stream, trading off simplicity vs accuracy here.
|
218
218
|
next unless Gem::Requirement.create(reqs).satisfied_by?(Gem::Version.new("#{collection[:puppet_maj_version]}.9999"))
|
219
219
|
|
220
|
-
matrix[:collection] << "
|
220
|
+
matrix[:collection] << "puppetcore#{collection[:puppet_maj_version]}"
|
221
221
|
|
222
222
|
include_version = {
|
223
223
|
8 => "~> #{collection[:puppet_maj_version]}.0",
|
@@ -229,6 +229,7 @@ if metadata.key?('requirements') && metadata['requirements'].length.positive?
|
|
229
229
|
end
|
230
230
|
end
|
231
231
|
|
232
|
+
puts '::warning::matrix_from_metadata_v2 is now deprecated and will be removed in puppet_litmus v3, please migrate to matrix_from_metadata_v3.'
|
232
233
|
# Set to defaults (all collections) if no matches are found
|
233
234
|
matrix[:collection] = COLLECTION_TABLE.map { |collection| "puppet#{collection[:puppet_maj_version]}-nightly" } if matrix[:collection].empty?
|
234
235
|
# Just to make sure there aren't any duplicates
|
data/exe/matrix_from_metadata_v3
CHANGED
@@ -260,7 +260,7 @@ options[:metadata]['requirements']&.each do |req|
|
|
260
260
|
# This assumes that such a boundary will always allow the latest actually existing puppet version of a release stream, trading off simplicity vs accuracy here.
|
261
261
|
next unless gem_req.satisfied_by?(Gem::Version.new("#{collection['puppet'].to_i}.9999"))
|
262
262
|
|
263
|
-
matrix[:collection] << "
|
263
|
+
matrix[:collection] << "puppetcore#{collection['puppet'].to_i}"
|
264
264
|
|
265
265
|
spec_matrix[:include] << {
|
266
266
|
puppet_version: "~> #{collection['puppet']}",
|
@@ -308,10 +308,10 @@ options[:metadata]['operatingsystem_support'].each do |os_sup|
|
|
308
308
|
end
|
309
309
|
|
310
310
|
os_ver_platforms << {
|
311
|
-
label
|
311
|
+
label:,
|
312
312
|
provider: provisioner,
|
313
|
-
arch
|
314
|
-
image
|
313
|
+
arch:,
|
314
|
+
image:,
|
315
315
|
runner: runner.nil? ? options[:runner] : runner
|
316
316
|
}
|
317
317
|
end
|
@@ -330,7 +330,7 @@ Action.group('matrix', matrix, pretty: true).group('spec_matrix', spec_matrix, p
|
|
330
330
|
Action.error('no supported puppet versions') if matrix[:collection].empty?
|
331
331
|
|
332
332
|
if Action.type == 'stdout'
|
333
|
-
$stdout.puts JSON.generate({ matrix
|
333
|
+
$stdout.puts JSON.generate({ matrix:, spec_matrix: })
|
334
334
|
else
|
335
335
|
Action.set_output('matrix', matrix).set_output('spec_matrix', spec_matrix)
|
336
336
|
end
|
@@ -20,8 +20,8 @@ module PuppetLitmus::PuppetHelpers
|
|
20
20
|
# @return [Boolean] The result of the 2 apply manifests.
|
21
21
|
def idempotent_apply(manifest, opts = {})
|
22
22
|
manifest_file_location = create_manifest_file(manifest)
|
23
|
-
apply_manifest(nil, **opts, catch_failures: true, manifest_file_location:
|
24
|
-
apply_manifest(nil, **opts, catch_changes: true, manifest_file_location:
|
23
|
+
apply_manifest(nil, **opts, catch_failures: true, manifest_file_location:)
|
24
|
+
apply_manifest(nil, **opts, catch_changes: true, manifest_file_location:)
|
25
25
|
end
|
26
26
|
|
27
27
|
# Applies a manifest. returning the result of that apply. Mimics the apply_manifest from beaker
|
@@ -230,7 +230,7 @@ module PuppetLitmus::PuppetHelpers
|
|
230
230
|
target_node_name = search_for_target(target_option, inventory_hash)
|
231
231
|
end
|
232
232
|
|
233
|
-
bolt_result = upload_file(source, destination, target_node_name, options
|
233
|
+
bolt_result = upload_file(source, destination, target_node_name, options:, config: nil, inventory: inventory_hash)
|
234
234
|
|
235
235
|
result_obj = {
|
236
236
|
exit_code: 0,
|
@@ -4,7 +4,7 @@ require 'bolt_spec/run'
|
|
4
4
|
require 'puppet_litmus/version'
|
5
5
|
|
6
6
|
# helper methods for the litmus rake tasks
|
7
|
-
module PuppetLitmus::RakeHelper
|
7
|
+
module PuppetLitmus::RakeHelper # rubocop:disable Metrics/ModuleLength
|
8
8
|
# DEFAULT_CONFIG_DATA should be frozen for our safety, but it needs to work around https://github.com/puppetlabs/bolt/pull/1696
|
9
9
|
DEFAULT_CONFIG_DATA = { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') } # .freeze # rubocop:disable Style/MutableConstant
|
10
10
|
SUPPORTED_PROVISIONERS = %w[abs docker docker_exp lxd provision_service vagrant vmpooler].freeze
|
@@ -129,14 +129,19 @@ module PuppetLitmus::RakeHelper
|
|
129
129
|
|
130
130
|
def install_agent(collection, targets, inventory_hash)
|
131
131
|
include ::BoltSpec::Run
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
132
|
+
puppet_version = ENV.fetch('PUPPET_VERSION', nil)
|
133
|
+
forge_token = ENV.fetch('PUPPET_FORGE_TOKEN', nil)
|
134
|
+
params = {}
|
135
|
+
params['password'] = forge_token if forge_token
|
136
|
+
params['collection'] = collection if collection
|
137
|
+
params['version'] = puppet_version if puppet_version
|
138
|
+
|
137
139
|
raise "puppet_agent was not found in #{DEFAULT_CONFIG_DATA['modulepath']}, please amend the .fixtures.yml file" \
|
138
140
|
unless File.directory?(File.join(DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent'))
|
139
141
|
|
142
|
+
raise 'puppetcore agent installs require a valid PUPPET_FORGE_TOKEN set in the env.' \
|
143
|
+
if collection =~ /\Apuppetcore.*/ && !forge_token
|
144
|
+
|
140
145
|
# using boltspec, when the runner is called it changes the inventory_hash dropping the version field. The clone works around this
|
141
146
|
bolt_result = run_task('puppet_agent::install', targets, params, config: DEFAULT_CONFIG_DATA, inventory: inventory_hash.clone)
|
142
147
|
targets.each do |target|
|
@@ -33,7 +33,7 @@ RSpec.describe 'matrix_from_metadata_v2' do
|
|
33
33
|
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","image":"ubuntu-2204-lts-arm64"}',
|
34
34
|
'],',
|
35
35
|
'"collection":[',
|
36
|
-
'"
|
36
|
+
'"puppetcore7","puppetcore8"',
|
37
37
|
']',
|
38
38
|
'}'
|
39
39
|
].join
|
@@ -75,7 +75,7 @@ RSpec.describe 'matrix_from_metadata_v2' do
|
|
75
75
|
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","image":"ubuntu-2204-lts-arm64"}',
|
76
76
|
'],',
|
77
77
|
'"collection":[',
|
78
|
-
'"
|
78
|
+
'"puppetcore7","puppetcore8"',
|
79
79
|
']',
|
80
80
|
'}'
|
81
81
|
].join
|
@@ -114,7 +114,7 @@ RSpec.describe 'matrix_from_metadata_v2' do
|
|
114
114
|
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","image":"ubuntu-2204-lts-arm64"}',
|
115
115
|
'],',
|
116
116
|
'"collection":[',
|
117
|
-
'"
|
117
|
+
'"puppetcore7","puppetcore8"',
|
118
118
|
']',
|
119
119
|
'}'
|
120
120
|
].join
|
@@ -153,7 +153,7 @@ RSpec.describe 'matrix_from_metadata_v2' do
|
|
153
153
|
'{"label":"Ubuntu-22.04","provider":"docker","image":"litmusimage/ubuntu:22.04"}',
|
154
154
|
'],',
|
155
155
|
'"collection":[',
|
156
|
-
'"
|
156
|
+
'"puppetcore7","puppetcore8"',
|
157
157
|
']',
|
158
158
|
'}'
|
159
159
|
].join
|
@@ -24,13 +24,13 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
24
24
|
matrix = [
|
25
25
|
'matrix={',
|
26
26
|
'"platforms":[',
|
27
|
-
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-
|
28
|
-
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-
|
29
|
-
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04","runner":"ubuntu-
|
27
|
+
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-22.04"},',
|
28
|
+
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-22.04"},',
|
29
|
+
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04","runner":"ubuntu-22.04"},',
|
30
30
|
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04","runner":"ubuntu-latest"}',
|
31
31
|
'],',
|
32
32
|
'"collection":[',
|
33
|
-
'"
|
33
|
+
'"puppetcore8"',
|
34
34
|
']',
|
35
35
|
'}'
|
36
36
|
].join
|
@@ -41,7 +41,7 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
41
41
|
'::group::spec_matrix'
|
42
42
|
)
|
43
43
|
expect(github_output_content).to include(matrix)
|
44
|
-
expect(github_output_content).to include('spec_matrix={"include":[{"puppet_version":"~>
|
44
|
+
expect(github_output_content).to include('spec_matrix={"include":[{"puppet_version":"~> 8.0","ruby_version":3.2}]}')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -53,17 +53,17 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
53
53
|
[
|
54
54
|
'matrix={',
|
55
55
|
'"platforms":[',
|
56
|
-
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-
|
57
|
-
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-
|
56
|
+
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-22.04"},',
|
57
|
+
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-22.04"},',
|
58
58
|
'{"label":"RedHat-8","provider":"provision_service","arch":"x86_64","image":"rhel-8","runner":"ubuntu-latest"},',
|
59
59
|
'{"label":"RedHat-9","provider":"provision_service","arch":"x86_64","image":"rhel-9","runner":"ubuntu-latest"},',
|
60
60
|
'{"label":"RedHat-9-arm","provider":"provision_service","arch":"arm","image":"rhel-9-arm64","runner":"ubuntu-latest"},',
|
61
|
-
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04","runner":"ubuntu-
|
61
|
+
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04","runner":"ubuntu-22.04"},',
|
62
62
|
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04","runner":"ubuntu-latest"},',
|
63
63
|
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","arch":"arm","image":"ubuntu-2204-lts-arm64","runner":"ubuntu-latest"}',
|
64
64
|
'],',
|
65
65
|
'"collection":[',
|
66
|
-
'"
|
66
|
+
'"puppetcore8"',
|
67
67
|
']',
|
68
68
|
'}'
|
69
69
|
].join
|
@@ -82,7 +82,7 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
82
82
|
)
|
83
83
|
expect(github_output_content).to include(matrix)
|
84
84
|
expect(github_output_content).to include(
|
85
|
-
'spec_matrix={"include":[{"puppet_version":"~>
|
85
|
+
'spec_matrix={"include":[{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
|
86
86
|
)
|
87
87
|
end
|
88
88
|
end
|
@@ -93,17 +93,17 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
93
93
|
[
|
94
94
|
'matrix={',
|
95
95
|
'"platforms":[',
|
96
|
-
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-
|
97
|
-
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-
|
96
|
+
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-22.04"},',
|
97
|
+
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-22.04"},',
|
98
98
|
'{"label":"RedHat-8","provider":"provision_service","arch":"x86_64","image":"rhel-8","runner":"ubuntu-latest"},',
|
99
99
|
'{"label":"RedHat-9","provider":"provision_service","arch":"x86_64","image":"rhel-9","runner":"ubuntu-latest"},',
|
100
100
|
'{"label":"RedHat-9-arm","provider":"provision_service","arch":"arm","image":"rhel-9-arm64","runner":"ubuntu-latest"},',
|
101
|
-
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04","runner":"ubuntu-
|
101
|
+
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04","runner":"ubuntu-22.04"},',
|
102
102
|
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04","runner":"ubuntu-latest"},',
|
103
103
|
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","arch":"arm","image":"ubuntu-2204-lts-arm64","runner":"ubuntu-latest"}',
|
104
104
|
'],',
|
105
105
|
'"collection":[',
|
106
|
-
'"
|
106
|
+
'"puppetcore8"',
|
107
107
|
']',
|
108
108
|
'}'
|
109
109
|
].join
|
@@ -122,7 +122,7 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
122
122
|
)
|
123
123
|
expect(github_output_content).to include(matrix)
|
124
124
|
expect(github_output_content).to include(
|
125
|
-
'spec_matrix={"include":[{"puppet_version":"~>
|
125
|
+
'spec_matrix={"include":[{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
|
126
126
|
)
|
127
127
|
end
|
128
128
|
end
|
@@ -133,8 +133,8 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
133
133
|
[
|
134
134
|
'matrix={',
|
135
135
|
'"platforms":[',
|
136
|
-
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-
|
137
|
-
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-
|
136
|
+
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-22.04"},',
|
137
|
+
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-22.04"},',
|
138
138
|
'{"label":"RedHat-8","provider":"provision_service","arch":"x86_64","image":"rhel-8","runner":"ubuntu-latest"},',
|
139
139
|
'{"label":"RedHat-9","provider":"provision_service","arch":"x86_64","image":"rhel-9","runner":"ubuntu-latest"},',
|
140
140
|
'{"label":"RedHat-9-arm","provider":"provision_service","arch":"arm","image":"rhel-9-arm64","runner":"ubuntu-latest"},',
|
@@ -142,7 +142,7 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
142
142
|
'{"label":"Ubuntu-22.04-arm","provider":"provision_service","arch":"arm","image":"ubuntu-2204-lts-arm64","runner":"ubuntu-latest"}',
|
143
143
|
'],',
|
144
144
|
'"collection":[',
|
145
|
-
'"
|
145
|
+
'"puppetcore8"',
|
146
146
|
']',
|
147
147
|
'}'
|
148
148
|
].join
|
@@ -162,7 +162,7 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
162
162
|
)
|
163
163
|
expect(github_output_content).to include(matrix)
|
164
164
|
expect(github_output_content).to include(
|
165
|
-
'spec_matrix={"include":[{"puppet_version":"~>
|
165
|
+
'spec_matrix={"include":[{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
|
166
166
|
)
|
167
167
|
end
|
168
168
|
end
|
@@ -175,7 +175,7 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
175
175
|
'"platforms":[',
|
176
176
|
'],',
|
177
177
|
'"collection":[',
|
178
|
-
'"
|
178
|
+
'"puppetcore8"',
|
179
179
|
']',
|
180
180
|
'}'
|
181
181
|
].join
|
@@ -198,7 +198,7 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
198
198
|
)
|
199
199
|
expect(github_output_content).to include(matrix)
|
200
200
|
expect(github_output_content).to include(
|
201
|
-
'spec_matrix={"include":[{"puppet_version":"~>
|
201
|
+
'spec_matrix={"include":[{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
|
202
202
|
)
|
203
203
|
end
|
204
204
|
end
|
@@ -209,13 +209,13 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
209
209
|
[
|
210
210
|
'matrix={',
|
211
211
|
'"platforms":[',
|
212
|
-
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-
|
212
|
+
'{"label":"AmazonLinux-2","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2","runner":"ubuntu-22.04"},',
|
213
213
|
'{"label":"AmazonLinux-2023","provider":"docker","arch":"x86_64","image":"litmusimage/amazonlinux:2023","runner":"ubuntu-20.04"},',
|
214
|
-
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04","runner":"ubuntu-
|
214
|
+
'{"label":"Ubuntu-18.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:18.04","runner":"ubuntu-22.04"},',
|
215
215
|
'{"label":"Ubuntu-22.04","provider":"docker","arch":"x86_64","image":"litmusimage/ubuntu:22.04","runner":"ubuntu-latest"}',
|
216
216
|
'],',
|
217
217
|
'"collection":[',
|
218
|
-
'"
|
218
|
+
'"puppetcore8"',
|
219
219
|
']',
|
220
220
|
'}'
|
221
221
|
].join
|
@@ -233,10 +233,10 @@ RSpec.describe 'matrix_from_metadata_v3' do
|
|
233
233
|
'::group::spec_matrix'
|
234
234
|
)
|
235
235
|
expect(github_output_content).to include(
|
236
|
-
'"collection":["2023.8.0-puppet_enterprise","2021.7.9-puppet_enterprise","
|
236
|
+
'"collection":["2023.8.0-puppet_enterprise","2021.7.9-puppet_enterprise","puppetcore8"'
|
237
237
|
)
|
238
238
|
expect(github_output_content).to include(
|
239
|
-
'spec_matrix={"include":[{"puppet_version":"~>
|
239
|
+
'spec_matrix={"include":[{"puppet_version":"~> 8.0","ruby_version":3.2}]}'
|
240
240
|
)
|
241
241
|
end
|
242
242
|
end
|
@@ -131,13 +131,34 @@ RSpec.describe PuppetLitmus::RakeHelper do
|
|
131
131
|
[{ 'uri' => 'some.host', 'facts' => { 'provisioner' => 'docker', 'container_name' => 'foo', 'platform' => 'some.host' } }] }] }
|
132
132
|
end
|
133
133
|
let(:targets) { ['some.host'] }
|
134
|
-
let(:
|
134
|
+
let(:token) { 'some_token' }
|
135
|
+
let(:params) { { 'collection' => 'puppet6', 'password' => token } }
|
135
136
|
|
136
137
|
it 'calls function' do
|
138
|
+
allow(ENV).to receive(:fetch).with('PUPPET_VERSION', nil).and_return(nil)
|
139
|
+
allow(ENV).to receive(:fetch).with('PUPPET_FORGE_TOKEN', nil).and_return(token)
|
137
140
|
allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent')).and_return(true)
|
138
141
|
allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('puppet_agent::install', targets, params, config: described_class::DEFAULT_CONFIG_DATA, inventory: inventory_hash).and_return([])
|
139
142
|
install_agent('puppet6', targets, inventory_hash)
|
140
143
|
end
|
144
|
+
|
145
|
+
it 'adds puppet version' do
|
146
|
+
params = { 'collection' => 'puppet7', 'version' => '7.35.0' }
|
147
|
+
allow(ENV).to receive(:fetch).with('PUPPET_VERSION', nil).and_return('7.35.0')
|
148
|
+
allow(ENV).to receive(:fetch).with('PUPPET_FORGE_TOKEN', nil).and_return(nil)
|
149
|
+
allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent')).and_return(true)
|
150
|
+
allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('puppet_agent::install', targets, params, config: described_class::DEFAULT_CONFIG_DATA, inventory: inventory_hash).and_return([])
|
151
|
+
install_agent('puppet7', targets, inventory_hash)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'fails for puppetcore if no token supplied' do
|
155
|
+
params = { 'collection' => 'puppetcore7' }
|
156
|
+
allow(ENV).to receive(:fetch).with('PUPPET_VERSION', nil).and_return(nil)
|
157
|
+
allow(ENV).to receive(:fetch).with('PUPPET_FORGE_TOKEN', nil).and_return(nil)
|
158
|
+
allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent')).and_return(true)
|
159
|
+
allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('puppet_agent::install', targets, params, config: described_class::DEFAULT_CONFIG_DATA, inventory: inventory_hash).and_return([])
|
160
|
+
expect { install_agent('puppetcore7', targets, inventory_hash) }.to raise_error(RuntimeError, /puppetcore agent installs require a valid PUPPET_FORGE_TOKEN set in the env\./)
|
161
|
+
end
|
141
162
|
end
|
142
163
|
|
143
164
|
context 'with install_module' do
|
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:
|
4
|
+
version: 2.0.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: 2025-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bolt
|
@@ -126,7 +126,6 @@ email:
|
|
126
126
|
- info@puppet.com
|
127
127
|
executables:
|
128
128
|
- matrix.json
|
129
|
-
- matrix_from_metadata
|
130
129
|
- matrix_from_metadata_v2
|
131
130
|
- matrix_from_metadata_v3
|
132
131
|
extensions: []
|
@@ -135,7 +134,6 @@ files:
|
|
135
134
|
- LICENSE
|
136
135
|
- README.md
|
137
136
|
- exe/matrix.json
|
138
|
-
- exe/matrix_from_metadata
|
139
137
|
- exe/matrix_from_metadata_v2
|
140
138
|
- exe/matrix_from_metadata_v3
|
141
139
|
- lib/puppet_litmus.rb
|
@@ -165,7 +163,7 @@ homepage: https://github.com/puppetlabs/puppet_litmus
|
|
165
163
|
licenses:
|
166
164
|
- Apache-2.0
|
167
165
|
metadata: {}
|
168
|
-
post_install_message:
|
166
|
+
post_install_message:
|
169
167
|
rdoc_options: []
|
170
168
|
require_paths:
|
171
169
|
- lib
|
@@ -173,15 +171,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
171
|
requirements:
|
174
172
|
- - ">="
|
175
173
|
- !ruby/object:Gem::Version
|
176
|
-
version:
|
174
|
+
version: 3.1.0
|
177
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
176
|
requirements:
|
179
177
|
- - ">="
|
180
178
|
- !ruby/object:Gem::Version
|
181
179
|
version: '0'
|
182
180
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
184
|
-
signing_key:
|
181
|
+
rubygems_version: 3.3.27
|
182
|
+
signing_key:
|
185
183
|
specification_version: 4
|
186
184
|
summary: Providing a simple command line tool for puppet content creators, to enable
|
187
185
|
simple and complex test deployments.
|
data/exe/matrix_from_metadata
DELETED
@@ -1,112 +0,0 @@
|
|
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
|
-
# Sets an output variable in GitHub Actions. If the GITHUB_OUTPUT environment
|
9
|
-
# variable is not set, this will fail with an exit code of 1 and
|
10
|
-
# send an ::error:: message to the GitHub Actions log.
|
11
|
-
# @param name [String] The name of the output variable
|
12
|
-
# @param value [String] The value of the output variable
|
13
|
-
|
14
|
-
def set_output(name, value)
|
15
|
-
# Get the output path
|
16
|
-
output = ENV.fetch('GITHUB_OUTPUT')
|
17
|
-
|
18
|
-
# Write the output variable to GITHUB_OUTPUT
|
19
|
-
File.open(output, 'a') do |f|
|
20
|
-
f.puts "#{name}=#{value}"
|
21
|
-
end
|
22
|
-
rescue KeyError
|
23
|
-
puts '::error::GITHUB_OUTPUT environment variable not set.'
|
24
|
-
exit 1
|
25
|
-
end
|
26
|
-
|
27
|
-
IMAGE_TABLE = {
|
28
|
-
'RedHat-7' => 'rhel-7',
|
29
|
-
'RedHat-8' => 'rhel-8',
|
30
|
-
'RedHat-9' => 'rhel-9',
|
31
|
-
'RedHat-9-arm' => 'rhel-9-arm64',
|
32
|
-
'SLES-12' => 'sles-12',
|
33
|
-
'SLES-15' => 'sles-15',
|
34
|
-
'Windows-2012 R2' => 'windows-2012-r2-core',
|
35
|
-
'Windows-2016' => 'windows-2016',
|
36
|
-
'Windows-2019' => 'windows-2019-core'
|
37
|
-
}.freeze
|
38
|
-
|
39
|
-
DOCKER_PLATFORMS = [
|
40
|
-
'CentOS-7',
|
41
|
-
'CentOS-8',
|
42
|
-
'Debian-10',
|
43
|
-
'Debian-8',
|
44
|
-
'Debian-9',
|
45
|
-
'OracleLinux-6',
|
46
|
-
'OracleLinux-7',
|
47
|
-
'Scientific-6',
|
48
|
-
'Scientific-7',
|
49
|
-
'Ubuntu-14.04',
|
50
|
-
'Ubuntu-16.04',
|
51
|
-
'Ubuntu-18.04',
|
52
|
-
'Ubuntu-20.04'
|
53
|
-
].freeze
|
54
|
-
|
55
|
-
# This table uses the latest version in each collection for accurate
|
56
|
-
# comparison when evaluating puppet requirements from the metadata
|
57
|
-
COLLECTION_TABLE = {
|
58
|
-
'6.21.0' => 'puppet6-nightly',
|
59
|
-
'7.4.0' => 'puppet7-nightly'
|
60
|
-
}.freeze
|
61
|
-
|
62
|
-
matrix = {
|
63
|
-
platform: [],
|
64
|
-
collection: []
|
65
|
-
}
|
66
|
-
|
67
|
-
metadata = JSON.parse(File.read('metadata.json'))
|
68
|
-
# Set platforms based on declared operating system support
|
69
|
-
metadata['operatingsystem_support'].sort_by { |a| a['operatingsystem'] }.each do |sup|
|
70
|
-
os = sup['operatingsystem']
|
71
|
-
sup['operatingsystemrelease'].sort_by(&:to_i).each do |ver|
|
72
|
-
image_key = "#{os}-#{ver}"
|
73
|
-
if IMAGE_TABLE.key? image_key
|
74
|
-
matrix[:platform] << IMAGE_TABLE[image_key]
|
75
|
-
elsif DOCKER_PLATFORMS.include? image_key
|
76
|
-
puts "Expecting #{image_key} test using docker on travis"
|
77
|
-
else
|
78
|
-
puts "::warning::Cannot find image for #{image_key}"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
# Set collections based on puppet version requirements
|
84
|
-
if metadata.key?('requirements') && metadata['requirements'].length.positive?
|
85
|
-
metadata['requirements'].each do |req|
|
86
|
-
next unless req.key?('name') && req.key?('version_requirement') && req['name'] == 'puppet'
|
87
|
-
|
88
|
-
ver_regexp = /^([>=<]{1,2})\s*([\d.]+)\s+([>=<]{1,2})\s*([\d.]+)$/
|
89
|
-
match = ver_regexp.match(req['version_requirement'])
|
90
|
-
if match.nil?
|
91
|
-
puts "::warning::Didn't recognize version_requirement '#{req['version_requirement']}'"
|
92
|
-
break
|
93
|
-
end
|
94
|
-
|
95
|
-
cmp_one, ver_one, cmp_two, ver_two = match.captures
|
96
|
-
reqs = ["#{cmp_one} #{ver_one}", "#{cmp_two} #{ver_two}"]
|
97
|
-
|
98
|
-
COLLECTION_TABLE.each do |key, val|
|
99
|
-
matrix[:collection] << val if Gem::Requirement.create(reqs).satisfied_by?(Gem::Version.new(key))
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# Set to defaults (all collections) if no matches are found
|
105
|
-
matrix[:collection] = COLLECTION_TABLE.values if matrix[:collection].empty?
|
106
|
-
|
107
|
-
# Just to make sure there aren't any duplicates
|
108
|
-
matrix[:platform] = matrix[:platform].uniq.sort
|
109
|
-
matrix[:collection] = matrix[:collection].uniq.sort
|
110
|
-
|
111
|
-
set_output('matrix', JSON.generate(matrix))
|
112
|
-
puts "Created matrix with #{matrix[:platform].length * matrix[:collection].length} cells."
|