From 0ff8bd5c4d45cab04f39cdad317d082a18994acf Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Wed, 18 Sep 2024 13:27:31 -0500 Subject: [PATCH] Fix legacy fact usage (#221) * Fix legacy fact usage * Update beaker nodesets * Add EL9 support in Simp::BeakerHelpers::SSG * Allow el9 to fail install_simp_repos tests --- CHANGELOG.md | 6 +++ lib/simp/beaker_helpers.rb | 10 ++-- lib/simp/beaker_helpers/inspec.rb | 4 +- lib/simp/beaker_helpers/ssg.rb | 51 ++++++++++++++++++- lib/simp/beaker_helpers/version.rb | 2 +- spec/acceptance/nodesets/default.yml | 17 ++----- spec/acceptance/nodesets/docker.yml | 16 ++---- spec/acceptance/nodesets/oel.yml | 16 +++--- .../default/install_simp_deps_repo_spec.rb | 22 ++++++-- .../suites/inspec/00_default_spec.rb | 2 +- 10 files changed, 99 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6173cd..c61b14e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 1.34.0 / 2024-09-17 +* Fixed: + * Legacy fact usage +* Added: + * EL9 support in Simp::BeakerHelpers::SSG + ### 1.33.0 / 2024-06-05 * Fixed: * Update gem dependencies diff --git a/lib/simp/beaker_helpers.rb b/lib/simp/beaker_helpers.rb index 3076361..90b3404 100644 --- a/lib/simp/beaker_helpers.rb +++ b/lib/simp/beaker_helpers.rb @@ -723,8 +723,8 @@ def linux_errata( suts ) os_info = fact_on(sut, 'os') # Make sure we have a domain on our host - current_domain = fact_on(sut, 'domain').strip - hostname = fact_on(sut, 'hostname').strip + current_domain = fact_on(sut, 'networking.domain').strip + hostname = fact_on(sut, 'networking.hostname').strip if current_domain.empty? new_fqdn = hostname + '.beaker.test' @@ -744,7 +744,7 @@ def linux_errata( suts ) end end - if fact_on(sut, 'domain').strip.empty? + if fact_on(sut, 'networking.domain').strip.empty? fail("Error: hosts must have an FQDN, got domain='#{current_domain}'") end @@ -1004,7 +1004,7 @@ def run_fake_pki_ca_on( ca_sut = master, suts = hosts, local_dir = '' ) suts_network_info = {} hosts.each do |host| - fqdn = fact_on(host, 'fqdn').strip + fqdn = fact_on(host, 'networking.fqdn').strip host_entry = { fqdn => [] } @@ -1090,7 +1090,7 @@ def run_fake_pki_ca_on( ca_sut = master, suts = hosts, local_dir = '' ) # public/fdqn.pub # private/fdqn.pem def copy_pki_to(sut, local_pki_dir, sut_base_dir = '/etc/pki/simp-testing') - fqdn = fact_on(sut, 'fqdn') + fqdn = fact_on(sut, 'networking.fqdn') sut_pki_dir = File.join( sut_base_dir, 'pki' ) local_host_pki_tree = File.join(local_pki_dir,'pki','keydist',fqdn) local_cacert = File.join(local_pki_dir,'pki','demoCA','cacert.pem') diff --git a/lib/simp/beaker_helpers/inspec.rb b/lib/simp/beaker_helpers/inspec.rb index e39cc9f..92a34de 100644 --- a/lib/simp/beaker_helpers/inspec.rb +++ b/lib/simp/beaker_helpers/inspec.rb @@ -46,8 +46,8 @@ def initialize(sut, profile) @sut.install_package("inspec-#{@inspec_version}") end - os = fact_on(@sut, 'operatingsystem') - os_rel = fact_on(@sut, 'operatingsystemmajrelease') + os = fact_on(@sut, 'os.name') + os_rel = fact_on(@sut, 'os.release.major') @profile = "#{os}-#{os_rel}-#{profile}" @profile_dir = '/tmp/inspec/inspec_profiles' diff --git a/lib/simp/beaker_helpers/ssg.rb b/lib/simp/beaker_helpers/ssg.rb index c1fac46..700b2cb 100644 --- a/lib/simp/beaker_helpers/ssg.rb +++ b/lib/simp/beaker_helpers/ssg.rb @@ -28,7 +28,7 @@ class SSG 'openscap-utils', 'python-jinja2', 'python-lxml', - 'python-setuptools' + 'python-setuptools', ] EL8_PACKAGES = [ @@ -43,7 +43,22 @@ class SSG 'python3-lxml', 'python3-pyyaml', 'python3-setuptools', - 'libarchive' + 'libarchive', + ] + + EL9_PACKAGES = [ + 'cmake', + 'git', + 'make', + 'openscap-python3', + 'openscap-utils', + 'openscap-scanner', + 'python3', + 'python3-jinja2', + 'python3-lxml', + 'python3-pyyaml', + 'python3-setuptools', + 'libarchive', ] OS_INFO = { @@ -71,6 +86,14 @@ class SSG 'build_target' => 'rhel8', 'datastream' => 'ssg-rhel8-ds.xml' } + }, + '9' => { + 'required_packages' => EL9_PACKAGES, + 'ssg' => { + 'profile_target' => 'rhel9', + 'build_target' => 'rhel9', + 'datastream' => 'ssg-rhel9-ds.xml' + } } }, 'CentOS' => { @@ -97,6 +120,14 @@ class SSG 'build_target' => 'centos8', 'datastream' => 'ssg-centos8-ds.xml' } + }, + '9' => { + 'required_packages' => EL9_PACKAGES, + 'ssg' => { + 'profile_target' => 'cs9', + 'build_target' => 'cs9', + 'datastream' => 'ssg-cs9-ds.xml' + } } }, 'Rocky' => { @@ -107,6 +138,14 @@ class SSG 'build_target' => 'centos8', 'datastream' => 'ssg-centos8-ds.xml' } + }, + '9' => { + 'required_packages' => EL9_PACKAGES, + 'ssg' => { + 'profile_target' => 'cs9', + 'build_target' => 'cs9', + 'datastream' => 'ssg-cs9-ds.xml' + } } }, 'OracleLinux' => { @@ -125,6 +164,14 @@ class SSG 'build_target' => 'ol8', 'datastream' => 'ssg-ol8-ds.xml' } + }, + '9' => { + 'required_packages' => EL9_PACKAGES, + 'ssg' => { + 'profile_target' => 'ol9', + 'build_target' => 'ol9', + 'datastream' => 'ssg-ol9-ds.xml' + } } } } diff --git a/lib/simp/beaker_helpers/version.rb b/lib/simp/beaker_helpers/version.rb index d8cd872..69f5ca3 100644 --- a/lib/simp/beaker_helpers/version.rb +++ b/lib/simp/beaker_helpers/version.rb @@ -3,5 +3,5 @@ module Simp; end module Simp::BeakerHelpers - VERSION = '1.33.0' + VERSION = '1.34.0' end diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml index b848bc0..8943579 100644 --- a/spec/acceptance/nodesets/default.yml +++ b/spec/acceptance/nodesets/default.yml @@ -1,19 +1,10 @@ --- HOSTS: - el7: + el9: roles: - - default - - el7 - platform: el-7-x86_64 - box: centos/7 - hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>" - family: centos-cloud/centos-7 - gce_machine_type: n1-standard-2 - el8: - roles: - - el8 - platform: el-8-x86_64 - box: generic/centos8s + - el9 + platform: el-9-x86_64 + box: generic/centos9s hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>" family: centos-cloud/centos-stream-8 gce_machine_type: n1-standard-2 diff --git a/spec/acceptance/nodesets/docker.yml b/spec/acceptance/nodesets/docker.yml index 10567d5..07ad141 100644 --- a/spec/acceptance/nodesets/docker.yml +++ b/spec/acceptance/nodesets/docker.yml @@ -1,20 +1,12 @@ --- HOSTS: - el7.test.net: + el9.test.net: roles: - default - - el7 - platform: el-7-x86_64 + - el9 + platform: el-9-x86_64 hypervisor: docker - image: simpproject/simp_beaker_el7 - docker_cmd: "/usr/sbin/sshd -D -E /var/log/sshd.log" - - el8.test.net: - roles: - - el8 - platform: el-8-x86_64 - hypervisor: docker - image: simpproject/simp_beaker_el8 + image: quay.io/centos/centos:stream9 docker_cmd: "/usr/sbin/sshd -D -E /var/log/sshd.log" CONFIG: diff --git a/spec/acceptance/nodesets/oel.yml b/spec/acceptance/nodesets/oel.yml index db941d3..92c0a81 100644 --- a/spec/acceptance/nodesets/oel.yml +++ b/spec/acceptance/nodesets/oel.yml @@ -1,13 +1,5 @@ --- HOSTS: - oel7: - roles: - - default - - el7 - platform: el-7-x86_64 - box: generic/oracle7 - hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>" - oel8: roles: - el8 @@ -15,6 +7,14 @@ HOSTS: box: generic/oracle8 hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>" + oel9: + roles: + - default + - el9 + platform: el-9-x86_64 + box: generic/oracle9 + hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>" + CONFIG: log_level: verbose type: aio diff --git a/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb b/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb index 1b11caa..dd31380 100644 --- a/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb +++ b/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb @@ -2,7 +2,7 @@ hosts.each do |host| expect_failures = false - if hosts_with_role(hosts, 'el8').include?(host) + if hosts_with_role(hosts, 'el9').include?(host) expect_failures = true end @@ -12,7 +12,15 @@ end context 'default settings' do - before(:all) { install_simp_repos(host) } + before(:all) do + install_simp_repos(host) + rescue => e + if expect_failures + warn e.message + else + raise e + end + end it 'enables the correct repos' do skip "#{host} is not supported yet" if expect_failures @@ -34,7 +42,15 @@ end context 'when passed a disabled list ' do - before(:all) { install_simp_repos(host, ['simp-community-simp'] ) } + before(:all) do + install_simp_repos(host, ['simp-community-simp'] ) + rescue => e + if expect_failures + warn e.message + else + raise e + end + end it 'enables the correct repos' do skip "#{host} is not supported yet" if expect_failures diff --git a/spec/acceptance/suites/inspec/00_default_spec.rb b/spec/acceptance/suites/inspec/00_default_spec.rb index 4e25715..f3e865e 100644 --- a/spec/acceptance/suites/inspec/00_default_spec.rb +++ b/spec/acceptance/suites/inspec/00_default_spec.rb @@ -14,7 +14,7 @@ profile_path = File.join( fixtures_path, 'inspec_profiles', - "#{fact_on(host, 'operatingsystem')}-#{fact_on(host, 'operatingsystemmajrelease')}-#{profile}" + "#{fact_on(host, 'os.name')}-#{fact_on(host, 'os.release.major')}-#{profile}" ) unless File.exist?(profile_path)