simp-beaker-helpers 1.34.2 → 1.35.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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/pr_acceptance.yml +1 -1
  3. data/.github/workflows/pr_tests.yml +6 -7
  4. data/.rubocop.yml +652 -495
  5. data/CHANGELOG.md +8 -0
  6. data/Gemfile +5 -2
  7. data/lib/simp/beaker_helpers/constants.rb +7 -5
  8. data/lib/simp/beaker_helpers/inspec.rb +52 -55
  9. data/lib/simp/beaker_helpers/snapshot.rb +126 -134
  10. data/lib/simp/beaker_helpers/ssg.rb +33 -34
  11. data/lib/simp/beaker_helpers/version.rb +2 -1
  12. data/lib/simp/beaker_helpers/windows.rb +4 -1
  13. data/lib/simp/beaker_helpers.rb +281 -295
  14. data/lib/simp/rake/beaker.rb +174 -177
  15. data/spec/acceptance/suites/default/check_puppet_version_spec.rb +3 -3
  16. data/spec/acceptance/suites/default/fixture_modules_spec.rb +9 -9
  17. data/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb +7 -13
  18. data/spec/acceptance/suites/default/pki_tests_spec.rb +10 -16
  19. data/spec/acceptance/suites/fips_from_fixtures/00_default_spec.rb +4 -4
  20. data/spec/acceptance/suites/inspec/00_default_spec.rb +22 -22
  21. data/spec/acceptance/suites/offline/00_default_spec.rb +43 -12
  22. data/spec/acceptance/suites/offline/nodesets/default.yml +1 -3
  23. data/spec/acceptance/suites/puppet_collections/00_default_spec.rb +3 -3
  24. data/spec/acceptance/suites/snapshot/00_snapshot_test_spec.rb +27 -7
  25. data/spec/acceptance/suites/snapshot/10_general_usage_spec.rb +3 -3
  26. data/spec/acceptance/suites/ssg/00_default_spec.rb +20 -18
  27. data/spec/acceptance/suites/windows/00_default_spec.rb +47 -49
  28. data/spec/acceptance/suites/windows/nodesets/default.yml +3 -3
  29. data/spec/acceptance/suites/windows/nodesets/win2012.yml +3 -3
  30. data/spec/acceptance/suites/windows/nodesets/win2016.yml +3 -3
  31. data/spec/acceptance/suites/windows/nodesets/win2019.yml +3 -3
  32. data/spec/lib/simp/beaker_helpers_spec.rb +96 -66
  33. data/spec/spec_helper.rb +51 -53
  34. data/spec/spec_helper_acceptance.rb +17 -22
  35. metadata +5 -5
@@ -1,8 +1,11 @@
1
+ require 'English'
1
2
  require 'beaker-puppet'
2
3
  require 'bundler'
3
4
 
5
+ # SIMP namespace
4
6
  module Simp; end
5
7
 
8
+ # SIMP Beaker helper methods for testing
6
9
  module Simp::BeakerHelpers
7
10
  include BeakerPuppet
8
11
 
@@ -17,8 +20,8 @@ module Simp::BeakerHelpers
17
20
 
18
21
  # Stealing this from the Ruby 2.5 Dir::Tmpname workaround from Rails
19
22
  def self.tmpname
20
- t = Time.new.strftime("%Y%m%d")
21
- "simp-beaker-helpers-#{t}-#{$$}-#{rand(0x100000000).to_s(36)}.tmp"
23
+ t = Time.new.strftime('%Y%m%d')
24
+ "simp-beaker-helpers-#{t}-#{$PROCESS_ID}-#{rand(0x100000000).to_s(36)}.tmp"
22
25
  end
23
26
 
24
27
  # Sets a single YUM option in the form that yum-config-manager/dnf
@@ -28,8 +31,8 @@ module Simp::BeakerHelpers
28
31
  #
29
32
  # Has no effect if yum or dnf is not present.
30
33
  def set_yum_opt_on(suts, key, value)
31
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
32
- repo,target = key.split('.')
34
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
35
+ repo, target = key.split('.')
33
36
 
34
37
  unless target
35
38
  key = "\\*.#{repo}"
@@ -37,13 +40,13 @@ module Simp::BeakerHelpers
37
40
 
38
41
  command = nil
39
42
  if !sut.which('dnf').empty?
40
- install_package_unless_present_on(sut, 'dnf-plugins-core', :accept_all_exit_codes => true)
43
+ install_package_unless_present_on(sut, 'dnf-plugins-core', accept_all_exit_codes: true)
41
44
  command = 'dnf config-manager'
42
45
  elsif !sut.which('yum').empty?
43
46
  command = 'yum-config-manager'
44
47
  end
45
48
 
