Skip to content

Commit 0ff8bd5

Browse files
authored
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
1 parent 4cc89e7 commit 0ff8bd5

File tree

10 files changed

+99
-47
lines changed

10 files changed

+99
-47
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### 1.34.0 / 2024-09-17
2+
* Fixed:
3+
* Legacy fact usage
4+
* Added:
5+
* EL9 support in Simp::BeakerHelpers::SSG
6+
17
### 1.33.0 / 2024-06-05
28
* Fixed:
39
* Update gem dependencies

lib/simp/beaker_helpers.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@ def linux_errata( suts )
723723
os_info = fact_on(sut, 'os')
724724

725725
# Make sure we have a domain on our host
726-
current_domain = fact_on(sut, 'domain').strip
727-
hostname = fact_on(sut, 'hostname').strip
726+
current_domain = fact_on(sut, 'networking.domain').strip
727+
hostname = fact_on(sut, 'networking.hostname').strip
728728

729729
if current_domain.empty?
730730
new_fqdn = hostname + '.beaker.test'
@@ -744,7 +744,7 @@ def linux_errata( suts )
744744
end
745745
end
746746

747-
if fact_on(sut, 'domain').strip.empty?
747+
if fact_on(sut, 'networking.domain').strip.empty?
748748
fail("Error: hosts must have an FQDN, got domain='#{current_domain}'")
749749
end
750750

@@ -1004,7 +1004,7 @@ def run_fake_pki_ca_on( ca_sut = master, suts = hosts, local_dir = '' )
10041004
suts_network_info = {}
10051005

10061006
hosts.each do |host|
1007-
fqdn = fact_on(host, 'fqdn').strip
1007+
fqdn = fact_on(host, 'networking.fqdn').strip
10081008

10091009
host_entry = { fqdn => [] }
10101010

@@ -1090,7 +1090,7 @@ def run_fake_pki_ca_on( ca_sut = master, suts = hosts, local_dir = '' )
10901090
# public/fdqn.pub
10911091
# private/fdqn.pem
10921092
def copy_pki_to(sut, local_pki_dir, sut_base_dir = '/etc/pki/simp-testing')
1093-
fqdn = fact_on(sut, 'fqdn')
1093+
fqdn = fact_on(sut, 'networking.fqdn')
10941094
sut_pki_dir = File.join( sut_base_dir, 'pki' )
10951095
local_host_pki_tree = File.join(local_pki_dir,'pki','keydist',fqdn)
10961096
local_cacert = File.join(local_pki_dir,'pki','demoCA','cacert.pem')

lib/simp/beaker_helpers/inspec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def initialize(sut, profile)
4646
@sut.install_package("inspec-#{@inspec_version}")
4747
end
4848

49-
os = fact_on(@sut, 'operatingsystem')
50-
os_rel = fact_on(@sut, 'operatingsystemmajrelease')
49+
os = fact_on(@sut, 'os.name')
50+
os_rel = fact_on(@sut, 'os.release.major')
5151

5252
@profile = "#{os}-#{os_rel}-#{profile}"
5353
@profile_dir = '/tmp/inspec/inspec_profiles'

lib/simp/beaker_helpers/ssg.rb

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SSG
2828
'openscap-utils',
2929
'python-jinja2',
3030
'python-lxml',
31-
'python-setuptools'
31+
'python-setuptools',
3232
]
3333

3434
EL8_PACKAGES = [
@@ -43,7 +43,22 @@ class SSG
4343
'python3-lxml',
4444
'python3-pyyaml',
4545
'python3-setuptools',
46-
'libarchive'
46+
'libarchive',
47+
]
48+
49+
EL9_PACKAGES = [
50+
'cmake',
51+
'git',
52+
'make',
53+
'openscap-python3',
54+
'openscap-utils',
55+
'openscap-scanner',
56+
'python3',
57+
'python3-jinja2',
58+
'python3-lxml',
59+
'python3-pyyaml',
60+
'python3-setuptools',
61+
'libarchive',
4762
]
4863

