simp-beaker-helpers 1.21.4 → 1.23.3

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/.fips_fixtures +1 -0
  3. data/.fixtures.yml +6 -1
  4. data/.github/workflows.local.json +6 -0
  5. data/.github/workflows/pr_acceptance.yml +55 -0
  6. data/.github/workflows/pr_glci.yml +190 -0
  7. data/.github/workflows/pr_glci_cleanup.yml +105 -0
  8. data/.github/workflows/pr_glci_manual.yml +143 -0
  9. data/.github/workflows/pr_tests.yml +90 -0
  10. data/.github/workflows/tag_deploy_rubygem.yml +192 -0
  11. data/.gitlab-ci.yml +37 -37
  12. data/CHANGELOG.md +55 -0
  13. data/Gemfile +1 -1
  14. data/README.md +63 -5
  15. data/lib/simp/beaker_helpers.rb +165 -68
  16. data/lib/simp/beaker_helpers/inspec.rb +16 -12
  17. data/lib/simp/beaker_helpers/ssg.rb +48 -13
  18. data/lib/simp/beaker_helpers/version.rb +1 -1
  19. data/lib/simp/rake/beaker.rb +14 -2
  20. data/simp-beaker-helpers.gemspec +2 -1
  21. data/spec/acceptance/nodesets/default.yml +1 -1
  22. data/spec/acceptance/nodesets/docker.yml +12 -10
  23. data/spec/acceptance/suites/default/enable_fips_spec.rb +6 -4
  24. data/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb +17 -5
  25. data/spec/acceptance/suites/fips_from_fixtures/00_default_spec.rb +11 -3
  26. data/spec/acceptance/suites/inspec/00_default_spec.rb +54 -0
  27. data/spec/acceptance/suites/inspec/metadata.yml +2 -0
  28. data/spec/acceptance/suites/inspec/nodesets +1 -0
  29. data/spec/acceptance/suites/puppet_collections/00_default_spec.rb +1 -1
  30. data/spec/acceptance/suites/ssg/00_default_spec.rb +40 -0
  31. data/spec/acceptance/suites/ssg/metadata.yml +2 -0
  32. data/spec/acceptance/suites/ssg/nodesets +1 -0
  33. data/spec/lib/simp/beaker_helpers_spec.rb +1 -3
  34. metadata +53 -39
  35. data/.travis.yml +0 -42
data/CHANGELOG.md CHANGED
@@ -1,3 +1,58 @@
1
+ ### 1.23.3 / 2021-06-30
2
+ * Fixed:
3
+ * Removed the Streams kernel update for EL 8.3 since it now causes issues
4
+ * Use `pfact_on` to select the interface facts to fix Puppet 7 issues
5
+
6
+ ### 1.23.2 / 2021-05-29
7
+ * Fixed:
8
+ * Fail an acceptance test when an explicitly-specified nodeset for an
9
+ acceptance test suite does not exist and the suite is configured
10
+ to fail fast (default behavior).
11
+ * The usual way of registering RHEL systems had to be changed to activate
12
+ immediately when called to function properly.
13
+
14
+ ### 1.23.1 / 2021-05-19
15
+ * Fixed:
16
+ * The SSG default branch is now the latest numeric tag instead of the one
17
+ closest to the head of the default branch. The tag closest to the default
18
+ branch has drifted over time.
19
+ * Removed direct call to `docker` when copying out inspec results
20
+ * Typos in `copy_in` when running against docker
21
+ * Added:
22
+ * `Simp::BeakerHelpers::Inspec.enable_repo_on(suts)` to allow users to easily
23
+ enable the Chef repos for inspec
24
+ * Beaker tests for inspec and SSG basic functionality
25
+ * GitHub Actions for acceptance testing where possible
26
+
27
+ ### 1.23.0 / 2021-03-16
28
+ * Added:
29
+ * For `podman` support:
30
+ * Bumped the required beaker-docker to between 0.8.3 and 2.0.0
31
+ * Added a dependency on docker-api between 2.1.0 and 3.0.0
32
+ * Make SSG failures have verbose output to make remediation easier
33
+ * Fixed:
34
+ * Ensure that containers use the correct method for copying files
35
+
36
+ ### 1.22.1 / 2021-03-01
37
+ * Fixed: enable_epel_on() now installs the correct EPEL repository
38
+ package on OracleLinux
39
+
40
+ ### 1.22.0 / 2021-01-27
41
+ * Fixed:
42
+ * Ensure that the simp-crypto_policy module is installed when flipping to FIPS
43
+ mode
44
+ * Only attempt to install the simp repos once in case they are broken for some
45
+ reason
46
+ * Added:
47
+ * Documentation for all of the beaker environment variables
48
+ * set_simp_repo_release() for setting the release and release_type of the
49
+ public SIMP yum repos
50
+ * set_yum_opts_on() method for setting bulk yum config options
51
+ * set_yum_opt_on() method for setting singular yum config options
52
+ * install_package_unless_present_on() method
53
+ * Allow users to set repos to disable using an environment variable
54
+ * A total run time summary for beaker suites
55
+
1
56
  ### 1.21.4 / 2021-01-21
