simp-beaker-helpers 1.19.1 → 1.21.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de616faf054a99c350f9a6241296669ce630fff0d6d622fd60c9a36ea2e2a036
4
- data.tar.gz: cdbc0d01a23a79472998e87ccbd850e5a32f4e56aa04b623c1b05c050254df92
3
+ metadata.gz: 6c454a97bb3100de8137245a8f4e328451e4048665c482db961c668cb820c972
4
+ data.tar.gz: 1aed320014ebd403f631faeb3f29484f6cc55a4441a4e499beab7409e289f101
5
5
  SHA512:
6
- metadata.gz: 9539f40a2fbf685e6d3a4763a69aaf5670d80e73a695eab4c029d294523612e847ca16132119a459d4381508e267642065c9f7ff99198ddabe8e4008562d7674
7
- data.tar.gz: b6ed70ae00c28cfe70705cc704df6206318734ae941ef5848751caa8a37506a1e6a4432fd324a7752aae5dfdcd5fc38baa0e029ae3e17fd5cb6094649432b29e
6
+ metadata.gz: b1df4f0b7411eead1d2c0d49f4f16d7a4f5dde7162ce91cb3fcba07018382508e56a8e16fdd65f06ee0b74fa2f4e6d036a7ea7f1d3c292964ce4face723bbb04
7
+ data.tar.gz: 82fb880cc4c7c975aa7a4b44134ec88f6d34d7a30431914c22b2616e54880b00ec647221779dda3d12e2b3f99923af49d3ce49a03efa20d04d318db3457189a4
@@ -2,5 +2,6 @@
2
2
  fixtures:
3
3
  repositories:
4
4
  stdlib: https://github.com/simp/puppetlabs-stdlib
5
+ simplib: https://github.com/simp/pupmod-simp-simplib
5
6
  compliance_markup: https://github.com/simp/pupmod-simp-compliance_markup
6
7
 
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .fips_fixtures.yml
1
2
  *.gem
2
3
  *.swp
3
4
  Gemfile.lock
@@ -1,131 +1,376 @@
1
+ # ------------------------------------------------------------------------------
2
+ # NOTICE: **This file is maintained with puppetsync**
3
+ #
4
+ # This file is updated automatically as part of a puppet module baseline.
5
+ #
6
+ # The next baseline sync will overwrite any local changes to everything above
7
+ # the line "# Repo-specific content"
8
+ # ------------------------------------------------------------------------------
9
+ # The testing matrix considers ruby/puppet versions supported by SIMP and PE:
10
+ #
11
+ # https://puppet.com/docs/pe/2019.8/component_versions_in_recent_pe_releases.html
12
+ # https://puppet.com/misc/puppet-enterprise-lifecycle
13
+ # https://puppet.com/docs/pe/2018.1/overview/getting_support_for_pe.html
14
+ # ------------------------------------------------------------------------------
15
+ # Release Puppet Ruby EOL
16
+ # SIMP 6.4 5.5 2.4.10 TBD
17
+ # PE 2018.1 5.5 2.4.10 2021-01 (LTS overlap)
18
+ # PE 2019.8 6.18 2.5.7 2022-12 (LTS)
1
19
  ---
2
- .cache_bundler: &cache_bundler
20
+
21
+ stages:
22
+ - 'validation'
23
+ - 'acceptance'
24
+ - 'compliance'
25
+ - 'deployment'
26
+
27
+ variables:
28
+ # PUPPET_VERSION is a canary variable!
29
+ #
30
+ # The value `UNDEFINED` will (intentionally) cause `bundler install|update` to
31
+ # fail. The intended value for PUPPET_VERSION is provided by the `pup_#` YAML
32
+ # anchors. If it is still `UNDEFINED`, all the other setting from the job's
33
+ # anchor are also missing.
34
+ PUPPET_VERSION: 'UNDEFINED' # <- Matrixed jobs MUST override this (or fail)
35
+ BUNDLER_VERSION: '1.17.1'
36
+ SIMP_MATRIX_LEVEL: '1'
37
+ SIMP_FORCE_RUN_MATRIX: 'no'
38
+
39
+ # Force dependencies into a path the gitlab-runner user can write to.
40
+ # (This avoids some failures on Runners with misconfigured ruby environments.)
41
+ GEM_HOME: .vendor/gem_install
42
+ BUNDLE_CACHE_PATH: .vendor/bundle
43
+ BUNDLE_PATH: .vendor/bundle
44
+ BUNDLE_BIN: .vendor/gem_install/bin
45
+ BUNDLE_NO_PRUNE: 'true'
46
+
47
+
48
+ # bundler dependencies + caching, optional RVM setup, with diagnostic output
49
+ # --------------------------------------------------------------------------
50
+ .setup_bundler_env: &setup_bundler_env
3
51
  cache:
4
- untracked: true
5
- # A broad attempt at caching between runs (ala Travis CI)
6
- key: "${CI_PROJECT_NAMESPACE}__bundler"
52
+ # Cache bundler gems between pipelines for each Ruby version
53
+ key: "${CI_PROJECT_NAMESPACE}_ruby-${MATRIX_RUBY_VERSION}_bundler"
7
54
  paths:
8
55
  - '.vendor'
9
- - 'vendor'
10
-
11
- .setup_bundler_env: &setup_bundler_env
12
56
  before_script:
13
- - 'echo Files in cache: $(find .vendor | wc -l) || :'
14
- - 'export GEM_HOME=.vendor/gem_install'
15
- - 'export BUNDLE_CACHE_PATH=.vendor/bundler'
16
- - 'declare GEM_BUNDLER_VER=(-v ''~> ${BUNDLER_VERSION:-1.16.0}'')'
17
- - declare GEM_INSTALL=(gem install --no-document)
18
- - declare BUNDLER_INSTALL=(bundle install --no-binstubs --jobs $(nproc) --path=.vendor "${FLAGS[@]}")
19
- - gem list -ie "${GEM_BUNDLE_VER[@]}" --silent bundler || "${GEM_INSTALL[@]}" --local "${GEM_BUNDLE_VER[@]}" bundler || "${GEM_INSTALL[@]}" "${GEM_BUNDLE_VER[@]}" bundler
57
+ - 'ruby -e "puts %(\n\n), %q(=)*80, %(\nSIMP-relevant Environment Variables:\n\n#{e=ENV.keys.grep(/^PUPPET|^SIMP|^BEAKER|MATRIX/); pad=e.map{|x| x.size}.max+1; e.map{|v| %( * #{%(#{v}:).ljust(pad)} #{39.chr + ENV[v] + 39.chr}\n)}.join}\n), %q(=)*80, %(\n\n)"'
58
+ # Diagnostic ruby & gem information
59
+ - 'which ruby && ruby --version || :'
60
+ - "[[ $- == *i* ]] && echo 'Interactive shell session' || echo 'Non-interactive shell session'"
61
+ - "shopt -q login_shell && echo 'Login shell' || echo 'Not a login shell'"
62
+ - 'rvm ls || :'
63
+
64
+ # If RVM is available, make SURE it's using the right Ruby:
65
+ # * Source rvm (to run in non-login shells)
66
+ # * If any $MATRIX_RUBY_VERSION rubies are available, use the latest
67
+ # * Otherwise: install & use ${MATRIX_RUBY_VERSION}-head (e.g., latest)
68
+ # * ^^ This could be wonky and introduce variations across runners
69
+ # * ^^ maybe it should just fail if there is no $MATRIX_RUBY_VERSION installed?
70
+ - "command -v rvm && { if declare -p rvm_path &> /dev/null; then source \"${rvm_path}/scripts/rvm\"; else source \"$HOME/.rvm/scripts/rvm\" || source /etc/profile.d/rvm.sh; fi; }"
71
+ - "command -v rvm && { LATEST_RVM_RUBY_XY=\"$(rvm ls | grep \"$MATRIX_RUBY_VERSION\" | tail -1 | sed -e 's/^.*\\([0-9]\\+\\.[0-9]\\+\\.[0-9]\\+\\).*$/\\1/g')\"; if [ -z \"$LATEST_RVM_RUBY_XY\" ]; then LATEST_RVM_RUBY_XY=\"${MATRIX_RUBY_VERSION}-head\"; rvm install \"$LATEST_RVM_RUBY\" --no-docs; else echo \"Found RVM Ruby: '${LATEST_RVM_RUBY_XY}'\"; fi; rvm use \"$LATEST_RVM_RUBY_XY\" ; }"
72
+ - 'ruby --version || :'
73
+ - 'gem list sync || :'
74
+
75
+ # Bundle gems (preferring cached > local > downloaded resources)
76
+ # * Try to use cached and local resources before downloading dependencies
77
+ - 'declare GEM_BUNDLER_VER=(-v "~> ${BUNDLER_VERSION:-1.17.1}")'
78
+ - 'declare GEM_INSTALL_CMD=(gem install --no-document)'
79
+ - 'declare BUNDLER_INSTALL_CMD=(bundle install --no-binstubs --jobs $(nproc) "${FLAGS[@]}")'
80
+ - 'mkdir -p ${GEM_HOME} ${BUNDLER_BIN}'
81
+ - 'gem list -ie "${GEM_BUNDLER_VER[@]}" --silent bundler || "${GEM_INSTALL_CMD[@]}" --local "${GEM_BUNDLER_VER[@]}" bundler || "${GEM_INSTALL_CMD[@]}" "${GEM_BUNDLER_VER[@]}" bundler'
20
82
  - 'rm -rf pkg/ || :'