4964
OS_INFO = {
@@ -71,6 +86,14 @@ class SSG
7186
'build_target' => 'rhel8',
7287
'datastream' => 'ssg-rhel8-ds.xml'
7388
}
89+
},
90+
'9' => {
91+
'required_packages' => EL9_PACKAGES,
92+
'ssg' => {
93+
'profile_target' => 'rhel9',
94+
'build_target' => 'rhel9',
95+
'datastream' => 'ssg-rhel9-ds.xml'
96+
}
7497
}
7598
},
7699
'CentOS' => {
@@ -97,6 +120,14 @@ class SSG
97120
'build_target' => 'centos8',
98121
'datastream' => 'ssg-centos8-ds.xml'
99122
}
123+
},
124+
'9' => {
125+
'required_packages' => EL9_PACKAGES,
126+
'ssg' => {
127+
'profile_target' => 'cs9',
128+
'build_target' => 'cs9',
129+
'datastream' => 'ssg-cs9-ds.xml'
130+
}
100131
}
101132
},
102133
'Rocky' => {
@@ -107,6 +138,14 @@ class SSG
107138
'build_target' => 'centos8',
108139
'datastream' => 'ssg-centos8-ds.xml'
109140
}
141+
},
142+
'9' => {
143+
'required_packages' => EL9_PACKAGES,
144+
'ssg' => {
145+
'profile_target' => 'cs9',
146+
'build_target' => 'cs9',
147+
'datastream' => 'ssg-cs9-ds.xml'
148+
}
110149
}
111150
},
112151
'OracleLinux' => {
@@ -125,6 +164,14 @@ class SSG
125164
'build_target' => 'ol8',
126165
'datastream' => 'ssg-ol8-ds.xml'
127166
}
167+
},
168+
'9' => {
169+
'required_packages' => EL9_PACKAGES,
170+
'ssg' => {
171+
'profile_target' => 'ol9',
172+
'build_target' => 'ol9',
173+
'datastream' => 'ssg-ol9-ds.xml'
174+
}
128175
}
129176
}
130177
}

lib/simp/beaker_helpers/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
module Simp; end
44

55
module Simp::BeakerHelpers
6-
VERSION = '1.33.0'
6+
VERSION = '1.34.0'
77
end

spec/acceptance/nodesets/default.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
---
22
HOSTS:
3-
el7:
3+
el9:
44
roles:
5-
- default
6-
- el7
7-
platform: el-7-x86_64
8-
box: centos/7
9-
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
10-
family: centos-cloud/centos-7
11-
gce_machine_type: n1-standard-2
12-
el8:
13-
roles:
14-
- el8
15-
platform: el-8-x86_64
16-
box: generic/centos8s
5+
- el9
6+
platform: el-9-x86_64
7+
box: generic/centos9s
178
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
189
family: centos-cloud/centos-stream-8
1910
gce_machine_type: n1-standard-2

spec/acceptance/nodesets/docker.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
---
22
HOSTS:
3-
el7.test.net:
3+
el9.test.net:
44
roles:
55
- default
6-
- el7
7-
platform: el-7-x86_64
6+
- el9
7+
platform: el-9-x86_64
88
hypervisor: docker
9-
image: simpproject/simp_beaker_el7
10-
docker_cmd: "/usr/sbin/sshd -D -E /var/log/sshd.log"
11-
12-
el8.test.net:
13-
roles:
14-
- el8
15-
platform: el-8-x86_64
16-
hypervisor: docker
17-
image: simpproject/simp_beaker_el8
9+
image: quay.io/centos/centos:stream9
1810
docker_cmd: "/usr/sbin/sshd -D -E /var/log/sshd.log"
1911

2012
CONFIG:

spec/acceptance/nodesets/oel.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
---
22
HOSTS:
3-
oel7:
4-
roles:
5-
- default
6-
- el7
7-
platform: el-7-x86_64
8-
box: generic/oracle7
9-
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
10-
113
oel8:
124
roles:
135
- el8
146
platform: el-8-x86_64
157
box: generic/oracle8
168
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
179

10+
oel9:
11+
roles:
12+
- default
13+
- el9
14+
platform: el-9-x86_64
15+
box: generic/oracle9
16+
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
17+
1818
CONFIG:
1919
log_level: verbose
2020
type: aio

spec/acceptance/suites/default/install_simp_deps_repo_spec.rb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
hosts.each do |host|
44
expect_failures = false
5-
if hosts_with_role(hosts, 'el8').include?(host)
5+
if hosts_with_role(hosts, 'el9').include?(host)
66
expect_failures = true
77
end
88

@@ -12,7 +12,15 @@
1212
end
1313

1414
context 'default settings' do
15-
before(:all) { install_simp_repos(host) }
15+
before(:all) do
16+
install_simp_repos(host)
17+
rescue => e
18+
if expect_failures
19+
warn e.message
20+
else
21+
raise e
22+
end
23+
end
1624

1725
it 'enables the correct repos' do
1826
skip "#{host} is not supported yet" if expect_failures
@@ -34,7 +42,15 @@
3442
end
3543

3644
context 'when passed a disabled list ' do
37-
before(:all) { install_simp_repos(host, ['simp-community-simp'] ) }
45+
before(:all) do
46+
install_simp_repos(host, ['simp-community-simp'] )
47+
rescue => e
48+
if expect_failures
49+
warn e.message
50+
else
51+
raise e
52+
end
53+
end
3854

3955
it 'enables the correct repos' do
4056
skip "#{host} is not supported yet" if expect_failures

spec/acceptance/suites/inspec/00_default_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
profile_path = File.join(
1515
fixtures_path,
1616
'inspec_profiles',
17-
"#{fact_on(host, 'operatingsystem')}-#{fact_on(host, 'operatingsystemmajrelease')}-#{profile}"
17+
"#{fact_on(host, 'os.name')}-#{fact_on(host, 'os.release.major')}-#{profile}"
1818
)
1919

2020
unless File.exist?(profile_path)

0 commit comments

Comments
 (0)