2
57
  * Fixed:
3
58
  * Reverted the use of OpenStruct due to issues with seralization
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ gem 'bundler'
13
13
  gem 'rake'
14
14
 
15
15
  group :system_tests do
16
- beaker_gem_options = ENV.fetch('BEAKER_GEM_OPTIONS', ['>= 4.17.0', '< 5.0.0'])
16
+ beaker_gem_options = ENV.fetch('BEAKER_GEM_OPTIONS', ['>= 4.28.1', '< 5.0.0'])
17
17
 
18
18
  if "#{beaker_gem_options}".include?(':')
19
19
  # Just pass in BEAKER_GEM_OPTIONS as a string that would represent the usual
data/README.md CHANGED
@@ -13,6 +13,8 @@ Methods to assist beaker acceptance tests for SIMP.
13
13
  * [`rake beaker:suites`](#rake-beakersuites)
14
14
  * [Suite Execution](#suite-execution)
15
15
  * [Environment Variables](#environment-variables)
16
+ * [Beaker Management](#beaker-management)
17
+ * [Beaker Helpers Adjustments](#beaker-helpers-adjustments)
16
18
  * [Global Suite Configuration](#global-suite-configuration)
17
19
  * [Supported Config:](#supported-config)
18
20
  * [Individual Suite Configuration](#individual-suite-configuration)
@@ -112,12 +114,68 @@ sensitive).
112
114
 
113
115
  #### Environment Variables
114
116
 
115
- * BEAKER_suite_runall
117
+ ##### Beaker Management
118
+
119
+ * BEAKER_suite_runall [yes|no]
116
120
  * Run all Suites
117
121
 
118
- * BEAKER_suite_basedir
122
+ * BEAKER_suite_basedir [String]
119
123
  * The base directory where suites will be defined
120
- * Default: spec/acceptance
124
+ * Default: `spec/acceptance`
125
+
126
+ ##### Beaker Helpers Adjustments
127
+
128
+ * BEAKER_SIMP_parallel [yes|no]
129
+ * `yes` => Run simp-beaker-helpers methods on SUTs in parallel if possible
130
+ * `no` => Do not run methods in parallel
131
+
132
+ * BEAKER_docker_cmd [String]
133
+ * The specific command to use for performing `docker` operations
134
+
135
+ * BEAKER_helpers_verbose [yes|no]
136
+ * `yes` => Enable verbose output
137
+ * `no` => Do not enable verbose output
138
+
139
+ * BEAKER_copy_fixtures [yes|no]
140
+ * `yes` => Enable copying fixtures to the SUT
141
+ * `no` => Disable copying fixtures to the SUT
142
+
143
+ * BEAKER_use_fixtures_dir_for_modules [yes|no]
144
+ * `yes` => Pull fixtures directly from `spec/fixtures/modules`
145
+ * `no` => Ignore `spec/fixtures/modules` content
146
+
147
+ * BEAKER_stringify_facts [yes|no]
148
+ * `yes` => Enable fact stringification
149
+
150
+ * BEAKER_fips_module_version [String]
151
+ * The specific version of the FIPS module to install from the puppet forge
152
+
153
+ * BEAKER_RHSM_USER [String]
154
+ * The username for using with RHSM
155
+
156
+ * BEAKER_RHSM_PASS [String]
157
+ * The password for using with RHSM
158
+
159
+ * BEAKER_fips [yes|no]
160
+ * `yes` => Enable FIPS on the SUT
161
+ * `no` => Do not manage FIPS on the SUT (will not disable if enabled)
162
+
163
+ * BEAKER_no_fix_interfaces [Boolean]
164
+ * If present, will not try to fix the interfaces on the SUT
165
+
166
+ * BEAKER_SIMP_install_repos [yes|no]
167
+ * `yes` => Install the SIMP YUM repositories
168
+ * `no` => No not install the SIMP YUM repositories
169
+
170
+ * BEAKER_SIMP_disable_repos [String]
171
+ * Comma delimited list of YUM repositories to disable on the SUT
172
+
173
+ * BEAKER_SIMP_repo_release [String]
174
+ * The release of SIMP to target in the YUM repos (usually a number)
175
+
176
+ * BEAKER_SIMP_repo_release_type [String]
177
+ * The release type of SIMP to target in the YUM repos
178
+ * Something like `stable`, `rolling`, or `unstable`
121
179
 
122
180
  #### Global Suite Configuration
123
181
 
@@ -406,7 +464,7 @@ might try to install packages before subscription manager is configured.
406
464
  The version of InSpec to use when running inspec tests. Currently hard-coded to
407
465
  `4.16.14` due to a bug introduced in `4.16.15`.
408
466
 
409
- Let to 'latest' to use the latest available in the upstream repos.
467
+ Set to 'latest' to use the latest available in the upstream repos.
410
468
 
411
469
  ## Examples
412
470
 
@@ -510,7 +568,7 @@ underlying OS configuration.
510
568
 
511
569
  `Simp::BeakerHelpers::Snapshot.save(sut, '<name of snapshot>')` will save a
512
570
  snapshot with the given name. If the snapshot already exists, it will be
513
- forceably overwritten.
571
+ forcibly overwritten.
514
572
 
515
573
 
516
574
  ##### Base Snapshots
@@ -18,7 +18,53 @@ 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(suts, package_name, package_source=nil, opts={})
21
+ # Sets a single YUM option in the form that yum-config-manager/dnf
22
+ # config-manager would expect.
23
+ #
24
+ # If not prefaced with a repository, the option will be applied globally.
25
+ #
26
+ # Has no effect if yum or dnf is not present.
27
+ def set_yum_opt_on(suts, key, value)
28
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
29
+ block_on(suts, :run_in_parallel => parallel) do |sut|
30
+ repo,target = key.split('.')
31
+
32
+ unless target
33
+ key = "\\*.#{repo}"
34
+ end
35
+
36
+ command = nil
37
+ if !sut.which('dnf').empty?
38
+ install_package_unless_present_on(sut, 'dnf-plugins-core', :accept_all_exit_codes => true)
39
+ command = 'dnf config-manager'
40
+ elsif !sut.which('yum').empty?
41
+ command = 'yum-config-manager'
42
+ end
43
+
44
+ on(sut, %{#{command} --save --setopt=#{key}=#{value}}, :silent => true) if command
45
+ end
46
+ end
47
+
48
+ # Takes a hash of YUM options to set in the form that yum-config-manager/dnf
49
+ # config-manager would expect.
50
+ #
51
+ # If not prefaced with a repository, the option will be applied globally.
52
+ #
53
+ # Example:
54
+ # {
55
+ # 'skip_if_unavailable' => '1', # Applies globally
56
+ # 'foo.installonly_limit' => '5' # Applies only to the 'foo' repo
57
+ # }
58
+ def set_yum_opts_on(suts, yum_opts={})
59
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
60
+ block_on(suts, :run_in_parallel => parallel) do |sut|
61
+ yum_opts.each_pair do |k,v|
62
+ set_yum_opt_on(sut, k, v)
63
+ end
64
+ end
65
+ end
66
+
67
+ def install_package_unless_present_on(suts, package_name, package_source=nil, opts={})
22
68
  default_opts = {
23
69
  max_retries: 3,
24
70
  retry_interval: 10
@@ -28,19 +74,35 @@ module Simp::BeakerHelpers
28
74
  block_on(suts, :run_in_parallel => parallel) do |sut|
29
75
  package_source = package_name unless package_source
30
76
 
31
- if sut.check_for_package(package_name)
32
- sut.upgrade_package(
77
+ unless sut.check_for_package(package_name)
78
+ sut.install_package(
33
79
  package_source,
34
80
  '',
81
+ nil,
35
82
  default_opts.merge(opts)
36
83
  )
37
- else
38
- sut.install_package(
84
+ end
85
+ end
86
+ end
87
+
88
+ def install_latest_package_on(suts, package_name, package_source=nil, opts={})
89
+ default_opts = {
90
+ max_retries: 3,
91
+ retry_interval: 10
92
+ }
93
+
94
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
95
+ block_on(suts, :run_in_parallel => parallel) do |sut|
96
+ package_source = package_name unless package_source
97
+
98
+ if sut.check_for_package(package_name)
99
+ sut.upgrade_package(
39
100
  package_source,
40
101
  '',
41
- nil,
42
102
  default_opts.merge(opts)
43
103
  )
104
+ else
105
+ install_package_unless_present_on(sut, package_name, package_source, opts)
44
106
  end
45
107
  end
46
108
  end
@@ -124,13 +186,18 @@ module Simp::BeakerHelpers
124
186
  end
125
187
  end
126
188
 
127
- unless directory_exists_on(sut, dest)
128
- dest = File.dirname(dest)
129
- sut.mkdir_p(dest)
130
- end
189
+ sut.mkdir_p(File.dirname(dest)) unless directory_exists_on(sut, dest)
131
190
 
132
- %x(tar #{exclude_list.join(' ')} -hcf - -C "#{File.dirname(src)}" "#{File.basename(src)}" | #{docker_cmd} exec -i "#{container_id}" tar -C "#{dest}" -xf -)
191
+ if File.file?(src)
192
+ cmd = %{#{docker_cmd} cp "#{src}" "#{container_id}:#{dest}"}
193
+ else
194
+ cmd = [
195
+ %{tar #{exclude_list.join(' ')} -hcf - -C "#{File.dirname(src)}" "#{File.basename(src)}"},
196
+ %{#{docker_cmd} exec -i "#{container_id}" tar -C "#{dest}" -xf -}
197
+ ].join(' | ')
198
+ end
133
199
 
200
+ %x(#{cmd})
134
201
  elsif rsync_functional_on?(sut)
135
202
  # This makes rsync_to work like beaker and scp usually do
136
203
  exclude_hack = %(__-__' -L --exclude '__-__)
@@ -181,7 +248,7 @@ module Simp::BeakerHelpers
181
248
  rescue StandardError
182
249
  # If *anything* fails, we need to fall back to `puppet facts`
183
250
 
184
- facts_json = on(sut, 'puppet facts find garbage_xxx', :silent => true).stdout
251
+ facts_json = retry_on(sut, 'puppet facts find garbage_xxx', :silent => true, :max_retries => 4).stdout
185
252
  facts = JSON.parse(facts_json)['values']
186
253
  end
187
254
 
@@ -434,13 +501,16 @@ module Simp::BeakerHelpers
434
501
 
435
502
  fips_enable_modulepath = '--modulepath=/root/.beaker_fips/modules'
436
503
 
437
- module_install_cmd = 'puppet module install simp-fips --target-dir=/root/.beaker_fips/modules'
504
+ modules_to_install = {
505
+ 'simp-fips' => ENV['BEAKER_fips_module_version'],
506
+ 'simp-crypto_policy' => nil
507
+ }
438
508
 
439
- if ENV['BEAKER_fips_module_version']
440
- module_install_cmd += " --version #{ENV['BEAKER_fips_module_version']}"
509
+ modules_to_install.each_pair do |to_install, version|
510
+ module_install_cmd = "puppet module install #{to_install} --target-dir=/root/.beaker_fips/modules"
511
+ module_install_cmd += " --version #{version}" if version
512
+ on(sut, module_install_cmd)
441
513
  end
442
-
443
- on(sut, module_install_cmd)
444
514
  end
445
515
 
446
516
  # Work around Vagrant and cipher restrictions in EL8+
@@ -469,7 +539,7 @@ module Simp::BeakerHelpers
469
539
  block_on(suts, :run_in_parallel => parallel) do |sut|
470
540
  if sut['yum_repos']
471
541
  sut['yum_repos'].each_pair do |repo, metadata|
472
- repo_manifest = create_yum_resource( repo, metadata)
542
+ repo_manifest = create_yum_resource(repo, metadata)
473
543
 
474
544
  apply_manifest_on(sut, repo_manifest, :catch_failures => true)
475
545
  end
@@ -549,12 +619,13 @@ module Simp::BeakerHelpers
549
619
  def enable_epel_on(suts)
550
620
  parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
551
621
  block_on(suts, :run_in_parallel => parallel) do |sut|
552
- if ONLINE && (ENV['BEAKER_stringify_facts'] != 'no')
622
+ if ONLINE
553
623
  os_info = fact_on(sut, 'os')
554
624
  os_maj_rel = os_info['release']['major']
555
625
 
556
626
  # This is based on the official EPEL docs https://fedoraproject.org/wiki/EPEL
557
- if ['RedHat', 'CentOS'].include?(os_info['name'])
627
+ case os_info['name']
628
+ when 'RedHat','CentOS'
558
629
  install_latest_package_on(
559
630
  sut,
560
631
  'epel-release',
@@ -580,7 +651,11 @@ module Simp::BeakerHelpers
580
651
  on sut, %{dnf config-manager --set-enabled powertools || dnf config-manager --set-enabled PowerTools}
581
652
  end
582
653
  end
654
+ when 'OracleLinux'
655
+ package_name = "oracle-epel-release-el#{os_maj_rel}"
656
+ install_latest_package_on(sut,package_name)
583
657
  end
658
+
584
659
  end
585
660
  end
586
661
  end
@@ -597,6 +672,9 @@ module Simp::BeakerHelpers
597
672
  def linux_errata( suts )
598
673
  parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
599
674
  block_on(suts, :run_in_parallel => parallel) do |sut|
675
+ # Set the locale if not set
676
+ sut.set_env_var('LANG', 'en_US.UTF-8') unless sut.get_env_var('LANG')
677
+
600
678
  # We need to be able to flip between server and client without issue
601
679
  on sut, 'puppet resource group puppet gid=52'
602
680
  on sut, 'puppet resource user puppet comment="Puppet" gid="52" uid="52" home="/var/lib/puppet" managehome=true'
@@ -672,11 +750,9 @@ module Simp::BeakerHelpers
672
750
  if os_info['family'] == 'RedHat'
673
751
  # OS-specific items
674
752
  if os_info['name'] == 'RedHat'
675
- RSpec.configure do |c|
676
- c.before(:all) do
677
- rhel_rhsm_subscribe(sut)
678
- end
753
+ rhel_rhsm_subscribe(sut)
679
754
 
755
+ RSpec.configure do |c|
680
756
  c.after(:all) do
681
757
  rhel_rhsm_unsubscribe(sut)
682
758
  end
@@ -695,15 +771,6 @@ module Simp::BeakerHelpers
695
771
  apply_manifest_on(sut, pp, :catch_failures => false)
696
772
  end
697
773
 
698
- unless sut[:hypervisor] == 'docker'
699
- if (os_info['name'] == 'CentOS') && (os_info['release']['major'].to_i >= 8)
700
- if os_info['release']['minor'].to_i == 3
701
- update_package_from_centos_stream(sut, 'kernel')
702
- sut.reboot
703
- end
704
- end
705
- end
706
-
707
774
  # Clean up YUM prior to starting our test runs.
708
775
  on(sut, 'yum clean all')
709
776
  end
@@ -1020,13 +1087,13 @@ module Simp::BeakerHelpers
1020
1087
  next
1021
1088
  end
1022
1089
 
1023
- interfaces_fact = retry_on(host,'facter interfaces', verbose: true).stdout
1090
+ interfaces_fact = pfact_on(host, 'interfaces')
1024
1091
 
1025
1092
  interfaces = interfaces_fact.strip.split(',')
1026
1093
  interfaces.delete_if { |x| x =~ /^lo/ }
1027
1094
 
1028
1095
  interfaces.each do |iface|
1029
- if fact_on(host, "ipaddress_#{iface}").strip.empty?
1096
+ if pfact_on(host, "ipaddress_#{iface}")
1030
1097
  on(host, "ifup #{iface}", :accept_all_exit_codes => true)
1031
1098
  end
1032
1099
  end
@@ -1397,49 +1464,79 @@ module Simp::BeakerHelpers
1397
1464
  # * 'simp-community-postgres'
1398
1465
  # * 'simp-community-puppet'
1399
1466
  #
1400
- def install_simp_repos(sut, disable = [])
1467
+ #
1468
+ # Environment Variables:
1469
+ # * BEAKER_SIMP_install_repos
1470
+ # * 'no' => disable the capability
1471
+ # * BEAKER_SIMP_disable_repos
1472
+ # * Comma delimited list of active yum repo names to disable
1473
+ def install_simp_repos(suts, disable = [])
1401
1474
  # NOTE: Do *NOT* use puppet in this method since it may not be available yet
1402
1475
 
1403
- install_latest_package_on(sut, 'yum-utils')
1404
- install_latest_package_on(
1405
- sut,
1406
- 'simp-release-community',
1407
- "https://download.simp-project.com/simp-release-community.rpm",
1408
- )
1476
+ return if (ENV.fetch('SIMP_install_repos', 'yes') == 'no')
1409
1477
 
1410
- to_disable = disable.dup
1478
+ parallel = (ENV['BEAKER_SIMP_parallel'] == 'yes')
1479
+ block_on(suts, :run_in_parallel => parallel) do |sut|
1480
+ install_package_unless_present_on(sut, 'yum-utils')
1411
1481
 
1412
- unless to_disable.empty?
1413
- if to_disable.include?('simp')
1414
- to_disable.delete('simp')
1415
- to_disable << 'simp-community-simp'
1416
- end
1482
+ install_package_unless_present_on(
1483
+ sut,
1484
+ 'simp-release-community',
1485
+ "https://download.simp-project.com/simp-release-community.rpm",
1486
+ )
1417
1487
 
1418
- if to_disable.include?('simp_deps')
1419
- to_disable.delete('simp_deps')
1420
- to_disable << 'simp-community-epel'
1421
- to_disable << 'simp-community-postgres'
1422
- to_disable << 'simp-community-puppet'
1423
- end
1488
+ to_disable = disable.dup
1489
+ to_disable += ENV.fetch('BEAKER_SIMP_disable_repos', '').split(',').map(&:strip)
1424
1490
 
1425
- # NOTE: This --enablerepo enables the repos for listing and is inherited
1426
- # from YUM. This does not actually "enable" the repos, that would require
1427
- # the "--enable" option (from yum-config-manager) :-D.
1428
- #
1429
- # Note: Certain versions of EL8 do not dump by default and EL7 does not
1430
- # have the '--dump' option.
1431
- available_repos = on(sut, %{yum-config-manager --enablerepo="*" || yum-config-manager --enablerepo="*" --dump}).stdout.lines.grep(/\A\[(.+)\]\Z/){|x| $1}
1491
+ unless to_disable.empty?
1492
+ if to_disable.include?('simp')
1493
+ to_disable.delete('simp')
1494
+ to_disable << 'simp-community-simp'
1495
+ end
1432
1496
 
1433
- invalid_repos = (to_disable - available_repos)
1497
+ if to_disable.include?('simp_deps')
1498
+ to_disable.delete('simp_deps')
1499
+ to_disable << 'simp-community-epel'
1500
+ to_disable << 'simp-community-postgres'
1501
+ to_disable << 'simp-community-puppet'
1502
+ end
1434
1503
 
1435
- # Verify that the repos passed to disable are in the list of valid repos
1436
- unless invalid_repos.empty?
1437
- logger.warn(%{WARN: install_simp_repo - requested repos to disable do not exist on the target system '#{invalid_repos.join("', '")}'.})
1438
- end
1504
+ # NOTE: This --enablerepo enables the repos for listing and is inherited
1505
+ # from YUM. This does not actually "enable" the repos, that would require
1506
+ # the "--enable" option (from yum-config-manager) :-D.
1507
+ #
1508
+ # Note: Certain versions of EL8 do not dump by default and EL7 does not
1509
+ # have the '--dump' option.
1510
+ available_repos = on(sut, %{yum-config-manager --enablerepo="*" || yum-config-manager --enablerepo="*" --dump}).stdout.lines.grep(/\A\[(.+)\]\Z/){|x| $1}
1439
1511
 
1440
- (to_disable - invalid_repos).each do |repo|
1441
- on(sut, %{yum-config-manager --disable "#{repo}"})
1512
+ invalid_repos = (to_disable - available_repos)
1513
+
1514
+ # Verify that the repos passed to disable are in the list of valid repos
1515
+ unless invalid_repos.empty?
1516
+ logger.warn(%{WARN: install_simp_repo - requested repos to disable do not exist on the target system '#{invalid_repos.join("', '")}'.})
1517
+ end
1518
+
1519
+ (to_disable - invalid_repos).each do |repo|
1520
+ on(sut, %{yum-config-manager --disable "#{repo}"})
1521
+ end
1442
1522
  end
1443
1523
  end
1524
+
1525
+ set_yum_opts_on(suts, {'simp*.skip_if_unavailable' => '1' })
1526
+ end
1527
+
1528
+ # Set the release and release type of the SIMP yum repos
1529
+ #
1530
+ # Environment variables may be used to set either one
1531
+ # * BEAKER_SIMP_repo_release => The actual release (version number)
1532
+ # * BEAKER_SIMP_repo_release_type => The type of release (stable, unstable, rolling, etc...)
1533
+ def set_simp_repo_release(sut, simp_release_type='stable', simp_release='6')
1534
+ simp_release = ENV.fetch('BEAKER_SIMP_repo_release', simp_release)
1535
+ simp_release_type = ENV.fetch('BEAKER_SIMP_repo_release_type', simp_release_type)
1536
+
1537
+ simp_release_type = 'releases' if (simp_release_type == 'stable')
1538
+
1539
+ create_remote_file(sut, '/etc/yum/vars/simprelease', simp_release)
1540
+ create_remote_file(sut, '/etc/yum/vars/simpreleasetype', simp_release_type)
1444
1541
  end
1445
1542
  end