21
- - bundle check || rm -f Gemfile.lock && ("${BUNDLER_INSTALL[@]}" --local || "${BUNDLER_INSTALL[@]}")
83
+ - 'bundle check || rm -f Gemfile.lock && ("${BUNDLER_INSTALL_CMD[@]}" --local || "${BUNDLER_INSTALL_CMD[@]}" || bundle pristine || "${BUNDLER_INSTALL_CMD[@]}") || { echo "PIPELINE: Bundler could not install everything (see log output above)" && exit 99 ; }'
84
+
85
+ # Diagnostic bundler, ruby, and gem checks:
86
+ - 'bundle exec rvm ls || :'
87
+ - 'bundle exec which ruby || :'
88
+ - 'bundle show sync || :'
89
+ - 'bundle exec gem list sync || :'
90
+
91
+
92
+ # Assign a matrix level when your test will run. Heavier jobs get higher numbers
93
+ # NOTE: To skip all jobs with a SIMP_MATRIX_LEVEL, set SIMP_MATRIX_LEVEL=0
94
+ # ------------------------------------------------------------------------------
95
+
96
+ .relevant_file_conditions_trigger_spec_tests: &relevant_file_conditions_trigger_spec_tests
97
+ changes:
98
+ - .gitlab-ci.yml
99
+ - .fixtures.yml
100
+ - .rspec
101
+ - metadata.json
102
+ - "spec/spec_helper.rb"
103
+ - "spec/{classes,unit,defines,type_aliases,types,hosts,lib}/**/*.rb"
104
+ - "{SIMP,data,manifests,files,types,lib}/**/*"
105
+ - "templates/**/*.{erb,epp}"
106
+ - "Gemfile"
107
+ exists:
108
+ - "spec/{classes,unit,defines,type_aliases,types,hosts,lib}/**/*_spec.rb"
109
+
110
+ .relevant_file_conditions_trigger_acceptance_tests: &relevant_file_conditions_trigger_acceptance_tests
111
+ changes:
112
+ - .gitlab-ci.yml
113
+ - .fixtures.yml
114
+ - "spec/spec_helper_acceptance.rb"
115
+ - "spec/acceptance/**/*"
116
+ - "{SIMP,data,manifests,files,types,lib}/**/*"
117
+ - "templates/**/*.{erb,epp}"
118
+ - "Gemfile"
119
+ exists:
120
+ - "spec/acceptance/**/*_spec.rb"
121
+
122
+ # For some reason, the rule regexes stopped matching line starts inside
123
+ # $CI_COMMIT_MESSAGE with carets /^/, so we're using /\n?/ as a workaround.
124
+ .skip_job_when_commit_message_says_to: &skip_job_when_commit_message_says_to
125
+ if: '$CI_COMMIT_MESSAGE =~ /\n?CI: (SKIP MATRIX|MATRIX LEVEL 0)/'
126
+ when: never
127
+
128
+ .force_run_job_when_commit_message_lvl_1_or_above: &force_run_job_when_commit_mssage_lvl_1_or_above
129
+ if: '$CI_COMMIT_MESSAGE =~ /\n?CI: MATRIX LEVEL [123]/'
130
+ when: on_success
131
+
132
+ .force_run_job_when_commit_message_lvl_2_or_above: &force_run_job_when_commit_mssage_lvl_2_or_above
133
+ if: '$CI_COMMIT_MESSAGE =~ /\n?CI: MATRIX LEVEL [23]/'
134
+ when: on_success
135
+
136
+ .force_run_job_when_commit_message_lvl_3_or_above: &force_run_job_when_commit_mssage_lvl_3_or_above
137
+ if: '$CI_COMMIT_MESSAGE =~ /\n?CI: MATRIX LEVEL [3]/'
138
+ when: on_success
139
+
140
+ # check for $CI_PIPELINE_SOURCE needed because this is combined w/when:changes
141
+ .run_job_when_level_1_or_above_w_changes: &run_job_when_level_1_or_above_w_changes
142
+ if: '$SIMP_MATRIX_LEVEL =~ /^[123]$/ && $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
143
+ when: on_success
144
+
145
+ .run_job_when_level_2_or_above_w_changes: &run_job_when_level_2_or_above_w_changes
146
+ if: '$SIMP_MATRIX_LEVEL =~ /^[23]$/ && $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
147
+ when: on_success
22
148
 
