Skip to content

Commit

Permalink
Fix legacy fact usage (#221)
Browse files Browse the repository at this point in the history
* Fix legacy fact usage
* Update beaker nodesets
* Add EL9 support in Simp::BeakerHelpers::SSG
* Allow el9 to fail install_simp_repos tests
  • Loading branch information
silug authored Sep 18, 2024
1 parent 4cc89e7 commit 0ff8bd5
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 47 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions lib/simp/beaker_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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

Expand Down Expand Up @@ -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 => [] }

Expand Down Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions lib/simp/beaker_helpers/inspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
51 changes: 49 additions & 2 deletions lib/simp/beaker_helpers/ssg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SSG
'openscap-utils',
'python-jinja2',
'python-lxml',
'python-setuptools'
'python-setuptools',
]

EL8_PACKAGES = [
Expand All @@ -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 = {
Expand Down Expand Up @@ -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' => {
Expand All @@ -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' => {
Expand All @@ -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' => {
Expand All @@ -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'
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/simp/beaker_helpers/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
module Simp; end

module Simp::BeakerHelpers
VERSION = '1.33.0'
VERSION = '1.34.0'
end
17 changes: 4 additions & 13 deletions spec/acceptance/nodesets/default.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 4 additions & 12 deletions spec/acceptance/nodesets/docker.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
16 changes: 8 additions & 8 deletions spec/acceptance/nodesets/oel.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
HOSTS:
oel7:
roles:
- default
- el7
platform: el-7-x86_64
box: generic/oracle7
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"

oel8:
roles:
- el8
platform: el-8-x86_64
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
Expand Down
22 changes: 19 additions & 3 deletions spec/acceptance/suites/default/install_simp_deps_repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/suites/inspec/00_default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0ff8bd5

Please sign in to comment.