46
- on(sut, %{#{command} --save --setopt=#{key}=#{value}}, :silent => true) if command
49
+ on(sut, %(#{command} --save --setopt=#{key}=#{value}), silent: true) if command
47
50
  end
48
51
  end
49
52
 
@@ -57,21 +60,21 @@ module Simp::BeakerHelpers
57
60
  # 'skip_if_unavailable' => '1', # Applies globally
58
61
  # 'foo.installonly_limit' => '5' # Applies only to the 'foo' repo
59
62
  # }
60
- def set_yum_opts_on(suts, yum_opts={})
61
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
62
- yum_opts.each_pair do |k,v|
63
+ def set_yum_opts_on(suts, yum_opts = {})
64
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
65
+ yum_opts.each_pair do |k, v|
63
66
  set_yum_opt_on(sut, k, v)
64
67
  end
65
68
  end
66
69
  end
67
70
 
68
- def install_package_unless_present_on(suts, package_name, package_source=nil, opts={})
71
+ def install_package_unless_present_on(suts, package_name, package_source = nil, opts = {})
69
72
  default_opts = {
70
73
  max_retries: 3,
71
74
  retry_interval: 10
72
75
  }
73
76
 
74
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
77
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
75
78
  package_source = package_name unless package_source
76
79
 
77
80
  unless sut.check_for_package(package_name)
@@ -79,26 +82,26 @@ module Simp::BeakerHelpers
79
82
  package_source,
80
83
  '',
81
84
  nil,
82
- default_opts.merge(opts)
85
+ default_opts.merge(opts),
83
86
  )
84
87
  end
85
88
  end
86
89
  end
87
90
 
88
- def install_latest_package_on(suts, package_name, package_source=nil, opts={})
91
+ def install_latest_package_on(suts, package_name, package_source = nil, opts = {})
89
92
  default_opts = {
90
93
  max_retries: 3,
91
94
  retry_interval: 10
92
95
  }
93
96
 
94
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
97
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
95
98
  package_source = package_name unless package_source
96
99
 
97
100
  if sut.check_for_package(package_name)
98
101
  sut.upgrade_package(
99
102
  package_source,
100
103
  '',
101
- default_opts.merge(opts)
104
+ default_opts.merge(opts),
102
105
  )
103
106
  else
104
107
  install_package_unless_present_on(sut, package_name, package_source, opts)
@@ -107,20 +110,19 @@ module Simp::BeakerHelpers
107
110
  end
108
111
 
109
112
  def is_windows?(sut)
110
- sut[:platform] =~ /windows/i
113
+ sut[:platform] =~ %r{windows}i
111
114
  end
112
115
 
113
116
  # We can't cache this because it may change during a run
114
117
  def fips_enabled(sut)
115
- return on( sut,
118
+ on(sut,
116
119
  'cat /proc/sys/crypto/fips_enabled 2>/dev/null',
117
- :accept_all_exit_codes => true
118
- ).output.strip == '1'
120
+ accept_all_exit_codes: true).output.strip == '1'
119
121
  end
120
122
 
121
123
  def rsync_functional_on?(sut)
122
124
  # We have to check if rsync *still* works otherwise
123
- return false if (@rsync_functional == false)
125
+ return false if @rsync_functional == false
124
126
 
125
127
  require 'facter'
126
128
  unless Facter::Util::Resolution.which('rsync')
@@ -143,38 +145,38 @@ module Simp::BeakerHelpers
143
145
  testfile.unlink
144
146
  end
145
147
 
146
- return true
148
+ true
147
149
  end
148
150
 
149
151
  # Figure out the best method to copy files to a host and use it
150
152
  #
151
153
  # Will create the directories leading up to the target if they don't exist
152
- def copy_to(sut, src, dest, opts={})
154
+ def copy_to(sut, src, dest, opts = {})
153
155
  sut.mkdir_p(File.dirname(dest))
154
156
 
155
157
  if sut[:hypervisor] == 'docker'
156
158
  exclude_list = []
157
159
  opts[:silent] ||= true
158
160
 
159
- if opts.has_key?(:ignore) && !opts[:ignore].empty?
161
+ if opts.key?(:ignore) && !opts[:ignore].empty?
160
162
  opts[:ignore].each do |value|
161
163
  exclude_list << "--exclude '#{value}'"
162
164
  end
163
165
  end
164
166
 
165
167
  # Work around for breaking changes in beaker-docker
166
- if sut.host_hash[:docker_container]
167
- container_id = sut.host_hash[:docker_container].id
168
- else
169
- container_id = sut.host_hash[:docker_container_id]
170
- end
168
+ container_id = if sut.host_hash[:docker_container]
169
+ sut.host_hash[:docker_container].id
170
+ else
171
+ sut.host_hash[:docker_container_id]
172
+ end
171
173
 
172
174
  if ENV['BEAKER_docker_cmd']
173
175
  docker_cmd = ENV['BEAKER_docker_cmd']
174
176
  else
175
177
  docker_cmd = 'docker'
176
178
 
177
- if ::Docker.version['Components'].any?{|x| x['Name'] =~ /podman/i}
179
+ if ::Docker.version['Components'].any? { |x| x['Name'] =~ %r{podman}i }
178
180
  docker_cmd = 'podman'
179
181
 
180
182
  if ENV['CONTAINER_HOST']
@@ -187,16 +189,16 @@ module Simp::BeakerHelpers
187
189
 
188
190
  sut.mkdir_p(File.dirname(dest)) unless directory_exists_on(sut, dest)
189
191
 
190
- if File.file?(src)
191
- cmd = %{#{docker_cmd} cp "#{src}" "#{container_id}:#{dest}"}
192
- else
193
- cmd = [
194
- %{tar #{exclude_list.join(' ')} -hcf - -C "#{File.dirname(src)}" "#{File.basename(src)}"},
195
- %{#{docker_cmd} exec -i "#{container_id}" tar -C "#{dest}" -xf -}
196
- ].join(' | ')
197
- end
192
+ cmd = if File.file?(src)
193
+ %(#{docker_cmd} cp "#{src}" "#{container_id}:#{dest}")
194
+ else
195
+ [
196
+ %(tar #{exclude_list.join(' ')} -hcf - -C "#{File.dirname(src)}" "#{File.basename(src)}"),
197
+ %(#{docker_cmd} exec -i "#{container_id}" tar -C "#{dest}" -xf -),
198
+ ].join(' | ')
199
+ end
198
200
 
199
- %x(#{cmd})
201
+ `#{cmd}`
200
202
  elsif rsync_functional_on?(sut)
201
203
  # This makes rsync_to work like beaker and scp usually do
202
204
  exclude_hack = %(__-__' -L --exclude '__-__)
@@ -204,9 +206,9 @@ module Simp::BeakerHelpers
204
206
  # There appears to be a single copy of 'opts' that gets passed around
205
207
  # through all of the different hosts so we're going to make a local deep
206
208
  # copy so that we don't destroy the world accidentally.
207
- _opts = Marshal.load(Marshal.dump(opts))
208
- _opts[:ignore] ||= []
209
- _opts[:ignore] << exclude_hack
209
+ local_opts = Marshal.load(Marshal.dump(opts))
210
+ local_opts[:ignore] ||= []
211
+ local_opts[:ignore] << exclude_hack
210
212
 
211
213
  if File.directory?(src)
212
214
  dest = File.join(dest, File.basename(src)) if File.directory?(src)
@@ -216,7 +218,7 @@ module Simp::BeakerHelpers
216
218
  # End rsync hackery
217
219
 
218
220
  begin
219
- rsync_to(sut, src, dest, _opts)
221
+ rsync_to(sut, src, dest, local_opts)
220
222
  rescue
221
223
  # Depending on what is getting tested, a new SSH session might not
222
224
  # work. In this case, we fall back to SSH.
@@ -237,21 +239,20 @@ module Simp::BeakerHelpers
237
239
  if sut.which('puppet').empty?
238
240
  found_fact = fact_on(sut, fact_name)
239
241
  else
240
- facts_json = nil
241
242
  begin
242
- cmd_output = on(sut, 'facter -p --json', :silent => true)
243
+ cmd_output = on(sut, 'facter -p --json', silent: true)
243
244
  # Facter 4+
244
- raise('skip facter -p') if (cmd_output.stderr =~ /no longer supported/)
245
+ raise('skip facter -p') if cmd_output.stderr.include?('no longer supported')
245
246
 
246
247
  facts = JSON.parse(cmd_output.stdout)
247
248
  rescue StandardError
248
249
  # If *anything* fails, we need to fall back to `puppet facts`
249
250
 
250
- facts_json = retry_on(sut, 'puppet facts find garbage_xxx', :silent => true, :max_retries => 4).stdout
251
+ facts_json = retry_on(sut, 'puppet facts find garbage_xxx', silent: true, max_retries: 4).stdout
251
252
  facts = JSON.parse(facts_json)['values']
252
253
  end
253
254
 
254
- found_fact = facts.dig(*(fact_name.split('.')))
255
+ found_fact = facts.dig(*fact_name.split('.'))
255
256
 
256
257
  # If we did not find a fact, we should use the upstream function since
257
258
  # puppet may be installed via a gem or through some other means.
@@ -264,7 +265,7 @@ module Simp::BeakerHelpers
264
265
  end
265
266
 
266
267
  # Returns the modulepath on the SUT, as an Array
267
- def puppet_modulepath_on(sut, environment='production')
268
+ def puppet_modulepath_on(sut, _environment = 'production')
268
269
  splitchar = ':'
269
270
  splitchar = ';' if is_windows?(sut)
270
271
 
@@ -275,7 +276,7 @@ module Simp::BeakerHelpers
275
276
  end
276
277
 
277
278
  # Return the default environment path
278
- def puppet_environment_path_on(sut, environment='production')
279
+ def puppet_environment_path_on(sut, _environment = 'production')
279
280
  File.dirname(sut.puppet_configprint['manifest'])
280
281
  end
281
282
 
@@ -289,12 +290,9 @@ module Simp::BeakerHelpers
289
290
 
290
291
  dir = File.join(File.expand_path(dir), 'fixtures')
291
292
 
292
- if File.directory?(dir)
293
- @fixtures_path = dir
294
- return @fixtures_path
295
- else
296
- raise("Could not find fixtures directory at '#{dir}'")
297
- end
293
+ raise("Could not find fixtures directory at '#{dir}'") unless File.directory?(dir)
294
+ @fixtures_path = dir
295
+ @fixtures_path
298
296
  end
299
297
 
300
298
  # Locates .fixture.yml in or above this directory.
@@ -308,8 +306,8 @@ module Simp::BeakerHelpers
308
306
  else
309
307
  fixtures_yml = ''
310
308
  dir = '.'
311
- while( fixtures_yml.empty? && File.expand_path(dir) != '/' ) do
312
- file = File.expand_path( '.fixtures.yml', dir )
309
+ while fixtures_yml.empty? && File.expand_path(dir) != '/'
310
+ file = File.expand_path('.fixtures.yml', dir)
313
311
  STDERR.puts " ** fixtures_yml_path: #{file}" if ENV['BEAKER_helpers_verbose']
314
312
  if File.exist? file
315
313
  fixtures_yml = file
@@ -325,62 +323,59 @@ module Simp::BeakerHelpers
325
323
 
326
324
  @fixtures_yml_path = fixtures_yml
327
325
 
328
- return @fixtures_yml_path
326
+ @fixtures_yml_path
329
327
  end
330
328
 
331
-
332
329
  # returns an Array of puppet modules declared in .fixtures.yml
333
330
  def pupmods_in_fixtures_yml
334
331
  return @pupmods_in_fixtures_yml if @pupmods_in_fixtures_yml
335
332
 
336
333
  STDERR.puts ' ** pupmods_in_fixtures_yml' if ENV['BEAKER_helpers_verbose']
337
334
  fixtures_yml = fixtures_yml_path
338
- data = YAML.load_file( fixtures_yml )
335
+ data = YAML.load_file(fixtures_yml)
339
336
  repos = data.fetch('fixtures').fetch('repositories', {}).keys || []
340
337
  symlinks = data.fetch('fixtures').fetch('symlinks', {}).keys || []
341
338
  STDERR.puts ' ** pupmods_in_fixtures_yml: finished' if ENV['BEAKER_helpers_verbose']
342
339
 
343
340
  @pupmods_in_fixtures_yml = (repos + symlinks)
344
341
 
345
- return @pupmods_in_fixtures_yml
342
+ @pupmods_in_fixtures_yml
346
343
  end
347
344
 
348
-
349
345
  # Ensures that the fixture modules (under `spec/fixtures/modules`) exists.
350
346
  # if any fixture modules are missing, run 'rake spec_prep' to populate the
351
347
  # fixtures/modules
352
348
  def ensure_fixture_modules
353
- STDERR.puts " ** ensure_fixture_modules" if ENV['BEAKER_helpers_verbose']
349
+ STDERR.puts ' ** ensure_fixture_modules' if ENV['BEAKER_helpers_verbose']
354
350
  unless ENV['BEAKER_spec_prep'] == 'no'
355
- puts "== checking prepped modules from .fixtures.yml"
356
- puts " -- (use BEAKER_spec_prep=no to disable)"
351
+ puts '== checking prepped modules from .fixtures.yml'
352
+ puts ' -- (use BEAKER_spec_prep=no to disable)'
357
353
  missing_modules = []
358
354
  pupmods_in_fixtures_yml.each do |pupmod|
359
355
  STDERR.puts " ** -- ensure_fixture_modules: '#{pupmod}'" if ENV['BEAKER_helpers_verbose']
360
- mod_root = File.expand_path( "spec/fixtures/modules/#{pupmod}", File.dirname( fixtures_yml_path ))
356
+ mod_root = File.expand_path("spec/fixtures/modules/#{pupmod}", File.dirname(fixtures_yml_path))
361
357
  missing_modules << pupmod unless File.directory? mod_root
362
358
  end
363
359
  puts " -- #{missing_modules.size} modules need to be prepped"
364
- unless missing_modules.empty?
360
+ if missing_modules.empty?
361
+ puts ' == all fixture modules present'
362
+ else
365
363
  cmd = 'bundle exec rake spec_prep'
366
364
  puts " -- running spec_prep: '#{cmd}'"
367
- %x(#{cmd})
368
- else
369
- puts " == all fixture modules present"
365
+ `#{cmd}`
370
366
  end
371
367
  end
372
- STDERR.puts " ** -- ensure_fixture_modules: finished" if ENV['BEAKER_helpers_verbose']
368
+ STDERR.puts ' ** -- ensure_fixture_modules: finished' if ENV['BEAKER_helpers_verbose']
373
369
  end
374
370
 
375
-
376
371
  # Copy the local fixture modules (under `spec/fixtures/modules`) onto each SUT
377
- def copy_fixture_modules_to( suts = hosts, opts = {})
372
+ def copy_fixture_modules_to(suts = hosts, opts = {})
378
373
  ensure_fixture_modules
379
374
 
380
375
  opts[:pluginsync] = opts.fetch(:pluginsync, true)
381
376
 
382
377
  unless ENV['BEAKER_copy_fixtures'] == 'no'
383
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
378
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
384
379
  STDERR.puts " ** copy_fixture_modules_to: '#{sut}'" if ENV['BEAKER_helpers_verbose']
385
380
 
386
381
  # Use spec_prep to provide modules (this supports isolated networks)
@@ -392,7 +387,7 @@ module Simp::BeakerHelpers
392
387
  # `modulepath` and targets the first one.
393
388
  target_module_path = puppet_modulepath_on(sut).first
394
389
 
395
- mod_root = File.expand_path( "spec/fixtures/modules", File.dirname( fixtures_yml_path ))
390
+ mod_root = File.expand_path('spec/fixtures/modules', File.dirname(fixtures_yml_path))
396
391
 
397
392
  Dir.chdir(mod_root) do
398
393
  # Have to do things the slow way on Windows
@@ -440,17 +435,14 @@ module Simp::BeakerHelpers
440
435
  begin
441
436
  tarfile = "#{Simp::BeakerHelpers.tmpname}.tar"
442
437
 
443
- excludes = (PUPPET_MODULE_INSTALL_IGNORE + ['spec']).map do |x|
444
- x = "--exclude '*/#{x}'"
445
- end.join(' ')
438
+ excludes = (PUPPET_MODULE_INSTALL_IGNORE + ['spec']).map { |x|
439
+ "--exclude '*/#{x}'"
440
+ }.join(' ')
446
441
 
447
- %x(tar -ch #{excludes} -f #{tarfile} *)
442
+ `tar -ch #{excludes} -f #{tarfile} *`
448
443
 
449
- if File.exist?(tarfile)
450
- copy_to(sut, tarfile, target_module_path, opts)
451
- else
452
- fail("Error: module tar file '#{tarfile}' could not be created at #{mod_root}")
453
- end
444
+ raise("Error: module tar file '#{tarfile}' could not be created at #{mod_root}") unless File.exist?(tarfile)
445
+ copy_to(sut, tarfile, target_module_path, opts)
454
446
 
455
447
  on(sut, "cd #{target_module_path} && tar -xf #{File.basename(tarfile)}")
456
448
  ensure
@@ -471,14 +463,20 @@ module Simp::BeakerHelpers
471
463
  file_exists_on(sut, '/etc/crypto-policies/config')
472
464
  end
473
465
 
474
- def munge_ssh_crypto_policies(suts, key_types=['ssh-rsa'])
475
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
466
+ def munge_ssh_crypto_policies(suts, key_types = ['ssh-rsa'])
467
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
476
468
  if has_crypto_policies(sut)
477
- install_latest_package_on(sut, 'crypto-policies', nil, :accept_all_exit_codes => true)
469
+ install_latest_package_on(sut, 'crypto-policies', nil, accept_all_exit_codes: true)
478
470
 
479
471
  # Since we may be doing this prior to having a box flip into FIPS mode, we
480
472
  # need to find and modify *all* of the affected policies
481
- 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 {} \\; ) ) })
473
+ on(
474
+ sut,
475
+ [
476
+ %{sed --follow-symlinks -i 's/\\(HostKeyAlgorithms\\|PubkeyAcceptedKeyTypes\\)\\(.\\)/\\1\\2#{key_types.join(',')},/g'},
477
+ "$( grep -L ssh-rsa $( find /etc/crypto-policies /usr/share/crypto-policies -type f -a \\( -name '*.txt' -o -name '*.config' \\) -exec grep -l PubkeyAcceptedKeyTypes {} \\; ) )",
478
+ ].join(' '),
479
+ )
482
480
  end
483
481
  end
484
482
  end
@@ -486,14 +484,14 @@ module Simp::BeakerHelpers
486
484
  # Perform the equivalend of an in-place sed without changing the target inode
487
485
  #
488
486
  # Required for many container targets
489
- def safe_sed(suts = hosts, pattern, target_file)
490
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
487
+ def safe_sed(suts = hosts, pattern, target_file) # rubocop:disable Style/OptionalArguments
488
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
491
489
  tmpfile = sut.tmpfile('safe_sed')
492
490
 
493
491
  command = [
494
492
  "cp #{target_file} #{tmpfile}",
495
493
  "sed -i '#{pattern}' #{tmpfile}",
496
- "cat #{tmpfile} > #{target_file}"
494
+ "cat #{tmpfile} > #{target_file}",
497
495
  ].join(' && ')
498
496
 
499
497
  on(sut, command)
@@ -503,11 +501,11 @@ module Simp::BeakerHelpers
503
501
  end
504
502
 
505
503
  # Configure and reboot SUTs into FIPS mode
506
- def enable_fips_mode_on( suts = hosts )
504
+ def enable_fips_mode_on(suts = hosts)
507
505
  puts '== configuring FIPS mode on SUTs'
508
506
  puts ' -- (use BEAKER_fips=no to disable)'
509
507
 
510
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
508
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
511
509
  next if sut[:hypervisor] == 'docker'
512
510
 
513
511
  if is_windows?(sut)
@@ -527,7 +525,7 @@ module Simp::BeakerHelpers
527
525
  # TODO Use simp-ssh Puppet module appropriately (i.e., in a fashion
528
526
  # that doesn't break vagrant access and is appropriate for
529
527
  # typical module tests.)
530
- fips_ssh_ciphers = [ 'aes256-ctr','aes192-ctr','aes128-ctr']
528
+ fips_ssh_ciphers = [ 'aes256-ctr', 'aes192-ctr', 'aes128-ctr']
531
529
  safe_sed(sut, '/Ciphers /d', '/etc/ssh/sshd_config')
532
530
  on(sut, %(echo 'Ciphers #{fips_ssh_ciphers.join(',')}' >> /etc/ssh/sshd_config))
533
531
 
@@ -579,19 +577,17 @@ module Simp::BeakerHelpers
579
577
  # gpgkeys:
580
578
  # - <URL to GPGKEY1>
581
579
  # - <URL to GPGKEY2>
582
- def enable_yum_repos_on( suts = hosts )
583
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
584
- if sut['yum_repos']
585
- sut['yum_repos'].each_pair do |repo, metadata|
586
- repo_manifest = create_yum_resource(repo, metadata)
580
+ def enable_yum_repos_on(suts = hosts)
581
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
582
+ sut['yum_repos']&.each_pair do |repo, metadata|
583
+ repo_manifest = create_yum_resource(repo, metadata)
587
584
 
588
- apply_manifest_on(sut, repo_manifest, :catch_failures => true)
589
- end
585
+ apply_manifest_on(sut, repo_manifest, catch_failures: true)
590
586
  end
591
587
  end
592
588
  end
593
589
 
594
- def create_yum_resource( repo, metadata )
590
+ def create_yum_resource(repo, metadata)
595
591
  repo_attrs = [
596
592
  :assumeyes,
597
593
  :bandwidth,
@@ -629,46 +625,46 @@ module Simp::BeakerHelpers
629
625
  :sslverify,
630
626
  :target,
631
627
  :throttle,
632
- :timeout
628
+ :timeout,
633
629
  ]
634
630
 
635
- repo_manifest = %(yumrepo { #{repo}:)
631
+ repo_manifest = %(yumrepo { #{repo}:)
636
632
 
637
- repo_manifest_opts = []
633
+ repo_manifest_opts = []
638
634
 
639
- # Legacy Support
640
- urls = !metadata[:url].nil? ? metadata[:url] : metadata[:baseurl]
641
- if urls
642
- repo_manifest_opts << 'baseurl => ' + '"' + Array(urls).flatten.join('\n ').gsub('$','\$') + '"'
643
- end
635
+ # Legacy Support
636
+ urls = (!metadata[:url].nil?) ? metadata[:url] : metadata[:baseurl]
637
+ if urls
638
+ repo_manifest_opts << 'baseurl => ' + '"' + Array(urls).flatten.join('\n ').gsub('$', '\$') + '"'
639
+ end
644
640
 
645
- # Legacy Support
646
- gpgkeys = !metadata[:gpgkeys].nil? ? metadata[:gpgkeys] : metadata[:gpgkey]
647
- if gpgkeys
648
- repo_manifest_opts << 'gpgkey => ' + '"' + Array(gpgkeys).flatten.join('\n ').gsub('$','\$') + '"'
649
- end
641
+ # Legacy Support
642
+ gpgkeys = (!metadata[:gpgkeys].nil?) ? metadata[:gpgkeys] : metadata[:gpgkey]
643
+ if gpgkeys
644
+ repo_manifest_opts << 'gpgkey => ' + '"' + Array(gpgkeys).flatten.join('\n ').gsub('$', '\$') + '"'
645
+ end
650
646
 
651
- repo_attrs.each do |attr|
652
- if metadata[attr]
653
- repo_manifest_opts << "#{attr} => '#{metadata[attr]}'"
654
- end
647
+ repo_attrs.each do |attr|
648
+ if metadata[attr]
649
+ repo_manifest_opts << "#{attr} => '#{metadata[attr]}'"
655
650
  end
651
+ end
656
652
 
657
- repo_manifest = repo_manifest + %(\n#{repo_manifest_opts.join(",\n")}) + "\n}\n"
653
+ repo_manifest + %(\n#{repo_manifest_opts.join(",\n")}) + "\n}\n"
658
654
  end
659
655
 
660
656
  # Enable EPEL if appropriate to do so and the system is online
661
657
  #
662
658
  # Can be disabled by setting BEAKER_enable_epel=no
663
659
  def enable_epel_on(suts)
664
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
660
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
665
661
  if ONLINE
666
662
  os_info = fact_on(sut, 'os')
667
663
  os_maj_rel = os_info['release']['major']
668
664
 
669
665
  # This is based on the official EPEL docs https://fedoraproject.org/wiki/EPEL
670
666
  case os_info['name']
671
- when 'RedHat','CentOS','AlmaLinux','Rocky'
667
+ when 'RedHat', 'CentOS', 'AlmaLinux', 'Rocky'
672
668
  install_latest_package_on(
673
669
  sut,
674
670
  'epel-release',
@@ -677,42 +673,42 @@ module Simp::BeakerHelpers
677
673
 
678
674
  if os_info['name'] == 'RedHat' && ENV['BEAKER_RHSM_USER'] && ENV['BEAKER_RHSM_PASS']
679
675
  if os_maj_rel == '7'
680
- on sut, %{subscription-manager repos --enable "rhel-*-extras-rpms"}
681
- on sut, %{subscription-manager repos --enable "rhel-ha-for-rhel-*-server-rpms"}
676
+ on sut, %(subscription-manager repos --enable "rhel-*-extras-rpms")
677
+ on sut, %(subscription-manager repos --enable "rhel-ha-for-rhel-*-server-rpms")
682
678
  end
683
679
 
684
680
  if os_maj_rel == '8'
685
- on sut, %{subscription-manager repos --enable "codeready-builder-for-rhel-8-#{os_info['architecture']}-rpms"}
681
+ on sut, %(subscription-manager repos --enable "codeready-builder-for-rhel-8-#{os_info['architecture']}-rpms")
686
682
  end
687
683
  end
688
684
 
689
- if ['CentOS','AlmaLinux','Rocky'].include?(os_info['name'])
685
+ if ['CentOS', 'AlmaLinux', 'Rocky'].include?(os_info['name'])
690
686
  if os_maj_rel == '8'
691
687
  # 8.0 fallback
692
688
  install_latest_package_on(sut, 'dnf-plugins-core')
693
- on sut, %{dnf config-manager --set-enabled powertools || dnf config-manager --set-enabled PowerTools}
689
+ on sut, %(dnf config-manager --set-enabled powertools || dnf config-manager --set-enabled PowerTools)
694
690
  end
695
691
  end
696
692
  when 'OracleLinux'
697
693
  package_name = "oracle-epel-release-el#{os_maj_rel}"
698
- install_latest_package_on(sut,package_name)
694
+ install_latest_package_on(sut, package_name)
699
695
  when 'Amazon'
700
- on sut, %{amazon-linux-extras install epel -y}
696
+ on sut, %(amazon-linux-extras install epel -y)
701
697
  end
702
698
  end
703
699
  end
704
700
  end
705
701
 
706
702
  def update_package_from_centos_stream(suts, package_name)
707
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
703
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
708
704
  sut.install_package('centos-release-stream') unless sut.check_for_package('centos-release-stream')
709
705
  install_latest_package_on(sut, package_name)
710
706
  sut.uninstall_package('centos-release-stream')
711
707
  end
712
708
  end
713
709
 
714
- def linux_errata( suts )
715
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
710
+ def linux_errata(suts)
711
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
716
712
  # Set the locale if not set
717
713
  sut.set_env_var('LANG', 'en_US.UTF-8') unless sut.get_env_var('LANG')
718
714
 
@@ -729,13 +725,13 @@ module Simp::BeakerHelpers
729
725
  if current_domain.nil? || current_domain.empty?
730
726
  new_fqdn = hostname + '.beaker.test'
731
727
 
732
- safe_sed(sut, "s/#{hostname}.*/#{new_fqdn} #{hostname}/", '/etc/hosts')
728
+ safe_sed(suts, "s/#{hostname}.*/#{new_fqdn} #{hostname}/", '/etc/hosts')
733
729
 
734
730
  if !sut.which('hostnamectl').empty?
735
731
  on(sut, "hostnamectl set-hostname #{new_fqdn}")
736
732
  else
737
- on(sut, "echo '#{new_fqdn}' > /etc/hostname", :accept_all_exit_codes => true)
738
- on(sut, "hostname #{new_fqdn}", :accept_all_exit_codes => true)
733
+ on(sut, "echo '#{new_fqdn}' > /etc/hostname", accept_all_exit_codes: true)
734
+ on(sut, "hostname #{new_fqdn}", accept_all_exit_codes: true)
739
735
  end
740
736
 
741
737
  if sut.file_exist?('/etc/sysconfig/network')
@@ -745,7 +741,7 @@ module Simp::BeakerHelpers
745
741
  end
746
742
 
747
743
  current_domain = fact_on(sut, 'networking.domain')&.strip
748
- fail("Error: hosts must have an FQDN, got domain='#{current_domain}'") if current_domain.nil? || current_domain.empty?
744
+ raise("Error: hosts must have an FQDN, got domain='#{current_domain}'") if current_domain.nil? || current_domain.empty?
749
745
 
750
746
  # This may not exist in docker so just skip the whole thing
751
747
  if sut.file_exist?('/etc/ssh')
@@ -767,15 +763,15 @@ module Simp::BeakerHelpers
767
763
  user_info.map do |u|
768
764
  u.strip!
769
765
  u = u.split(':')
770
- u[5] =~ %r{^(/|/dev/.*|/s?bin/?.*|/proc/?.*)$} ? [nil] : [u[0], u[5]]
766
+ %r{^(/|/dev/.*|/s?bin/?.*|/proc/?.*)$}.match?(u[5]) ? [nil] : [u[0], u[5]]
771
767
  end
772
768
  ]
773
769
 
774
- user_info.keys.each do |user|
770
+ user_info.each_key do |user|
775
771
  src_file = "#{user_info[user]}/.ssh/authorized_keys"
776
772
  tgt_file = "/etc/ssh/local_keys/#{user}"
777
773
 
778
- on(sut, %{if [ -f "#{src_file}" ]; then cp -a -f "#{src_file}" "#{tgt_file}" && chmod 644 "#{tgt_file}"; fi}, :silent => true)
774
+ on(sut, %(if [ -f "#{src_file}" ]; then cp -a -f "#{src_file}" "#{tgt_file}" && chmod 644 "#{tgt_file}"; fi), silent: true)
779
775
  end
780
776
  end
781
777
 
@@ -807,22 +803,22 @@ module Simp::BeakerHelpers
807
803
  end
808
804
 
809
805
  if [
810
- 'AlmaLinux',
811
- 'Amazon',
812
- 'CentOS',
813
- 'OracleLinux',
814
- 'RedHat',
815
- 'Rocky'
806
+ 'AlmaLinux',
807
+ 'Amazon',
808
+ 'CentOS',
809
+ 'OracleLinux',
810
+ 'RedHat',
811
+ 'Rocky',
816
812
  ].include?(os_info['name'])
817
813
  enable_yum_repos_on(sut)
818
814
  enable_epel_on(sut)
819
815
 
820
816
  # net-tools required for netstat utility being used by be_listening
821
- if (os_info['release']['major'].to_i >= 7) ||((os_info['name'] == 'Amazon') && (os_info['release']['major'].to_i >= 2))
817
+ if (os_info['release']['major'].to_i >= 7) || ((os_info['name'] == 'Amazon') && (os_info['release']['major'].to_i >= 2))
822
818
  pp = <<-EOS
823
819
  package { 'net-tools': ensure => installed }
824
820
  EOS
825
- apply_manifest_on(sut, pp, :catch_failures => false)
821
+ apply_manifest_on(sut, pp, catch_failures: false)
826
822
  end
827
823
 
828
824
  # Clean up YUM prior to starting our test runs.
@@ -839,30 +835,30 @@ module Simp::BeakerHelpers
839
835
  def rhel_rhsm_subscribe(suts, *opts)
840
836
  require 'securerandom'
841
837
 
842
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
838
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
843
839
  rhsm_opts = {
844
- :username => ENV['BEAKER_RHSM_USER'],
845
- :password => ENV['BEAKER_RHSM_PASS'],
846
- :system_name => "#{sut}_beaker_#{Time.now.to_i}_#{SecureRandom.uuid}",
847
- :repo_list => {
840
+ username: ENV['BEAKER_RHSM_USER'],
841
+ password: ENV['BEAKER_RHSM_PASS'],
842
+ system_name: "#{sut}_beaker_#{Time.now.to_i}_#{SecureRandom.uuid}",
843
+ repo_list: {
848
844
  '7' => [
849
845
  'rhel-7-server-extras-rpms',
850
846
  'rhel-7-server-rh-common-rpms',
851
847
  'rhel-7-server-rpms',
852
- 'rhel-7-server-supplementary-rpms'
848
+ 'rhel-7-server-supplementary-rpms',
853
849
  ],
854
850
  '8' => [
855
851
  'rhel-8-for-x86_64-baseos-rpms',
856
- 'rhel-8-for-x86_64-supplementary-rpms'
852
+ 'rhel-8-for-x86_64-supplementary-rpms',
857
853
  ],
858
854
  '9' => [
859
855
  'rhel-9-for-x86_64-appstream-rpms',
860
- 'rhel-9-for-x86_64-baseos-rpms'
856
+ 'rhel-9-for-x86_64-baseos-rpms',
861
857
  ]
862
858
  }
863
859
  }
864
860
 
865
- if opts && opts.is_a?(Hash)
861
+ if opts&.is_a?(Hash)
866
862
  rhsm_opts.merge!(opts)
867
863
  end
868
864
 
@@ -871,14 +867,14 @@ module Simp::BeakerHelpers
871
867
 
872
868
  if os == 'RedHat'
873
869
  unless rhsm_opts[:username] && rhsm_opts[:password]
874
- warn("BEAKER_RHSM_USER and/or BEAKER_RHSM_PASS not set on RHEL system.", "Assuming that subscription-manager is not needed. This may prevent packages from installing")
870
+ warn('BEAKER_RHSM_USER and/or BEAKER_RHSM_PASS not set on RHEL system.', 'Assuming that subscription-manager is not needed. This may prevent packages from installing')
875
871
  return
876
872
  end
877
873
 
878
- sub_status = on(sut, 'subscription-manager status', :accept_all_exit_codes => true)
874
+ sub_status = on(sut, 'subscription-manager status', accept_all_exit_codes: true)
879
875
  unless sub_status.exit_code == 0
880
876
  logger.info("Registering #{sut} via subscription-manager")
881
- on(sut, %{subscription-manager register --auto-attach --name='#{rhsm_opts[:system_name]}' --username='#{rhsm_opts[:username]}' --password='#{rhsm_opts[:password]}'}, :silent => true)
877
+ on(sut, %(subscription-manager register --auto-attach --name='#{rhsm_opts[:system_name]}' --username='#{rhsm_opts[:username]}' --password='#{rhsm_opts[:password]}'), silent: true)
882
878
  end
883
879
 
884
880
  if rhsm_opts[:repo_list][os_release]
@@ -889,17 +885,17 @@ module Simp::BeakerHelpers
889
885
 
890
886
  # Ensure that all users can access the entitlements since we don't know
891
887
  # who we'll be running jobs as (often not root)
892
- on(sut, 'chmod -R ugo+rX /etc/pki/entitlement', :accept_all_exit_codes => true)
888
+ on(sut, 'chmod -R ugo+rX /etc/pki/entitlement', accept_all_exit_codes: true)
893
889
  end
894
890
  end
895
891
  end
896
892
 
897
- def sosreport(suts, dest='sosreports')
898
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
893
+ def sosreport(suts, dest = 'sosreports')
894
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
899
895
  install_latest_package_on(sut, 'sos')
900
896
  on(sut, 'sosreport --batch')
901
897
 
902
- files = on(sut, 'ls /var/tmp/sosreport* /tmp/sosreport* 2>/dev/null', :accept_all_exit_codes => true).output.lines.map(&:strip)
898
+ files = on(sut, 'ls /var/tmp/sosreport* /tmp/sosreport* 2>/dev/null', accept_all_exit_codes: true).output.lines.map(&:strip)
903
899
 
904
900
  FileUtils.mkdir_p(dest)
905
901
 
@@ -910,37 +906,39 @@ module Simp::BeakerHelpers
910
906
  end
911
907
 
912
908
  def rhel_repo_enable(suts, repos)
913
- if ENV['BEAKER_RHSM_USER'] && ENV['BEAKER_RHSM_PASS']
914
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
915
- Array(repos).each do |repo|
916
- on(sut, %{subscription-manager repos --enable #{repo}})
917
- end
909
+ return unless ENV['BEAKER_RHSM_USER'] && ENV['BEAKER_RHSM_PASS']
910
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
911
+ Array(repos).each do |repo|
912
+ on(sut, %(subscription-manager repos --enable #{repo}))
918
913
  end
919
914
  end
920
915
  end
921
916
 
922
917
  def rhel_repo_disable(suts, repos)
923
- if ENV['BEAKER_RHSM_USER'] && ENV['BEAKER_RHSM_PASS']
924
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
925
- Array(repos).each do |repo|
926
- on(sut, %{subscription-manager repos --disable #{repo}}, :accept_all_exit_codes => true)
927
- end
918
+ return unless ENV['BEAKER_RHSM_USER'] && ENV['BEAKER_RHSM_PASS']
919
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
920
+ Array(repos).each do |repo|
921
+ on(sut, %(subscription-manager repos --disable #{repo}), accept_all_exit_codes: true)
928
922
  end
929
923
  end
930
924
  end
931
925
 
932
926
  def rhel_rhsm_unsubscribe(suts)
933
- if ENV['BEAKER_RHSM_USER'] && ENV['BEAKER_RHSM_PASS']
934
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
935
- on(sut, %{subscription-manager unregister}, :accept_all_exit_codes => true)
936
- end
927
+ return unless ENV['BEAKER_RHSM_USER'] && ENV['BEAKER_RHSM_PASS']
928
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
929
+ on(sut, %(subscription-manager unregister), accept_all_exit_codes: true)
937
930
  end
938
931
  end
939
932
 
940
933
  # Apply known OS fixes we need to run Beaker on each SUT
941
- def fix_errata_on( suts = hosts )
942
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
943
- if is_windows?(sut)
934
+ def fix_errata_on(suts = hosts)
935
+ windows_suts = suts.select { |sut| is_windows?(sut) }
936
+ linux_suts = suts - windows_suts
937
+
938
+ linux_errata(linux_suts) unless linux_suts.empty?
939
+
940
+ unless windows_suts.empty?
941
+ block_on(windows_suts, run_in_parallel: @run_in_parallel) do |sut|
944
942
  # Load the Windows requirements
945
943
  require 'simp/beaker_helpers/windows'
946
944
 
@@ -971,15 +969,12 @@ module Simp::BeakerHelpers
971
969
  EOM
972
970
 
973
971
  install_cert_on_windows(sut, 'geotrustglobal', geotrust_global_ca)
974
- else
975
- linux_errata(sut)
976
972
  end
977
973
  end
978
974
 
979
975
  # Configure and reboot SUTs into FIPS mode
980
- if ENV['BEAKER_fips'] == 'yes'
981
- enable_fips_mode_on(suts)
982
- end
976
+ return unless ENV['BEAKER_fips'] == 'yes'
977
+ enable_fips_mode_on(suts)
983
978
  end
984
979
 
985
980
  # Generate a fake openssl CA + certs for each host on a given SUT
@@ -989,13 +984,13 @@ module Simp::BeakerHelpers
989
984
  # NOTE: This generates everything within an SUT and copies it back out.
990
985
  # This is because it is assumed the SUT will have the appropriate
991
986
  # openssl in its environment, which may not be true of the host.
992
- def run_fake_pki_ca_on( ca_sut = master, suts = hosts, local_dir = '' )
993
- puts "== Fake PKI CA"
994
- pki_dir = File.expand_path( "../../files/pki", File.dirname(__FILE__))
987
+ def run_fake_pki_ca_on(ca_sut = master, _suts = hosts, local_dir = '')
988
+ puts '== Fake PKI CA'
989
+ pki_dir = File.expand_path('../../files/pki', File.dirname(__FILE__))
995
990
  host_dir = '/root/pki'
996
991
 
997
992
  ca_sut.mkdir_p(host_dir)
998
- Dir[ File.join(pki_dir, '*') ].each{|f| copy_to( ca_sut, f, host_dir)}
993
+ Dir[ File.join(pki_dir, '*') ].each { |f| copy_to(ca_sut, f, host_dir) }
999
994
 
1000
995
  # Collect network information from all SUTs
1001
996
  #
@@ -1008,14 +1003,14 @@ module Simp::BeakerHelpers
1008
1003
  host_entry = { fqdn => [] }
1009
1004
 
1010
1005
  # Add the short name because containers can't change the hostname
1011
- host_entry[fqdn] << host.name if (host[:hypervisor] == 'docker')
1006
+ host_entry[fqdn] << host.name if host[:hypervisor] == 'docker'
1012
1007
 
1013
1008
  # Ensure that all interfaces are active prior to collecting data
1014
1009
  activate_interfaces(host)
1015
1010
 
1016
1011
  networking_fact = pfact_on(host, 'networking')
1017
1012
  if networking_fact && networking_fact['interfaces']
1018
- networking_fact['interfaces'].each do |iface, data|
1013
+ networking_fact['interfaces'].each_value do |data|
1019
1014
  next unless data['ip']
1020
1015
  next if data['ip'].start_with?('127.')
1021
1016
 
@@ -1046,10 +1041,10 @@ module Simp::BeakerHelpers
1046
1041
  # 3. Pull out an Array of all of the common element keys for future
1047
1042
  # comparison
1048
1043
  common_ip_addresses = suts_network_info
1049
- .values.flatten
1050
- .group_by{ |x| x }
1051
- .select{|k,v| v.size > 1}
1052
- .keys
1044
+ .values.flatten
1045
+ .group_by { |x| x }
1046
+ .select { |_k, v| v.size > 1 }
1047
+ .keys
1053
1048
 
1054
1049
  # generate PKI certs for each SUT
1055
1050
  Dir.mktmpdir do |dir|
@@ -1068,10 +1063,9 @@ module Simp::BeakerHelpers
1068
1063
  end
1069
1064
 
1070
1065
  # if a local_dir was provided, copy everything down to it
1071
- unless local_dir.empty?
1072
- FileUtils.mkdir_p local_dir
1073
- scp_from( ca_sut, host_dir, local_dir )
1074
- end
1066
+ return if local_dir.empty?
1067
+ FileUtils.mkdir_p local_dir
1068
+ scp_from(ca_sut, host_dir, local_dir)
1075
1069
  end
1076
1070
 
1077
1071
  # Copy a single SUT's PKI certs (with cacerts) onto an SUT.
@@ -1089,26 +1083,26 @@ module Simp::BeakerHelpers
1089
1083
  # public/fdqn.pub
1090
1084
  # private/fdqn.pem
1091
1085
  def copy_pki_to(sut, local_pki_dir, sut_base_dir = '/etc/pki/simp-testing')
1092
- fqdn = fact_on(sut, 'networking.fqdn')
1093
- sut_pki_dir = File.join( sut_base_dir, 'pki' )
1094
- local_host_pki_tree = File.join(local_pki_dir,'pki','keydist',fqdn)
1095
- local_cacert = File.join(local_pki_dir,'pki','demoCA','cacert.pem')
1096
-
1097
- sut.mkdir_p("#{sut_pki_dir}/public")
1098
- sut.mkdir_p("#{sut_pki_dir}/private")
1099
- sut.mkdir_p("#{sut_pki_dir}/cacerts")
1100
- copy_to(sut, "#{local_host_pki_tree}/#{fqdn}.pem", "#{sut_pki_dir}/private/")
1101
- copy_to(sut, "#{local_host_pki_tree}/#{fqdn}.pub", "#{sut_pki_dir}/public/")
1102
-
1103
- copy_to(sut, local_cacert, "#{sut_pki_dir}/cacerts/simp_auto_ca.pem")
1104
-
1105
- # NOTE: to match pki::copy, 'cacert.pem' is copied to 'cacerts.pem'
1106
- copy_to(sut, local_cacert, "#{sut_pki_dir}/cacerts/cacerts.pem")
1107
-
1108
- # Need to hash all of the CA certificates so that apps can use them
1109
- # properly! This must happen on the host itself since it needs to match
1110
- # the native hashing algorithms.
1111
- hash_cmd = <<~EOM.strip
1086
+ fqdn = fact_on(sut, 'networking.fqdn')
1087
+ sut_pki_dir = File.join(sut_base_dir, 'pki')
1088
+ local_host_pki_tree = File.join(local_pki_dir, 'pki', 'keydist', fqdn)
1089
+ local_cacert = File.join(local_pki_dir, 'pki', 'demoCA', 'cacert.pem')
1090
+
1091
+ sut.mkdir_p("#{sut_pki_dir}/public")
1092
+ sut.mkdir_p("#{sut_pki_dir}/private")
1093
+ sut.mkdir_p("#{sut_pki_dir}/cacerts")
1094
+ copy_to(sut, "#{local_host_pki_tree}/#{fqdn}.pem", "#{sut_pki_dir}/private/")
1095
+ copy_to(sut, "#{local_host_pki_tree}/#{fqdn}.pub", "#{sut_pki_dir}/public/")
1096
+
1097
+ copy_to(sut, local_cacert, "#{sut_pki_dir}/cacerts/simp_auto_ca.pem")
1098
+
1099
+ # NOTE: to match pki::copy, 'cacert.pem' is copied to 'cacerts.pem'
1100
+ copy_to(sut, local_cacert, "#{sut_pki_dir}/cacerts/cacerts.pem")
1101
+
1102
+ # Need to hash all of the CA certificates so that apps can use them
1103
+ # properly! This must happen on the host itself since it needs to match
1104
+ # the native hashing algorithms.
1105
+ hash_cmd = <<~EOM.strip
1112
1106
  PATH=/opt/puppetlabs/puppet/bin:$PATH; \
1113
1107
  cd #{sut_pki_dir}/cacerts; \
1114
1108
  for x in *; do \
@@ -1122,14 +1116,14 @@ module Simp::BeakerHelpers
1122
1116
  done
1123
1117
  EOM
1124
1118
 
1125
- on(sut, hash_cmd)
1119
+ on(sut, hash_cmd)
1126
1120
  end
1127
1121
 
1128
1122
  # Copy a CA keydist/ directory of CA+host certs into an SUT
1129
1123
  #
1130
1124
  # This simulates the output of FakeCA's gencerts_nopass.sh to keydist/
1131
- def copy_keydist_to( ca_sut = master, host_keydist_dir = nil )
1132
- if !host_keydist_dir
1125
+ def copy_keydist_to(ca_sut = master, host_keydist_dir = nil)
1126
+ unless host_keydist_dir
1133
1127
  modulepath = puppet_modulepath_on(ca_sut)
1134
1128
 
1135
1129
  host_keydist_dir = "#{modulepath.first}/pki/files/keydist"
@@ -1149,8 +1143,8 @@ module Simp::BeakerHelpers
1149
1143
  def activate_interfaces(hosts)
1150
1144
  return if ENV['BEAKER_no_fix_interfaces']
1151
1145
 
1152
- block_on(hosts, :run_in_parallel => @run_in_parallel) do |host|
1153
- if host[:platform] =~ /windows/
1146
+ block_on(hosts, run_in_parallel: @run_in_parallel) do |host|
1147
+ if host[:platform].include?('windows')
1154
1148
  puts " -- SKIPPING #{host} because it is windows"
1155
1149
  next
1156
1150
  end
@@ -1158,18 +1152,18 @@ module Simp::BeakerHelpers
1158
1152
  networking_fact = pfact_on(host, 'networking')
1159
1153
  if networking_fact && networking_fact['interfaces']
1160
1154
  networking_fact['interfaces'].each do |iface, data|
1161
- next if ( ( data['ip'] && !data['ip'].empty? ) || ( data['ip6'] && !data['ip6'].empty? ) )
1162
- on(host, "ifup #{iface}", :accept_all_exit_codes => true)
1155
+ next if (data['ip'] && !data['ip'].empty?) || (data['ip6'] && !data['ip6'].empty?)
1156
+ on(host, "ifup #{iface}", accept_all_exit_codes: true)
1163
1157
  end
1164
1158
  else
1165
1159
  interfaces_fact = pfact_on(host, 'interfaces')
1166
1160
 
1167
1161
  interfaces = interfaces_fact.strip.split(',')
1168
- interfaces.delete_if { |x| x =~ /^lo/ }
1162
+ interfaces.delete_if { |x| x =~ %r{^lo} }
1169
1163
 
1170
1164
  interfaces.each do |iface|
1171
1165
  if pfact_on(host, "ipaddress_#{iface}")
1172
- on(host, "ifup #{iface}", :accept_all_exit_codes => true)
1166
+ on(host, "ifup #{iface}", accept_all_exit_codes: true)
1173
1167
  end
1174
1168
  end
1175
1169
  end
@@ -1186,7 +1180,7 @@ module Simp::BeakerHelpers
1186
1180
  require 'rspec'
1187
1181
  RSpec.configure do |c|
1188
1182
  c.before(:all) do
1189
- @temp_hieradata_dirs = @temp_hieradata_dirs || []
1183
+ @temp_hieradata_dirs ||= []
1190
1184
 
1191
1185
  # We can't guarantee that the upstream vendor isn't disabling interfaces
1192
1186
  activate_interfaces(hosts)
@@ -1204,18 +1198,18 @@ module Simp::BeakerHelpers
1204
1198
  # @param trim [Boolean] remove leading and trailing whitespace
1205
1199
  #
1206
1200
  # @return [String, nil] the contents of the remote file
1207
- def file_content_on(sut, path, trim=true)
1201
+ def file_content_on(sut, path, _trim = true)
1208
1202
  file_content = nil
1209
1203
 
1210
1204
  if file_exists_on(sut, path)
1211
1205
  Dir.mktmpdir do |dir|
1212
1206
  scp_from(sut, path, dir)
1213
1207
 
1214
- file_content = File.read(File.join(dir,File.basename(path)))
1208
+ file_content = File.read(File.join(dir, File.basename(path)))
1215
1209
  end
1216
1210
  end
1217
1211
 
1218
- return file_content
1212
+ file_content
1219
1213
  end
1220
1214
 
1221
1215
  # Retrieve the default hiera.yaml path
@@ -1267,7 +1261,7 @@ module Simp::BeakerHelpers
1267
1261
  # using `#clear_temp_hieradata` in the `after(:all)` hook. It may also be
1268
1262
  # retained for debugging purposes.
1269
1263
  #
1270
- def write_hieradata_to(sut, hieradata, terminus = 'deprecated')
1264
+ def write_hieradata_to(sut, hieradata, _terminus = 'deprecated')
1271
1265
  @temp_hieradata_dirs ||= []
1272
1266
  data_dir = Dir.mktmpdir('hieradata')
1273
1267
  @temp_hieradata_dirs << data_dir
@@ -1305,20 +1299,20 @@ module Simp::BeakerHelpers
1305
1299
  sut_environment = sut.puppet_configprint['environment']
1306
1300
 
1307
1301
  # This output lets us know where Hiera is configured to look on the system
1308
- puppet_lookup_info = on(sut, "puppet lookup --explain --environment #{sut_environment} test__simp__test", :silent => true).output.strip.lines
1302
+ puppet_lookup_info = on(sut, "puppet lookup --explain --environment #{sut_environment} test__simp__test", silent: true).output.strip.lines
1309
1303
 
1310
1304
  if sut.puppet_configprint['manifest'].nil? || sut.puppet_configprint['manifest'].empty?
1311
- fail("No output returned from `puppet config print manifest` on #{sut}")
1305
+ raise("No output returned from `puppet config print manifest` on #{sut}")
1312
1306
  end
1313
1307
 
1314
1308
  puppet_env_path = puppet_environment_path_on(sut)
1315
1309
 
1316
1310
  # We'll just take the first match since Hiera will find things there
1317
- puppet_lookup_info = puppet_lookup_info.grep(/Path "/).grep(Regexp.new(puppet_env_path))
1311
+ puppet_lookup_info = puppet_lookup_info.grep(%r{Path "}).grep(Regexp.new(puppet_env_path))
1318
1312
 
1319
1313
  # Grep always returns an Array
1320
1314
  if puppet_lookup_info.empty?
1321
- fail("Could not determine hiera data directory under #{puppet_env_path} on #{sut}")
1315
+ raise("Could not determine hiera data directory under #{puppet_env_path} on #{sut}")
1322
1316
  end
1323
1317
 
1324
1318
  # Snag the actual path without the extra bits
@@ -1340,7 +1334,7 @@ module Simp::BeakerHelpers
1340
1334
  datadir_path = puppet_env_path + file_sep + datadir_name
1341
1335
 
1342
1336
  # Return the path to the data directory
1343
- return datadir_path
1337
+ datadir_path
1344
1338
  end
1345
1339
 
1346
1340
  # Write the provided data structure to Hiera's :datadir and configure Hiera to
@@ -1360,29 +1354,26 @@ module Simp::BeakerHelpers
1360
1354
  #
1361
1355
  # @return [Nil]
1362
1356
  #
1363
- def set_hieradata_on(sut, hieradata, terminus = 'deprecated')
1357
+ def set_hieradata_on(sut, hieradata, _terminus = 'deprecated')
1364
1358
  write_hieradata_to sut, hieradata
1365
1359
  end
1366
1360
 
1367
-
1368
1361
  # Clean up all temporary hiera data files.
1369
1362
  #
1370
1363
  # Meant to be called from after(:all)
1371
1364
  def clear_temp_hieradata
1372
- if @temp_hieradata_dirs && !@temp_hieradata_dirs.empty?
1373
- @temp_hieradata_dirs.each do |data_dir|
1374
- if File.exist?(data_dir)
1375
- FileUtils.rm_r(data_dir)
1376
- end
1365
+ return unless @temp_hieradata_dirs && !@temp_hieradata_dirs.empty?
1366
+ @temp_hieradata_dirs.each do |data_dir|
1367
+ if File.exist?(data_dir)
1368
+ FileUtils.rm_r(data_dir)
1377
1369
  end
1378
1370
  end
1379
1371
  end
1380
1372
 
1381
-
1382
1373
  # pluginsync custom facts for all modules
1383
- def pluginsync_on( suts = hosts )
1374
+ def pluginsync_on(_suts = hosts)
1384
1375
  puts "== pluginsync_on'" if ENV['BEAKER_helpers_verbose']
1385
- pluginsync_manifest =<<-PLUGINSYNC_MANIFEST
1376
+ pluginsync_manifest = <<-PLUGINSYNC_MANIFEST
1386
1377
  file { $::settings::libdir:
1387
1378
  ensure => directory,
1388
1379
  source => 'puppet:///plugins',
@@ -1392,10 +1383,9 @@ module Simp::BeakerHelpers
1392
1383
  noop => false
1393
1384
  }
1394
1385
  PLUGINSYNC_MANIFEST
1395
- apply_manifest_on(hosts, pluginsync_manifest, :run_in_parallel => @run_in_parallel)
1386
+ apply_manifest_on(hosts, pluginsync_manifest, run_in_parallel: @run_in_parallel)
1396
1387
  end
1397
1388
 
1398
-
1399
1389
  # Looks up latest `puppet-agent` version by the version of its `puppet` gem
1400
1390
  #
1401
1391
  # @param puppet_version [String] target Puppet gem version. Works with
@@ -1403,58 +1393,58 @@ module Simp::BeakerHelpers
1403
1393
  #
1404
1394
  # @return [String,Nil] the `puppet-agent` version or nil
1405
1395
  #
1406
- def latest_puppet_agent_version_for( puppet_version )
1396
+ def latest_puppet_agent_version_for(puppet_version)
1407
1397
  return nil if puppet_version.nil?
1408
1398
 
1409
1399
  require 'rubygems/requirement'
1410
1400
  require 'rubygems/version'
1411
1401
  require 'yaml'
1412
1402
 
1413
- _puppet_version = puppet_version.strip.split(',')
1414
-
1403
+ split_puppet_version = puppet_version.strip.split(',')
1415
1404
 
1416
1405
  @agent_version_table ||= YAML.load_file(
1417
1406
  File.expand_path(
1418
1407
  '../../files/puppet-agent-versions.yaml',
1419
- File.dirname(__FILE__)
1420
- )).fetch('version_mappings')
1421
- _pair = @agent_version_table.find do |k,v|
1422
- Gem::Requirement.new(_puppet_version).satisfied_by?(Gem::Version.new(k))
1408
+ File.dirname(__FILE__),
1409
+ ),
1410
+ ).fetch('version_mappings')
1411
+ pair = @agent_version_table.find do |k, _v|
1412
+ Gem::Requirement.new(split_puppet_version).satisfied_by?(Gem::Version.new(k))
1423
1413
  end
1424
- result = _pair ? _pair.last : nil
1414
+ result = pair&.last
1425
1415
 
1426
1416
  # If we didn't get a match, go look for published rubygems
1427
1417
  unless result
1428
1418
  puppet_gems = nil
1429
1419
 
1430
1420
  Bundler.with_unbundled_env do
1431
- puppet_gems = %x(gem search -ra -e puppet).match(/\((.+)\)/)
1421
+ puppet_gems = `gem search -ra -e puppet`.match(%r{\((.+)\)})
1432
1422
  end
1433
1423
 
1434
1424
  if puppet_gems
1435
- puppet_gems = puppet_gems[1].split(/,?\s+/).select{|x| x =~ /^\d/}
1425
+ puppet_gems = puppet_gems[1].split(%r{,?\s+}).select { |x| x =~ %r{^\d} }
1436
1426
 
1437
1427
  # If we don't have a full version string, we need to massage it for the
1438
1428
  # match.
1439
1429
  begin
1440
- if _puppet_version.size == 1
1441
- Gem::Version.new(_puppet_version[0])
1442
- if _puppet_version[0].count('.') < 2
1443
- _puppet_version = "~> #{_puppet_version[0]}"
1430
+ if split_puppet_version.size == 1
1431
+ Gem::Version.new(split_puppet_version[0])
1432
+ if split_puppet_version[0].count('.') < 2
1433
+ split_puppet_version = "~> #{split_puppet_version[0]}"
1444
1434
  end
1445
1435
  end
1446
1436
  rescue ArgumentError
1447
- # this means _puppet_version is not just a version, but a version
1437
+ # this means split_puppet_version is not just a version, but a version
1448
1438
  # specifier such as "= 5.2.3", "<= 5.1", "> 4", "~> 4.10.7"
1449
1439
  end
1450
1440
 
1451
1441
  result = puppet_gems.find do |ver|
1452
- Gem::Requirement.new(_puppet_version).satisfied_by?(Gem::Version.new(ver))
1442
+ Gem::Requirement.new(split_puppet_version).satisfied_by?(Gem::Version.new(ver))
1453
1443
  end
1454
1444
  end
1455
1445
  end
1456
1446
 
1457
- return result
1447
+ result
1458
1448
  end
1459
1449
 
1460
1450
  # returns hash with :puppet_install_version, :puppet_collection,
@@ -1471,18 +1461,16 @@ module Simp::BeakerHelpers
1471
1461
  # The first match is internal Beaker and the second is legacy SIMP
1472
1462
  puppet_install_version = ENV['BEAKER_PUPPET_AGENT_VERSION'] || ENV['PUPPET_INSTALL_VERSION'] || ENV['PUPPET_VERSION']
1473
1463
 
1474
- if puppet_install_version and !puppet_install_version.strip.empty?
1464
+ if puppet_install_version && !puppet_install_version.strip.empty?
1475
1465
  puppet_agent_version = latest_puppet_agent_version_for(puppet_install_version.strip)
1476
1466
  end
1477
1467
 
1478
1468
  if puppet_agent_version.nil?
1479
- if puppet_collection = (ENV['BEAKER_PUPPET_COLLECTION'] || host.options['puppet_collection'])
1480
- if puppet_collection =~ /puppet(\d+)/
1481
- puppet_install_version = "~> #{$1}"
1482
- puppet_agent_version = latest_puppet_agent_version_for(puppet_install_version)
1483
- else
1484
- raise("Error: Puppet Collection '#{puppet_collection}' must match /puppet(\\d+)/")
1485
- end
1469
+ if (puppet_collection = ENV['BEAKER_PUPPET_COLLECTION'] || host.options['puppet_collection'])
1470
+ raise("Error: Puppet Collection '#{puppet_collection}' must match /puppet(\\d+)/") unless puppet_collection =~ %r{puppet(\d+)}
1471
+ puppet_install_version = "~> #{::Regexp.last_match(1)}"
1472
+ puppet_agent_version = latest_puppet_agent_version_for(puppet_install_version)
1473
+
1486
1474
  else
1487
1475
  puppet_agent_version = latest_puppet_agent_version_for(DEFAULT_PUPPET_AGENT_VERSION)
1488
1476
  end
@@ -1494,13 +1482,12 @@ module Simp::BeakerHelpers
1494
1482
  end
1495
1483
 
1496
1484
  {
1497
- :puppet_install_version => puppet_agent_version,
1498
- :puppet_collection => puppet_collection,
1499
- :puppet_install_type => ENV.fetch('PUPPET_INSTALL_TYPE', 'agent')
1485
+ puppet_install_version: puppet_agent_version,
1486
+ puppet_collection: puppet_collection,
1487
+ puppet_install_type: ENV.fetch('PUPPET_INSTALL_TYPE', 'agent')
1500
1488
  }
1501
1489
  end
1502
1490
 
1503
-
1504
1491
  # Replacement for `install_puppet` in spec_helper_acceptance.rb
1505
1492
  def install_puppet
1506
1493
  install_info = get_puppet_install_info
@@ -1547,27 +1534,27 @@ module Simp::BeakerHelpers
1547
1534
  def install_simp_repos(suts, disable = [])
1548
1535
  # NOTE: Do *NOT* use puppet in this method since it may not be available yet
1549
1536
 
1550
- return if (ENV.fetch('SIMP_install_repos', 'yes') == 'no')
1537
+ return if ENV.fetch('SIMP_install_repos', 'yes') == 'no'
1551
1538
 
1552
- block_on(suts, :run_in_parallel => @run_in_parallel) do |sut|
1539
+ block_on(suts, run_in_parallel: @run_in_parallel) do |sut|
1553
1540
  install_package_unless_present_on(sut, 'yum-utils')
1554
1541
 
1555
1542
  os = fact_on(sut, 'os.name')
1556
1543
  release = fact_on(sut, 'os.release.major')
1557
1544
 
1558
1545
  # Work around Amazon 2 compatibility
1559
- if (( os == 'Amazon' ) && ( "#{release}" == '2' ))
1546
+ if (os == 'Amazon') && (release.to_s == '2')
1560
1547
  release = '7'
1561
1548
  end
1562
1549
 
1563
1550
  install_package_unless_present_on(
1564
1551
  sut,
1565
1552
  'simp-release-community',
1566
- "https://download.simp-project.com/simp-release-community.el#{release}.rpm"
1553
+ "https://download.simp-project.com/simp-release-community.el#{release}.rpm",
1567
1554
  )
1568
1555
 
1569
1556
  # TODO: Remove this hack-around when there's a version for AL2
1570
- if ( os == 'Amazon' )
1557
+ if os == 'Amazon'
1571
1558
  on(sut, %(sed -i 's/$releasever/#{release}/g' /etc/yum.repos.d/simp*))
1572
1559
  end
1573
1560
 
@@ -1600,7 +1587,7 @@ module Simp::BeakerHelpers
1600
1587
  to_disable << 'puppet6--simp'
1601
1588
  end
1602
1589
 
1603
- logger.info(%{INFO: repos to disable: '#{to_disable.join("', '")}'.})
1590
+ logger.info(%(INFO: repos to disable: '#{to_disable.join("', '")}'.))
1604
1591
 
1605
1592
  # NOTE: This --enablerepo enables the repos for listing and is inherited
1606
1593
  # from YUM. This does not actually "enable" the repos, that would require
@@ -1608,26 +1595,25 @@ module Simp::BeakerHelpers
1608
1595
  #
1609
1596
  # Note: Certain versions of EL8 do not dump by default and EL7 does not
1610
1597
  # have the '--dump' option.
1611
- x = on(sut, %{yum repolist all || dnf repolist --all}).stdout.lines
1612
- y = x.map{|z| z.gsub(%r{/.*\Z},'')}
1613
- available_repos = y.grep(/\A([a-zA-Z][a-zA-Z0-9:_-]+)\s*/){|x| $1}
1614
- logger.info(%{INFO: available repos: '#{available_repos.join("', '")}'.})
1598
+ x = on(sut, %(yum repolist all || dnf repolist --all)).stdout.lines
1599
+ y = x.map { |z| z.gsub(%r{/.*\Z}, '') }
1600
+ available_repos = y.grep(%r{\A([a-zA-Z][a-zA-Z0-9:_-]+)\s*}) { |_x| ::Regexp.last_match(1) }
1601
+ logger.info(%(INFO: available repos: '#{available_repos.join("', '")}'.))
1615
1602
 
1616
1603
  invalid_repos = (to_disable - available_repos)
1617
1604
 
1618
1605
  # Verify that the repos passed to disable are in the list of valid repos
1619
1606
  unless invalid_repos.empty?
1620
- logger.warn(%{WARN: install_simp_repo - requested repos to disable do not exist on the target system '#{invalid_repos.join("', '")}'.})
1607
+ logger.warn(%(WARN: install_simp_repo - requested repos to disable do not exist on the target system '#{invalid_repos.join("', '")}'.))
1621
1608
  end
1622
1609
 
1623
-
1624
1610
  (to_disable - invalid_repos).each do |repo|
1625
- on(sut, %{yum-config-manager --disable "#{repo}"})
1611
+ on(sut, %(yum-config-manager --disable "#{repo}"))
1626
1612
  end
1627
1613
  end
1628
1614
  end
1629
1615
 
1630
- set_yum_opts_on(suts, {'simp*.skip_if_unavailable' => '1' })
1616
+ set_yum_opts_on(suts, { 'simp*.skip_if_unavailable' => '1' })
1631
1617
  end
1632
1618
 
1633
1619
  # Set the release and release type of the SIMP yum repos
@@ -1635,11 +1621,11 @@ module Simp::BeakerHelpers
1635
1621
  # Environment variables may be used to set either one
1636
1622
  # * BEAKER_SIMP_repo_release => The actual release (version number)
1637
1623
  # * BEAKER_SIMP_repo_release_type => The type of release (stable, unstable, rolling, etc...)
1638
- def set_simp_repo_release(sut, simp_release_type='stable', simp_release='6')
1624
+ def set_simp_repo_release(sut, simp_release_type = 'stable', simp_release = '6')
1639
1625
  simp_release = ENV.fetch('BEAKER_SIMP_repo_release', simp_release)
1640
1626
  simp_release_type = ENV.fetch('BEAKER_SIMP_repo_release_type', simp_release_type)
1641
1627
 
1642
- simp_release_type = 'releases' if (simp_release_type == 'stable')
1628
+ simp_release_type = 'releases' if simp_release_type == 'stable'
1643
1629
 
1644
1630
  create_remote_file(sut, '/etc/yum/vars/simprelease', simp_release)
1645
1631
  create_remote_file(sut, '/etc/yum/vars/simpreleasetype', simp_release_type)