23
- .spec_tests: &spec_tests
149
+ .run_job_when_level_3_or_above_w_changes: &run_job_when_level_3_or_above_w_changes
150
+ if: '$SIMP_MATRIX_LEVEL =~ /^[3]$/ && $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
151
+ when: on_success
152
+
153
+ .force_run_job_when_var_and_lvl_1_or_above: &force_run_job_when_var_and_lvl_1_or_above
154
+ if: '$SIMP_FORCE_RUN_MATRIX == "yes" && $SIMP_MATRIX_LEVEL =~ /^[123]$/'
155
+ when: on_success
156
+
157
+ .force_run_job_when_var_and_lvl_2_or_above: &force_run_job_when_var_and_lvl_2_or_above
158
+ if: '$SIMP_FORCE_RUN_MATRIX == "yes" && $SIMP_MATRIX_LEVEL =~ /^[23]$/'
159
+ when: on_success
160
+
161
+ .force_run_job_when_var_and_lvl_3_or_above: &force_run_job_when_var_and_lvl_3_or_above
162
+ if: '$SIMP_FORCE_RUN_MATRIX == "yes" && $SIMP_MATRIX_LEVEL =~ /^[3]$/'
163
+ when: on_success
164
+
165
+
166
+
167
+ # SIMP_MATRIX_LEVEL=1: Intended to run every commit
168
+ .with_SIMP_ACCEPTANCE_MATRIX_LEVEL_1: &with_SIMP_ACCEPTANCE_MATRIX_LEVEL_1
169
+ rules:
170
+ - <<: *skip_job_when_commit_message_says_to
171
+ - <<: *force_run_job_when_var_and_lvl_1_or_above
172
+ - <<: *force_run_job_when_commit_mssage_lvl_1_or_above
173
+ - <<: *run_job_when_level_1_or_above_w_changes
174
+ <<: *relevant_file_conditions_trigger_acceptance_tests
175
+ - when: never
176
+
177
+ .with_SIMP_SPEC_MATRIX_LEVEL_1: &with_SIMP_SPEC_MATRIX_LEVEL_1
178
+ rules:
179
+ - <<: *skip_job_when_commit_message_says_to
180
+ - <<: *force_run_job_when_commit_mssage_lvl_1_or_above
181
+ - <<: *force_run_job_when_var_and_lvl_1_or_above
182
+ - <<: *run_job_when_level_1_or_above_w_changes
183
+ <<: *relevant_file_conditions_trigger_spec_tests
184
+ - when: never
185
+
186
+ # SIMP_MATRIX_LEVEL=2: Resource-heavy or redundant jobs
187
+ .with_SIMP_ACCEPTANCE_MATRIX_LEVEL_2: &with_SIMP_ACCEPTANCE_MATRIX_LEVEL_2
188
+ rules:
189
+ - <<: *skip_job_when_commit_message_says_to
190
+ - <<: *force_run_job_when_var_and_lvl_2_or_above
191
+ - <<: *force_run_job_when_commit_mssage_lvl_2_or_above
192
+ - <<: *run_job_when_level_2_or_above_w_changes
193
+ <<: *relevant_file_conditions_trigger_acceptance_tests
194
+ - when: never
195
+
196
+ .with_SIMP_SPEC_MATRIX_LEVEL_2: &with_SIMP_SPEC_MATRIX_LEVEL_2
197
+ rules:
198
+ - <<: *skip_job_when_commit_message_says_to
199
+ - <<: *force_run_job_when_commit_mssage_lvl_2_or_above
200
+ - <<: *force_run_job_when_var_and_lvl_2_or_above
201
+ - <<: *run_job_when_level_2_or_above_w_changes
202
+ <<: *relevant_file_conditions_trigger_spec_tests
203
+ - when: never
204
+
205
+ # SIMP_MATRIX_LEVEL=3: Reserved for FULL matrix testing
206
+ .with_SIMP_ACCEPTANCE_MATRIX_LEVEL_3: &with_SIMP_ACCEPTANCE_MATRIX_LEVEL_3
207
+ rules:
208
+ - <<: *skip_job_when_commit_message_says_to
209
+ - <<: *force_run_job_when_var_and_lvl_3_or_above
210
+ - <<: *force_run_job_when_commit_mssage_lvl_3_or_above
211
+ - <<: *run_job_when_level_3_or_above_w_changes
212
+ <<: *relevant_file_conditions_trigger_acceptance_tests
213
+ - when: never
214
+
215
+
216
+ # Puppet Versions
217
+ #-----------------------------------------------------------------------
218
+
219
+ .pup_5: &pup_5
220
+ image: 'ruby:2.4'
221
+ variables:
222
+ PUPPET_VERSION: '~> 5.0'
223
+ BEAKER_PUPPET_COLLECTION: 'puppet5'
224
+ MATRIX_RUBY_VERSION: '2.4'
225
+
226
+ .pup_6: &pup_6
227
+ image: 'ruby:2.5'
228
+ variables:
229
+ PUPPET_VERSION: '~> 6.0'
230
+ BEAKER_PUPPET_COLLECTION: 'puppet6'
231
+ MATRIX_RUBY_VERSION: '2.5'
232
+
233
+ .pup_6_18_0: &pup_6_18_0
234
+ image: 'ruby:2.5'
235
+ variables:
236
+ PUPPET_VERSION: '6.18.0'
237
+ BEAKER_PUPPET_COLLECTION: 'puppet6'
238
+ MATRIX_RUBY_VERSION: '2.5'
239
+
240
+ .pup_7: &pup_7
241
+ image: 'ruby:2.7'
242
+ variables:
243
+ PUPPET_VERSION: '~> 7.0'
244
+ BEAKER_PUPPET_COLLECTION: 'puppet7'
245
+ MATRIX_RUBY_VERSION: '2.7'
246
+
247
+ # Testing Environments
248
+ #-----------------------------------------------------------------------
249
+
250
+ .lint_tests: &lint_tests
251
+ stage: 'validation'
252
+ tags: ['docker']
253
+ <<: *setup_bundler_env
24
254
  script:
25
- - bundle exec rake spec
255
+ - 'bundle exec rake syntax'
256
+ - 'bundle exec rake lint'
257
+ - 'bundle exec rake metadata_lint'
26
258
 
27
- # To avoid running a prohibitive number of tests every commit,
28
- # don't set this env var in your gitlab instance
29
- .only_with_SIMP_FULL_MATRIX: &only_with_SIMP_FULL_MATRIX
30
- only:
31
- variables:
32
- - $SIMP_FULL_MATRIX
259
+ .unit_tests: &unit_tests
260
+ stage: 'validation'
261
+ tags: ['docker']
262
+ <<: *setup_bundler_env
263
+ <<: *with_SIMP_SPEC_MATRIX_LEVEL_1
264
+ script:
265
+ - 'bundle exec rake spec'
33
266
 
34
- stages:
35
- - unit
36
- - acceptance
37
-
38
- 2_4-unit:
39
- stage: unit
40
- tags:
41
- - docker
42
- image: ruby:2.4
43
- <<: *cache_bundler
267
+ .acceptance_base: &acceptance_base
268
+ stage: 'acceptance'
269
+ tags: ['beaker']
44
270
  <<: *setup_bundler_env
45
- <<: *spec_tests
271
+ <<: *with_SIMP_ACCEPTANCE_MATRIX_LEVEL_1
272
+
273
+ .compliance_base: &compliance_base
274
+ stage: 'compliance'
275
+ tags: ['beaker']
276
+ <<: *setup_bundler_env
277
+ <<: *with_SIMP_ACCEPTANCE_MATRIX_LEVEL_1
278
+
279
+
280
+ # Unit Tests
281
+ #-----------------------------------------------------------------------
282
+
283
+ pup5-unit:
284
+ <<: *pup_5
285
+ <<: *unit_tests
286
+
287
+ pup6-unit:
288
+ <<: *pup_6
289
+ <<: *unit_tests
290
+
291
+ pup7-unit:
292
+ <<: *pup_7
293
+ <<: *unit_tests
294
+
295
+ # ------------------------------------------------------------------------------
296
+ # NOTICE: **This file is maintained with puppetsync**
297
+ #
298
+ # Everything above the "Repo-specific content" comment will be overwritten by
299
+ # the next puppetsync.
300
+ # ------------------------------------------------------------------------------
301
+
302
+ # Repo-specific content
303
+ # ==============================================================================
304
+
305
+ #=======================================================================
306
+ # Packaging test
307
+
308
+ pup5-pkg:
309
+ <<: *pup_5
310
+ <<: *unit_tests
311
+ script:
312
+ 'bundle exec rake pkg:gem'
46
313
 
314
+ pup6-pkg:
315
+ <<: *pup_6
316
+ <<: *unit_tests
317
+ script:
318
+ 'bundle exec rake pkg:gem'
319
+
320
+ pup7-pkg:
321
+ <<: *pup_7
322
+ <<: *unit_tests
323
+ script:
324
+ 'bundle exec rake pkg:gem'
47
325
 
48
326
  #=======================================================================
49
327
  # Acceptance tests
50
328
  default:
51
- stage: acceptance
52
- tags:
53
- - beaker
54
- <<: *cache_bundler
55
- <<: *setup_bundler_env
329
+ <<: *pup_6
330
+ <<: *acceptance_base
56
331
  script:
57
- - bundle exec rake spec_clean
58
332
  - bundle exec rake beaker:suites[default]
59
333
 
60
334
  default-fips:
61
- stage: acceptance
62
- tags:
63
- - beaker
64
- <<: *cache_bundler
65
- <<: *setup_bundler_env
66
- variables:
67
- BEAKER_fips: 'yes'
335
+ <<: *pup_6
336
+ <<: *acceptance_base
68
337
  script:
69
- - bundle exec rake spec_clean
70
- - bundle exec rake beaker:suites[default]
338
+ - BEAKER_fips=yes bundle exec rake beaker:suites[default]
71
339
 
72
340
  fips_from_fixtures:
73
- stage: acceptance
74
- tags:
75
- - beaker
76
- <<: *cache_bundler
77
- <<: *setup_bundler_env
78
- variables:
79
- PUPPET_VERSION: '~> 5.3'
80
- BEAKER_PUPPET_COLLECTION: 'puppet5'
341
+ <<: *pup_6
342
+ <<: *acceptance_base
81
343
  script:
82
- - bundle exec rake spec_clean
83
344
  - bundle exec rake beaker:suites[fips_from_fixtures]
84
345
 
85
346
  puppet5_collections:
86
- stage: acceptance
87
- tags:
88
- - beaker
89
- <<: *cache_bundler
90
- <<: *setup_bundler_env
91
- variables:
92
- PUPPET_VERSION: '~> 5.3'
347
+ <<: *pup_5
348
+ <<: *acceptance_base
93
349
  script:
94
- - bundle exec rake spec_clean
95
350
  - bundle exec rake beaker:suites[puppet_collections]
96
351
 
97
352
  puppet6_collections:
98
- stage: acceptance
99
- tags:
100
- - beaker
101
- <<: *cache_bundler
102
- <<: *setup_bundler_env
103
- variables:
104
- BEAKER_PUPPET_COLLECTION: 'puppet6'
353
+ <<: *pup_6
354
+ <<: *acceptance_base
355
+ script:
356
+ - bundle exec rake beaker:suites[puppet_collections]
357
+
358
+ puppet7_collections:
359
+ <<: *pup_7
360
+ <<: *acceptance_base
105
361
  script:
106
- - bundle exec rake spec_clean
107
362
  - bundle exec rake beaker:suites[puppet_collections]
108
363
 
109
364
  windows:
110
- stage: acceptance
111
- tags:
112
- - beaker
113
- <<: *cache_bundler
114
- <<: *setup_bundler_env
365
+ <<: *pup_6
366
+ <<: *acceptance_base
115
367
  script:
116
- - bundle exec rake spec_clean
117
368
  - bundle exec rake beaker:suites[windows]
118
369
 
119
370
  snapshot:
120
- stage: acceptance
371
+ <<: *pup_6
372
+ <<: *acceptance_base
121
373
  # This is prone to breakage in the underlying system
122
374
  allow_failure: true
123
- tags:
124
- - beaker
125
- <<: *cache_bundler
126
- <<: *setup_bundler_env
127
- variables:
128
- BEAKER_simp_snapshot: 'yes'
129
375
  script:
130
- - bundle exec rake spec_clean
131
- - bundle exec rake beaker:suites[snapshot]
376
+ - BEAKER_simp_snapshot=yes bundle exec rake beaker:suites[snapshot]
@@ -1,36 +1,42 @@
1
1
  ---
2
- language: ruby
3
- cache: bundler
4
- sudo: false
5
- before_install:
6
- - rm Gemfile.lock || true
7
- bundler_args: "--without development --path .vendor"
2
+ language: shell
8
3
  notifications:
9
4
  email: false
10
- rvm:
11
- - 2.4.4
12
- env:
13
- - SIMP_SKIP_NON_SIMPOS_TESTS=1
14
- script:
15
- - bundle exec rake spec
16
- before_deploy:
17
- - bundle exec rake clobber
18
- - "export GEM_VERSION=`ruby -r ./lib/simp/beaker_helpers/version.rb -e 'puts Simp::BeakerHelpers::VERSION'`"
19
- - '[[ $TRAVIS_TAG =~ ^${GEM_VERSION}$ ]]'
20
- deploy:
21
- - provider: rubygems
22
- gemspec: simp-beaker-helpers.gemspec
23
- gem: simp-beaker-helpers
24
- api_key:
25
- secure: "AlnBx0dBSxn+S97n0h14ltKUOA+6v0bc7QZPIcwGJV9nnf1hKH3pf9La1TVknEx7XgpAcM9jusQJ7hBlqvSq8z8SFF0bZk1EgSRIKc1cuYPLiGyUM2O7+AFHyCy3iCnPvKeoQmE/BJb5O1dGnbmSbf4A0fqLxA7jiHG1j7z+cnmJB1i67wovDfl13TsOXyBfbespWBMMc0BKAw56FPs9XggAk2cNusS3hd5tqW1AZPT2/xwt+d8ngkmO96u8QcichYRFQ+w+XW4H0w935wNg/dWiskJlt7TIYVAh4Ko5s2DZKf52Tne8TugALSn0LhRatpp7sw1FTTpteCW8UqK8uwGC2hM4pZViAOv4P1YObz2IPOZPriBl+cCayJdMKnotkUJliAMnw5TLiSWKLou+S0Pdj2h3fJZWdOEwRPMzIVoJtsOHG3GdNcPL6f7iU0vP/wr6FeR3uWa+fA7NHRi2Du955O8JpogjdrW08ahcAEwhtI3A4mrA08wN09axsrwr093uDRm/5h4FHyAhExJ0YiA/6kcPpUvILcLStyHe0RQDICQMdsQo2DSbnL65w3QjFa2fML2Shf9cRwX06+ia2BxozWzFD/6p3RiRtPxphnbFiUdjYSGWcwCcUgbJx9SW04lSSxOhpyItuXgxZqiybkzstXd6riu5zwg1R8TWk34="
26
- on:
27
- tags: true
28
- rvm: 2.4.4
29
- condition: "($SKIP_PUBLISH != true)"
30
- - provider: releases
31
- api_key:
32
- secure: "I41p4aqjkrNDHJhZ5gWC4gzn7BVwEYRm5Q3PAxQRSIUDB/QTVgNqZx8YptkuIvSGpw8kIywyZg3NKdzGUO8aJJ0NlXapL7e9qQIigkYhdaCZjZFG5zIxdOFs4sVoz/6vnQT9JIcGWy7uS5xiNOulGvfEWU78+e+I9yPdT74RApve5VAVT/km5lV5ldRnwwehLnTx+volUlnOD8rwfizoVLqFTrfRfr4cVMF605UYyaiVxHF50hywFRZoAdVcMEhlLQnQXfz/ZsLMJLJm9eCpjQ989N0oX6theSLCcv7QtHcWMXydjWMcpuTfBZSFrwUVbC23uMOKTJVEWq5LMG3m2L6hP3//2gvUzGhOVLvoGuC+erboB7QoXdcoOgXY+dTZPMcPBxpArdDLWVQSLTvPs05QzpaUdRLVMC/kD1d1EudlEicgkNgNDBhBn3089nVmvKndbKLvj+23a5AQVVbs+8C0x+SJvTc9N2N+bmuH7jIJPrEvWK4xwcQa+g2M/EBv05jaEdSErlVa6B6UKCH0Lea9rpy1se9vn5OzpaaMCCJIpcpQqHDjo0PMAQXBSbqjKcBei6lR5fIFl5UO9gWP1v8PGPuCzGTBivQ92XlgV1TWXmdbJHwIuSbJx3Ali7Wp19RR4E4uHC+TPFssvgkh9ZLkORnWWS35wzzU1LkwWx0="
33
- on:
34
- tags: true
35
- rvm: 2.4.4
36
- condition: "($SKIP_PUBLISH != true)"
5
+ stages:
6
+ - name: deploy
7
+ if: 'tag IS present'
8
+
9
+ ### Testing on Travis CI is indefinitely disabled
10
+ ###
11
+ ### See:
12
+ ### * https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing
13
+ ### * https://simp-project.atlassian.net/browse/SIMP-8703
14
+ jobs:
15
+ include:
16
+ - stage: deploy
17
+ script: skip
18
+ cache: bundler
19
+ before_install:
20
+ - rm Gemfile.lock || true
21
+ bundler_args: "--without development --path .vendor"
22
+ language: ruby
23
+ rvm: 2.4.5
24
+ before_deploy:
25
+ - bundle exec rake clobber
26
+ - "export GEM_VERSION=`ruby -r ./lib/simp/beaker_helpers/version.rb -e 'puts Simp::BeakerHelpers::VERSION'`"
27
+ - '[[ $TRAVIS_TAG =~ ^${GEM_VERSION}$ ]]'
28
+ deploy:
29
+ - provider: rubygems
30
+ gemspec: simp-beaker-helpers.gemspec
31
+ gem: simp-beaker-helpers
32
+ token:
33
+ secure: "AlnBx0dBSxn+S97n0h14ltKUOA+6v0bc7QZPIcwGJV9nnf1hKH3pf9La1TVknEx7XgpAcM9jusQJ7hBlqvSq8z8SFF0bZk1EgSRIKc1cuYPLiGyUM2O7+AFHyCy3iCnPvKeoQmE/BJb5O1dGnbmSbf4A0fqLxA7jiHG1j7z+cnmJB1i67wovDfl13TsOXyBfbespWBMMc0BKAw56FPs9XggAk2cNusS3hd5tqW1AZPT2/xwt+d8ngkmO96u8QcichYRFQ+w+XW4H0w935wNg/dWiskJlt7TIYVAh4Ko5s2DZKf52Tne8TugALSn0LhRatpp7sw1FTTpteCW8UqK8uwGC2hM4pZViAOv4P1YObz2IPOZPriBl+cCayJdMKnotkUJliAMnw5TLiSWKLou+S0Pdj2h3fJZWdOEwRPMzIVoJtsOHG3GdNcPL6f7iU0vP/wr6FeR3uWa+fA7NHRi2Du955O8JpogjdrW08ahcAEwhtI3A4mrA08wN09axsrwr093uDRm/5h4FHyAhExJ0YiA/6kcPpUvILcLStyHe0RQDICQMdsQo2DSbnL65w3QjFa2fML2Shf9cRwX06+ia2BxozWzFD/6p3RiRtPxphnbFiUdjYSGWcwCcUgbJx9SW04lSSxOhpyItuXgxZqiybkzstXd6riu5zwg1R8TWk34="
34
+ on:
35
+ tags: true
36
+ condition: "($SKIP_PUBLISH != true)"
37
+ - provider: releases
38
+ token:
39
+ secure: "I41p4aqjkrNDHJhZ5gWC4gzn7BVwEYRm5Q3PAxQRSIUDB/QTVgNqZx8YptkuIvSGpw8kIywyZg3NKdzGUO8aJJ0NlXapL7e9qQIigkYhdaCZjZFG5zIxdOFs4sVoz/6vnQT9JIcGWy7uS5xiNOulGvfEWU78+e+I9yPdT74RApve5VAVT/km5lV5ldRnwwehLnTx+volUlnOD8rwfizoVLqFTrfRfr4cVMF605UYyaiVxHF50hywFRZoAdVcMEhlLQnQXfz/ZsLMJLJm9eCpjQ989N0oX6theSLCcv7QtHcWMXydjWMcpuTfBZSFrwUVbC23uMOKTJVEWq5LMG3m2L6hP3//2gvUzGhOVLvoGuC+erboB7QoXdcoOgXY+dTZPMcPBxpArdDLWVQSLTvPs05QzpaUdRLVMC/kD1d1EudlEicgkNgNDBhBn3089nVmvKndbKLvj+23a5AQVVbs+8C0x+SJvTc9N2N+bmuH7jIJPrEvWK4xwcQa+g2M/EBv05jaEdSErlVa6B6UKCH0Lea9rpy1se9vn5OzpaaMCCJIpcpQqHDjo0PMAQXBSbqjKcBei6lR5fIFl5UO9gWP1v8PGPuCzGTBivQ92XlgV1TWXmdbJHwIuSbJx3Ali7Wp19RR4E4uHC+TPFssvgkh9ZLkORnWWS35wzzU1LkwWx0="
40
+ on:
41
+ tags: true
42
+ condition: "($SKIP_PUBLISH != true)"
@@ -1,3 +1,56 @@
1
+ ### 1.21.2 / 2021-01-15
2
+ * Fixed version mismatch. 1.21.1 was tagged with an incorrect version
3
+ in version.rb.
4
+
5
+ ### 1.21.1 / 2021-01-13
6
+ * Added:
7
+ * update_package_from_centos_stream method
8
+ * install_latest_package_on method
9
+ * Fixed:
10
+ * Removed some of the extraneous calls to facter
11
+ * Automatically pull the CentOS 8 kernel to the latest version in
12
+ CentOS-Stream to work around issues on FIPS systems
13
+
14
+ ### 1.20.1 / 2021-01-08
15
+ * Fixed:
16
+ * Ensure that yum calls commands appropriately depending on whether or not
17
+ packages are already installed.
18
+ * Also change all HostKeyAlgorithms settings for SSH connections
19
+
20
+ ### 1.20.0 / 2021-01-05
21
+ * Added:
22
+ * A `enable_epel_on` function that follows the instructions on the EPEL
23
+ website to properly enable EPEL on hosts. May be disabled using
24
+ `BEAKER_enable_epel=no`.
25
+ * An Ubuntu nodeset to make sure our default settings don't destroy other
26
+ Linux systems.
27
+ * Added has_crypto_policies method for determining if crypto policies are
28
+ present on the SUT
29
+ * Added munge_ssh_crypto_policies to allow vagrant to SSH back into systems
30
+ with restrictive crypto policies (usually FIPS)
31
+ * Fixed:
32
+ * Modify all crypto-policy backend files to support ssh-rsa keys
33
+ * Try harder when doing yum installations
34
+
35
+ ### 1.19.4 / 2021-01-05
36
+ * Fixed:
37
+ * Only return a default empty string when `pfact_on` finds a `nil` value
38
+ * Added an acceptance test to validate this
39
+ * Ensure that we start with `facter -p` for `facter` < 4.0 and continue to
40
+ `puppet facts` otherwise
41
+ * Updated the Rakefile to skip symlinks in chmods which fixes the ability to
42
+ build gems
43
+
44
+ ### 1.19.3 / 2021-01-01
45
+ * Fixed:
46
+ * Ensure that `pfact_on` can handle fact dot notation
47
+ * Changed:
48
+ * Silenced some of the noisy commands that didn't provide value-add output
49
+
50
+ ### 1.19.2 / 2020-12-19
51
+ * Fixed:
52
+ * Fixed an issue with pfact_on
53
+
1
54
  ### 1.19.1 / 2020-12-02
2
55
  * Fixed:
3
56
  * Bumped the core puppet version to 6.X
data/Rakefile CHANGED
@@ -30,7 +30,7 @@ task :chmod do
30
30
  gemspec = File.expand_path( "#{@package}.gemspec", @rakefile_dir ).strip
31
31
  spec = Gem::Specification::load( gemspec )
32
32
  spec.files.each do |file|
33
- FileUtils.chmod 'go=r', file
33
+ FileUtils.chmod 'go=r', file unless File.symlink?(file)
34
34
  end
35
35
  end
36
36
 
@@ -18,6 +18,30 @@ module Simp::BeakerHelpers
18
18
  "simp-beaker-helpers-#{t}-#{$$}-#{rand(0x100000000).to_s(36)}.tmp"
19
19
  end
20
20
 
21
+ def install_latest_package_on(sut, package_name, package_source=nil, opts={})
22
+ default_opts = {
23
+ max_retries: 3,
24
+ retry_interval: 10
25
+ }
26
+
27
+ package_source = package_name unless package_source
28
+
29
+ if sut.check_for_package(package_name)
30
+ sut.upgrade_package(
31
+ package_source,
32
+ '',
33
+ default_opts.merge(opts)
34
+ )
35
+ else
36
+ sut.install_package(
37
+ package_source,
38
+ '',
39
+ nil,
40
+ default_opts.merge(opts)
41
+ )
42
+ end
43
+ end
44
+
21
45
  def is_windows?(sut)
22
46
  sut[:platform] =~ /windows/i
23
47
  end
@@ -66,6 +90,8 @@ module Simp::BeakerHelpers
66
90
 
67
91
  if sut[:hypervisor] == 'docker'
68
92
  exclude_list = []
93
+ opts[:silent] ||= true
94
+
69
95
  if opts.has_key?(:ignore) && !opts[:ignore].empty?
70
96
  opts[:ignore].each do |value|
71
97
  exclude_list << "--exclude '#{value}'"
@@ -114,9 +140,34 @@ module Simp::BeakerHelpers
114
140
 
115
141
  # use the `puppet fact` face to look up facts on an SUT
116
142
  def pfact_on(sut, fact_name)
117
- facts_json = on(sut,'puppet facts find xxx').output
118
- facts = JSON.parse(facts_json).fetch( 'values' )
119
- facts.fetch(fact_name)
143
+ require 'ostruct'
144
+
145
+ # If puppet is not installed, there are no puppet facts to fetch
146
+ if sut.which('puppet').empty?
147
+ fact_on(sut, fact_name, :silent => true)
148
+ else
149
+ facts_json = nil
150
+ begin
151
+ cmd_output = on(sut, 'facter -p --json', :silent => true)
152
+
153
+ # Facter 4+
154
+ raise('skip facter -p') if (cmd_output.stderr =~ /no longer supported/)
155
+
156
+ facts = JSON.parse(cmd_output.stdout, object_class: OpenStruct)
157
+ rescue StandardError
158
+ # If *anything* fails, we need to fall back to `puppet facts`
159
+
160
+ facts_json = on(sut, 'puppet facts find garbage_xxx', :silent => true).stdout
161
+ facts = JSON.parse(facts_json, object_class: OpenStruct).values
162
+ end
163
+
164
+ found_fact = facts.dig(*(fact_name.split('.')))
165
+
166
+ # Fall back to the behavior in fact_on
167
+ found_fact = '' if found_fact.nil?
168
+
169
+ return found_fact
170
+ end
120
171
  end
121
172
 
122
173
  # Returns the modulepath on the SUT, as an Array
@@ -294,6 +345,19 @@ module Simp::BeakerHelpers
294
345
  pluginsync_on(suts) if opts[:pluginsync]
295
346
  end
296
347
 
348
+ def has_crypto_policies(sut)
349
+ file_exists_on(sut, '/etc/crypto-policies/config')
350
+ end
351
+
352
+ def munge_ssh_crypto_policies(sut, key_types=['ssh-rsa'])
353
+ if has_crypto_policies(sut)
354
+ install_latest_package_on(sut, 'crypto-policies', nil, :accept_all_exit_codes => true)
355
+
356
+ # Since we may be doing this prior to having a box flip into FIPS mode, we
357
+ # need to find and modify *all* of the affected policies
358
+ on( sut, %{sed --follow-symlinks -i 's/\\(HostKeyAlgorithms\\|PubkeyAcceptedKeyTypes\\)\\(.\\)/\\1\\2#{key_types.join(',')},/g' $( grep -L ssh-rsa $( find /etc/crypto-policies /usr/share/crypto-policies -type f -a \\( -name '*.txt' -o -name '*.config' \\) -exec grep -l PubkeyAcceptedKeyTypes {} \\; ) ) })
359
+ end
360
+ end
297
361
 
298
362
  # Configure and reboot SUTs into FIPS mode
299
363
  def enable_fips_mode_on( suts = hosts )
@@ -347,17 +411,14 @@ module Simp::BeakerHelpers
347
411
  on(sut, module_install_cmd)
348
412
  end
349
413
 
350
- # Enable FIPS and then reboot to finish.
351
- on(sut, %(puppet apply --verbose #{fips_enable_modulepath} -e "class { 'fips': enabled => true }"))
352
-
353
414
  # Work around Vagrant and cipher restrictions in EL8+
354
415
  #
355
416
  # Hopefully, Vagrant will update the used ciphers at some point but who
356
417
  # knows when that will be
357
- opensshserver_config = '/etc/crypto-policies/back-ends/opensshserver.config'
358
- if file_exists_on(sut, opensshserver_config)
359
- on(sut, "sed --follow-symlinks -i 's/PubkeyAcceptedKeyTypes=/PubkeyAcceptedKeyTypes=ssh-rsa,/' #{opensshserver_config}")
360
- end
418
+ munge_ssh_crypto_policies(sut)
419
+
420
+ # Enable FIPS and then reboot to finish.
421
+ on(sut, %(puppet apply --verbose #{fips_enable_modulepath} -e "class { 'fips': enabled => true }"))
361
422
 
362
423
  sut.reboot
363
424
  end
@@ -450,11 +511,57 @@ module Simp::BeakerHelpers
450
511
  repo_manifest = repo_manifest + %(\n#{repo_manifest_opts.join(",\n")}) + "\n}\n"
451
512
  end
452
513
 
514
+ # Enable EPEL if appropriate to do so and the system is online
515
+ #
516
+ # Can be disabled by setting BEAKER_enable_epel=no
517
+ def enable_epel_on(sut)
518
+ if ONLINE && (ENV['BEAKER_stringify_facts'] != 'no')
519
+ os_info = fact_on(sut, 'os')
520
+ os_maj_rel = os_info['release']['major']
521
+
522
+ # This is based on the official EPEL docs https://fedoraproject.org/wiki/EPEL
523
+ if ['RedHat', 'CentOS'].include?(os_info['name'])
524
+ install_latest_package_on(
525
+ sut,
526
+ 'epel-release',
527
+ "https://dl.fedoraproject.org/pub/epel/epel-release-latest-#{os_maj_rel}.noarch.rpm",
528
+ )
529
+
530
+ if os_info['name'] == 'RedHat'
531
+ if os_maj_rel == '7'
532
+ on sut, %{subscription-manager repos --enable "rhel-*-optional-rpms"}
533
+ on sut, %{subscription-manager repos --enable "rhel-*-extras-rpms"}
534
+ on sut, %{subscription-manager repos --enable "rhel-ha-for-rhel-*-server-rpms"}
535
+ end
536
+
537
+ if os_maj_rel == '8'
538
+ on sut, %{subscription-manager repos --enable "codeready-builder-for-rhel-8-#{os_info['architecture']}-rpms"}
539
+ end
540
+ end
541
+
542
+ if os_info['name'] == 'CentOS'
543
+ if os_maj_rel == '8'
544
+ # 8.0 fallback
545
+ on sut, %{dnf config-manager --set-enabled powertools || dnf config-manager --set-enabled PowerTools}
546
+ end
547
+ end
548
+ end
549
+ end
550
+ end
551
+
552
+ def update_package_from_centos_stream(sut, package_name)
553
+ sut.install_package('centos-release-stream') unless sut.check_for_package('centos-release-stream')
554
+ install_latest_package_on(sut, package_name)
555
+ sut.uninstall_package('centos-release-stream')
556
+ end
557
+
453
558
  def linux_errata( sut )
454
559
  # We need to be able to flip between server and client without issue
455
560
  on sut, 'puppet resource group puppet gid=52'
456
561
  on sut, 'puppet resource user puppet comment="Puppet" gid="52" uid="52" home="/var/lib/puppet" managehome=true'
457
562
 
563
+ os_info = fact_on(sut, 'os')
564
+
458
565
  # Make sure we have a domain on our host
459
566
  current_domain = fact_on(sut, 'domain').strip
460
567
  hostname = fact_on(sut, 'hostname').strip
@@ -521,8 +628,9 @@ module Simp::BeakerHelpers
521
628
  configure_type_defaults_on(sut)
522
629
  end
523
630
 
524
- if fact_on(sut, 'osfamily') == 'RedHat'
525
- if fact_on(sut, 'operatingsystem') == 'RedHat'
631
+ if os_info['family'] == 'RedHat'
632
+ # OS-specific items
633
+ if os_info['name'] == 'RedHat'
526
634
  RSpec.configure do |c|
527
635
  c.before(:all) do
528
636
  rhel_rhsm_subscribe(sut)
@@ -534,18 +642,28 @@ module Simp::BeakerHelpers
534
642
  end
535
643
  end
536
644
 
537
- enable_yum_repos_on(sut)
645
+ if ['CentOS','RedHat','OracleLinux'].include?(os_info['name'])
646
+ enable_yum_repos_on(sut)
647
+ enable_epel_on(sut)
538
648
 
539
- # net-tools required for netstat utility being used by be_listening
540
- if fact_on(sut, 'operatingsystemmajrelease') == '7'
541
- pp = <<-EOS
542
- package { 'net-tools': ensure => installed }
543
- EOS
544
- apply_manifest_on(sut, pp, :catch_failures => false)
545
- end
649
+ # net-tools required for netstat utility being used by be_listening
650
+ if os_info['release']['major'].to_i >= 7
651
+ pp = <<-EOS
652
+ package { 'net-tools': ensure => installed }
653
+ EOS
654
+ apply_manifest_on(sut, pp, :catch_failures => false)
655
+ end
656
+
657
+ if (os_info['name'] == 'CentOS') && (os_info['release']['major'].to_i >= 8)
658
+ if os_info['release']['minor'].to_i == 3
659
+ update_package_from_centos_stream(sut, 'kernel')
660
+ sut.reboot
661
+ end
662
+ end
546
663
 
547
- # Clean up YUM prior to starting our test runs.
548
- on(sut, 'yum clean all')
664
+ # Clean up YUM prior to starting our test runs.
665
+ on(sut, 'yum clean all')
666
+ end
549
667
  end
550
668
  end
551
669
 
@@ -606,7 +724,7 @@ module Simp::BeakerHelpers
606
724
  end
607
725
 
608
726
  def sosreport(sut, dest='sosreports')
609
- on(sut, 'puppet resource package sos ensure=latest')
727
+ install_latest_package_on(sut, 'sos')
610
728
  on(sut, 'sosreport --batch')
611
729
 
612
730
  files = on(sut, 'ls /var/tmp/sosreport* /tmp/sosreport* 2>/dev/null', :accept_all_exit_codes => true).output.lines.map(&:strip)
@@ -792,18 +910,18 @@ module Simp::BeakerHelpers
792
910
  # Need to hash all of the CA certificates so that apps can use them
793
911
  # properly! This must happen on the host itself since it needs to match
794
912
  # the native hashing algorithms.
795
- hash_cmd = <<-EOM.strip
796
- cd #{sut_pki_dir}/cacerts; \
797
- for x in *; do \
798
- if [ ! -h "$x" ]; then \
799
- `openssl x509 -in $x >/dev/null 2>&1`; \
800
- if [ $? -eq 0 ]; then \
801
- hash=`openssl x509 -in $x -hash | head -1`; \
802
- ln -sf $x $hash.0; \
803
- fi; \
804
- fi; \
805
- done
806
- EOM
913
+ hash_cmd = <<~EOM.strip
914
+ cd #{sut_pki_dir}/cacerts; \
915
+ for x in *; do \
916
+ if [ ! -h "$x" ]; then \
917
+ `openssl x509 -in $x >/dev/null 2>&1`; \
918
+ if [ $? -eq 0 ]; then \
919
+ hash=`openssl x509 -in $x -hash | head -1`; \
920
+ ln -sf $x $hash.0; \
921
+ fi; \
922
+ fi; \
923
+ done
924
+ EOM
807
925
 
808
926
  on(sut, hash_cmd)
809
927
  end
@@ -980,7 +1098,7 @@ done
980
1098
  # @returns [String] Path to the Hieradata directory on the target system
981
1099
  def hiera_datadir(sut)
982
1100
  # This output lets us know where Hiera is configured to look on the system
983
- puppet_lookup_info = on(sut, 'puppet lookup --explain test__simp__test').output.strip.lines
1101
+ puppet_lookup_info = on(sut, 'puppet lookup --explain test__simp__test', :silent => true).output.strip.lines
984
1102
 
985
1103
  if sut.puppet_configprint['manifest'].nil? || sut.puppet_configprint['manifest'].empty?
986
1104
  fail("No output returned from `puppet config print manifest` on #{sut}")
@@ -1218,13 +1336,12 @@ done
1218
1336
  def install_simp_repos(sut, disable = [])
1219
1337
  # NOTE: Do *NOT* use puppet in this method since it may not be available yet
1220
1338
 
1221
- if on(sut, 'rpm -q yum-utils', :accept_all_exit_codes => true).exit_code != 0
1222
- on(sut, 'yum -y install yum-utils')
1223
- end
1224
-
1225
- if on(sut, 'rpm -q simp-release-community', :accept_all_exit_codes => true).exit_code != 0
1226
- on(sut, 'yum -y install "https://download.simp-project.com/simp-release-community.rpm"')
1227
- end
1339
+ install_latest_package_on(sut, 'yum-utils')
1340
+ install_latest_package_on(
1341
+ sut,
1342
+ 'simp-release-community',
1343
+ "https://download.simp-project.com/simp-release-community.rpm",
1344
+ )
1228
1345
 
1229
1346
  to_disable = disable.dup
1230
1347
 
@@ -17,7 +17,11 @@ module Simp::BeakerHelpers
17
17
  require 'open-uri'
18
18
 
19
19
  begin
20
- ONLINE = true if open('http://google.com')
20
+ if URI.respond_to?(:open)
21
+ ONLINE = true if URI.open('http://google.com')
22
+ else
23
+ ONLINE = true if open('http://google.com')
24
+ end
21
25
  rescue
22
26
  ONLINE = false
23
27
  end
@@ -1,5 +1,5 @@
1
1
  module Simp; end
2
2
 
3
3
  module Simp::BeakerHelpers
4
- VERSION = '1.19.1'
4
+ VERSION = '1.21.2'
5
5
  end
@@ -6,21 +6,27 @@
6
6
  end
7
7
  -%>
8
8
  HOSTS:
9
- server-el7:
9
+ el7:
10
10
  roles:
11
- - server
12
- - master
13
- - default
14
11
  - el7
12
+ - master
15
13
  platform: el-7-x86_64
16
14
  box: centos/7
17
15
  hypervisor: <%= hypervisor %>
18
16
 
19
- server-el8:
17
+ el8:
18
+ roles:
19
+ - el8
20
+ platform: el-8-x86_64
21
+ box: centos/8
22
+ hypervisor: <%= hypervisor %>
23
+
24
+ el8-0:
20
25
  roles:
21
26
  - el8
22
27
  platform: el-8-x86_64
23
28
  box: centos/8
29
+ box_version: "1905.1"
24
30
  hypervisor: <%= hypervisor %>
25
31
 
26
32
  CONFIG:
@@ -30,3 +36,14 @@ CONFIG:
30
36
  <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
31
37
  puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
32
38
  <% end -%>
39
+ ssh:
40
+ keepalive: true
41
+ keepalive_interval: 10
42
+ host_key:
43
+ - <%= Net::SSH::Transport::Algorithms::ALGORITHMS[:host_key].join("\n#{' '*6}- ") %>
44
+ kex:
45
+ - <%= Net::SSH::Transport::Algorithms::ALGORITHMS[:kex].join("\n#{' '*6}- ") %>
46
+ encryption:
47
+ - <%= Net::SSH::Transport::Algorithms::ALGORITHMS[:encryption].join("\n#{' '*6}- ") %>
48
+ hmac:
49
+ - <%= Net::SSH::Transport::Algorithms::ALGORITHMS[:hmac].join("\n#{' '*6}- ") %>
@@ -0,0 +1,20 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ focal:
10
+ platform: ubuntu-20.04-x86_64
11
+ box: ubuntu/focal64
12
+ hypervisor: <%= hypervisor %>
13
+
14
+ CONFIG:
15
+ log_level: verbose
16
+ type: aio
17
+ vagrant_memsize: 256
18
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
19
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
20
+ <% end -%>
@@ -8,15 +8,33 @@ context 'after copy_fixture_modules_to( hosts )' do
8
8
 
9
9
  describe "fact_on(master,'root_home')" do
10
10
  it 'should not return value of `root_home`' do
11
- puts fact = fact_on(master, 'root_home')
12
- expect( fact ).to eq ''
11
+ expect(fact_on(master, 'root_home')).to eq ''
13
12
  end
14
13
  end
15
14
 
16
15
  describe "pfact_on(master,'root_home')" do
17
16
  it 'should return value of `root_home`' do
18
- puts fact = pfact_on(master, 'root_home')
19
- expect( fact ).to eq '/root'
17
+ expect(pfact_on(master, 'root_home')).to eq '/root'
18
+ end
19
+ end
20
+
21
+ describe "pfact_on(master,'os.release.major')" do
22
+ it 'should return the value of `os.release.major`' do
23
+ expect(pfact_on(master, 'os.release.major')).to match(/.+/)
24
+ end
25
+ end
26
+
27
+ describe "pfact_on(master,'os.release.foo')" do
28
+ it 'should not return the value of `os.release.foo`' do
29
+ expect(pfact_on(master, 'os.release.foo')).to eq ''
30
+ end
31
+ end
32
+
33
+ describe "pfact_on(master,'fips_enabled')" do
34
+ expected = (ENV['BEAKER_fips'] == 'yes')
35
+
36
+ it 'should return false' do
37
+ expect(pfact_on(master, 'fips_enabled')).to eq expected
20
38
  end
21
39
  end
22
40
  end
@@ -103,8 +103,21 @@ describe 'Simp::BeakerHelpers' do
103
103
  end
104
104
 
105
105
  it 'uses defaults when no environment variables are set' do
106
- expect( @helper.get_puppet_install_info[:puppet_install_version] ).to match(/^6\./)
107
- expect( @helper.get_puppet_install_info[:puppet_collection] ).to eq('puppet6')
106
+
107
+ # Prevent namespace pollution
108
+ pipe_out,pipe_in = IO.pipe
109
+ fork do
110
+ pipe_out.close
111
+ require 'puppet'
112
+ pipe_in.write(Puppet.version)
113
+ end
114
+ pipe_in.close
115
+
116
+ expected_version = pipe_out.gets
117
+ expected_major_version = expected_version.split('.').first
118
+
119
+ expect( @helper.get_puppet_install_info[:puppet_install_version] ).to match(expected_version)
120
+ expect( @helper.get_puppet_install_info[:puppet_collection] ).to eq("puppet#{expected_major_version}")
108
121
  expect( @helper.get_puppet_install_info[:puppet_install_type] ).to eq('agent')
109
122
  end
110
123
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simp-beaker-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.1
4
+ version: 1.21.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Tessmer
8
8
  - Trevor Vaughan
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-12-10 00:00:00.000000000 Z
12
+ date: 2021-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beaker
@@ -188,6 +188,7 @@ files:
188
188
  - lib/simp/rake/beaker.rb
189
189
  - simp-beaker-helpers.gemspec
190
190
  - spec/acceptance/nodesets/default.yml
191
+ - spec/acceptance/nodesets/ubuntu.yml
191
192
  - spec/acceptance/suites/default/check_puppet_version_spec.rb
192
193
  - spec/acceptance/suites/default/enable_fips_spec.rb
193
194
  - spec/acceptance/suites/default/fixture_modules_spec.rb
@@ -220,7 +221,7 @@ licenses:
220
221
  - Apache-2.0
221
222
  metadata:
222
223
  issue_tracker: https://simp-project.atlassian.net
223
- post_install_message:
224
+ post_install_message:
224
225
  rdoc_options: []
225
226
  require_paths:
226
227
  - lib
@@ -235,8 +236,37 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
236
  - !ruby/object:Gem::Version
236
237
  version: '0'
237
238
  requirements: []
238
- rubygems_version: 3.0.8
239
- signing_key:
239
+ rubygems_version: 3.0.9
240
+ signing_key:
240
241
  specification_version: 4
241
242
  summary: beaker helper methods for SIMP
242
- test_files: []
243
+ test_files:
244
+ - spec/acceptance/nodesets/default.yml
245
+ - spec/acceptance/nodesets/ubuntu.yml
246
+ - spec/acceptance/suites/default/check_puppet_version_spec.rb
247
+ - spec/acceptance/suites/default/enable_fips_spec.rb
248
+ - spec/acceptance/suites/default/fixture_modules_spec.rb
249
+ - spec/acceptance/suites/default/install_simp_deps_repo_spec.rb
250
+ - spec/acceptance/suites/default/nodesets
251
+ - spec/acceptance/suites/default/pki_tests_spec.rb
252
+ - spec/acceptance/suites/default/set_hieradata_on_spec.rb
253
+ - spec/acceptance/suites/default/write_hieradata_to_spec.rb
254
+ - spec/acceptance/suites/fips_from_fixtures/00_default_spec.rb
255
+ - spec/acceptance/suites/fips_from_fixtures/metadata.yml
256
+ - spec/acceptance/suites/fips_from_fixtures/nodesets
257
+ - spec/acceptance/suites/offline/00_default_spec.rb
258
+ - spec/acceptance/suites/offline/README
259
+ - spec/acceptance/suites/offline/nodesets/default.yml
260
+ - spec/acceptance/suites/puppet_collections/00_default_spec.rb
261
+ - spec/acceptance/suites/puppet_collections/metadata.yml
262
+ - spec/acceptance/suites/snapshot/00_snapshot_test_spec.rb
263
+ - spec/acceptance/suites/snapshot/10_general_usage_spec.rb
264
+ - spec/acceptance/suites/snapshot/nodesets
265
+ - spec/acceptance/suites/windows/00_default_spec.rb
266
+ - spec/acceptance/suites/windows/metadata.yml
267
+ - spec/acceptance/suites/windows/nodesets/default.yml
268
+ - spec/acceptance/suites/windows/nodesets/win2016.yml
269
+ - spec/acceptance/suites/windows/nodesets/win2019.yml
270
+ - spec/lib/simp/beaker_helpers_spec.rb
271
+ - spec/spec_helper.rb
272
+ - spec/spec_helper_acceptance.rb