Skip to content

Commit c1ce9c3

Browse files
(SIMP-10175) simplib Add Puppet 7 acceptance test (#259)
* (SIMP-10175) simplib Add Puppet 7 acceptance test * Add a Puppet 7 acceptance test * Fixe ipa_fact test suite * Reinstate GitLab test jobs for caller_function, ipa_fact, and prelink_fact suites * Split default nodeset for ipa_fact suite into nodesets for CentOS and Oracle boxes and then added corresponding *el8 nodes to them * Fail acceptance tests if no examples are executed. [SIMP-9666] #comment pupmod-simp-simplib acceptance tests configured SIMP-10175 #close SIMP-10303 #close SIMP-10243 #close Co-authored-by: lnemsick-simp <lnemsick.simp@gmail.com> Co-authored-by: lnemsick-simp <lnemsick-simp@users.noreply.github.com>
1 parent aef6afc commit c1ce9c3

11 files changed

Lines changed: 180 additions & 92 deletions

File tree

.fixtures.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
22
fixtures:
33
repositories:
4+
haveged: https://github.com/simp/pupmod-simp-haveged.git
45
simpkv: https://github.com/simp/pupmod-simp-simpkv.git
56
stdlib: https://github.com/simp/puppetlabs-stdlib.git
7+
systemd: https://github.com/simp/puppet-systemd.git
68

79
# This needs to be in place for the rspec-puppet Hiera 5 hook to work
810
# No idea why, it may be because Puppet sees a custom backend and loads all

.gitlab-ci.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,47 @@ pup6.pe-oel:
356356
script:
357357
- 'bundle exec rake beaker:suites[default,oel]'
358358

359-
pup6.pe-win:
359+
pup6.pe-caller_function:
360+
<<: *acceptance_base
361+
<<: *pup_6_pe
362+
script:
363+
- 'bundle exec rake beaker:suites[caller_function,default]'
364+
365+
pup6.pe-ipa_fact:
366+
<<: *acceptance_base
367+
<<: *pup_6_pe
368+
script:
369+
- 'bundle exec rake beaker:suites[ipa_fact,default]'
370+
371+
pup6.pe-ipa_fact-oel:
372+
<<: *acceptance_base
373+
<<: *pup_6_pe
374+
<<: *with_SIMP_ACCEPTANCE_MATRIX_LEVEL_3
375+
script:
376+
- 'bundle exec rake beaker:suites[ipa_fact,oel]'
377+
378+
pup6.pe-prelink_fact:
379+
<<: *acceptance_base
380+
<<: *pup_6_pe
381+
script:
382+
- 'bundle exec rake beaker:suites[prelink_fact,default]'
383+
384+
pup6.pe-windows:
360385
<<: *acceptance_base
361386
<<: *pup_6_pe
362387
script:
363388
- 'bundle exec rake beaker:suites[windows,default]'
389+
390+
pup7.x:
391+
<<: *pup_7_x
392+
<<: *acceptance_base
393+
script:
394+
- 'bundle exec rake beaker:suites[default,default]'
395+
396+
# caller_function exercises code that depends upon Puppet-internals, so make
397+
# sure it is run for the latest version of Puppet
398+
pup7.pe-caller_function:
399+
<<: *acceptance_base
400+
<<: *pup_7_x
401+
script:
402+
- 'bundle exec rake beaker:suites[caller_function,default]'

CHANGELOG

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
* Tue Jun 22 2021 Trevor Vaughan <tvaughan@onyxpoint.com> - 4.9.0
2-
- Add a `simplib::cron::to_systemd` function to provide 'best-effort'
1+
* Tue Jul 06 2021 Trevor Vaughan <tvaughan@onyxpoint.com> - 4.9.0
2+
- Added a `simplib::cron::to_systemd` function to provide 'best-effort'
33
conversions of cron resource parameters to a systemd timespec
4-
- Fix the simplib__networkmanager fact
4+
- Fixed the simplib__networkmanager fact
5+
- Fixed a bug where the ipa fact did not detect when an EL8 client was
6+
joined to an IPA domain
57

68
* Wed Jun 16 2021 Chris Tessmer <chris.tessmer@onyxpoint.com> - 4.9.0
79
- Removed support for Puppet 5

lib/facter/ipa.rb

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,21 @@
2323
kinit = Facter::Core::Execution.which('kinit')
2424
confine { kinit }
2525

26+
klist = Facter::Core::Execution.which('klist')
27+
confine { klist }
28+
2629
ipa = Facter::Core::Execution.which('ipa')
2730
confine { ipa }
2831

32+
truecmd = Facter::Core::Execution.which('true')
33+
confine { truecmd }
34+
35+
# In EL8 the ipa command needs LC_ALL set to UTF-8 and this is the only
36+
# workaround at this time
37+
locale = ENV.fetch('LANG', 'en_US.UTF-8')
38+
locale = 'en_US.UTF-8' unless locale.match?(/UTF-?8/i)
39+
ipacmd = "#{truecmd} && LC_ALL=#{locale} #{ipa}"
40+
2941
# This file is only present if the host has, at some time,
3042
# been joined to an IPA domain.
3143
confine { File.exist?('/etc/ipa/default.conf') }
@@ -57,19 +69,19 @@
5769
# We won't know if we are connected to a server until later
5870
defaults['connected'] = false
5971

60-
# Grab the necessary information from 'ipa env'
61-
ipa_response = Facter::Core::Execution.execute("#{ipa} env #{needed_keys.join(' ')}", options = {:timeout => ipa_timeout})
62-
63-
if ipa_response.strip.empty?
72+
Facter::Core::Execution.execute(klist)
73+
unless $?.success?
6474
# Obtain host Kerberos token so we can use IPA API
6575
kinit_msg = Facter::Core::Execution.execute("#{kinit} -k 2>&1", options = {:timeout => kinit_timeout})
66-
ipa_response = Facter::Core::Execution.execute("#{ipa} env #{needed_keys.join(' ')}", options = {:timeout => ipa_timeout})
6776
end
6877

78+
# Grab the necessary information from 'ipa env'
79+
ipa_response = Facter::Core::Execution.execute("#{ipacmd} env #{needed_keys.join(' ')}", options = {:timeout => ipa_timeout})
80+
6981
if ipa_response.strip.empty?
7082
ipa_response = {}
7183
else
72-
ipa_server_response = Facter::Core::Execution.execute("#{ipa} env --server host", options = {:timeout => ipa_timeout})
84+
ipa_server_response = Facter::Core::Execution.execute("#{ipacmd} env --server host", options = {:timeout => ipa_timeout})
7385

7486
defaults['connected'] = !ipa_server_response.strip.empty?
7587

spec/acceptance/nodesets/default.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ HOSTS:
99
el7:
1010
roles:
1111
- client
12-
# roles migrated from now-removed el6 node(s):
1312
- default
1413
- master
1514
- prelink
@@ -21,7 +20,7 @@ HOSTS:
2120
roles:
2221
- client
2322
platform: el-8-x86_64
24-
box: centos/8
23+
box: generic/centos8
2524
hypervisor: <%= hypervisor %>
2625

2726
CONFIG:

spec/acceptance/nodesets/oel.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ HOSTS:
99
oel7:
1010
roles:
1111
- client
12-
# roles migrated from now-removed el6 node(s):
1312
- default
1413
- master
1514
- prelink

spec/acceptance/suites/ipa_fact/ipa_fact_spec.rb

Lines changed: 40 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,24 @@ def skip_fips(host)
2323
ipa_realm = ipa_domain.upcase
2424

2525
hosts.each do |host|
26-
it 'should be running haveged for entropy' do
27-
if skip_fips(host)
28-
pending("#{host} does not work in FIPS mode")
29-
expect(false).to eq true
30-
31-
next
32-
else
33-
# IPA requires entropy, so use haveged service
34-
on(host, 'puppet resource package epel-release ensure=present')
35-
on(host, 'puppet resource package haveged ensure=present')
36-
on(host, 'puppet resource service haveged ensure=running enable=true')
37-
38-
# Install the IPA client on all hosts
39-
on(host, 'puppet resource package ipa-client ensure=present')
40-
41-
# Admintools for EL6
42-
on(host, 'puppet resource package ipa-admintools ensure=present', :accept_all_exit_codes => true)
43-
44-
# Ensure that the hostname is set to the FQDN
45-
hostname = fact_on(host, 'fqdn')
46-
if host.host_hash['platform'] =~ /el-7/
47-
on(host, "hostnamectl set-hostname #{hostname}")
48-
else
49-
on(host, "hostname #{hostname}")
50-
create_remote_file(host, '/etc/hostname', "#{hostname}\n")
51-
on(host, "sed -i '/HOSTNAME/d' /etc/sysconfig/network")
52-
on(host, "echo HOSTNAME=#{hostname} >> /etc/sysconfig/network")
53-
end
26+
next if skip_fips(host)
5427

55-
# DBus may need to be restarted after updating, and a reboot is the only way
56-
host.reboot
57-
end
28+
# IPA requires entropy!
29+
it 'should be running haveged or rngd for entropy' do
30+
apply_manifest_on(host, 'include haveged', :accept_all_exit_codes => true)
31+
apply_manifest_on(host, 'include haveged')
32+
end
33+
34+
it 'should install IPA client package' do
35+
on(host, 'puppet resource package ipa-client ensure=present')
36+
end
37+
38+
it 'should ensure hostname is set to the FQDN' do
39+
hostname = pfact_on(host, 'fqdn')
40+
on(host, "hostnamectl set-hostname #{hostname}")
41+
42+
# DBus may need to be restarted after updating, and a reboot is the only way
43+
host.reboot
5844
end
5945
end
6046

@@ -66,9 +52,7 @@ def skip_fips(host)
6652
results = apply_manifest_on(server, manifest)
6753
expect(results.output).to match(/Notice: Type => NilClass Content => null/)
6854

69-
results = JSON.load(on(server, 'puppet facts').output)
70-
71-
expect(results['values']['ipa']).to be_nil
55+
expect(pfact_on(server, 'ipa')).to be_empty
7256
end
7357
end
7458

@@ -81,9 +65,7 @@ def skip_fips(host)
8165
results = apply_manifest_on(server, manifest)
8266
expect(results.output).to match(/Notice: Type => NilClass Content => null/)
8367

84-
results = JSON.load(on(server, 'puppet facts').output)
85-
86-
expect(results['values']['ipa']).to be_nil
68+
expect(pfact_on(server, 'ipa')).to be_empty
8769
end
8870
end
8971

@@ -92,7 +74,7 @@ def skip_fips(host)
9274
it 'ipa fact should contain domain and IPA server' do
9375
# ipa-server-install installs both the IPA server and client.
9476
# The fact uses the client env.
95-
fqdn = fact_on(server, 'fqdn')
77+
fqdn = pfact_on(server, 'fqdn')
9678

9779
cmd = [
9880
'umask 0022 &&',
@@ -112,23 +94,23 @@ def skip_fips(host)
11294
# We only care about this data
11395
expect(apply_manifest_on(server, manifest).output).to match(/Hash Content => {"/)
11496

115-
results = JSON.load(on(server, 'puppet facts').output)
97+
results = pfact_on(server, 'ipa')
11698

117-
expect(results['values']['ipa']).to_not be_nil
118-
expect(results['values']['ipa']['connected']).to eq true
119-
expect(results['values']['ipa']['server']).to eq fqdn
120-
expect(results['values']['ipa']['domain']).to eq ipa_domain
121-
expect(results['values']['ipa']['realm']).to eq ipa_realm
99+
expect(results).to_not be_empty
100+
expect(results['connected']).to eq true
101+
expect(results['server']).to eq fqdn
102+
expect(results['domain']).to eq ipa_domain
103+
expect(results['realm']).to eq ipa_realm
122104
end
123105

124106
it 'ipa fact should have unknown status when connection to IPA server is down' do
125107
# stop IPA server
126108
on(server, 'ipactl stop')
127109

128-
results = JSON.load(on(server, 'puppet facts').output)
110+
results = pfact_on(server, 'ipa')
129111

130-
expect(results['values']['ipa']).to_not be_nil
131-
expect(results['values']['ipa']['connected']).to eq false
112+
expect(results).to_not be_empty
113+
expect(results['connected']).to eq false
132114
end
133115

134116
it 'should restart the IPA server for further tests' do
@@ -144,15 +126,13 @@ def skip_fips(host)
144126

145127
context 'prior to registration' do
146128
it 'should not have an IPA fact' do
147-
results = JSON.load(on(client, 'puppet facts').output)
148-
149-
expect(results['values']['ipa']).to be_nil
129+
expect(pfact_on(client, 'ipa')).to be_empty
150130
end
151131
end
152132

153133
context 'after registration' do
154134
let(:ipa_server) {
155-
fact_on(hosts_with_role(hosts, 'server').first, 'fqdn')
135+
pfact_on(hosts_with_role(hosts, 'server').first, 'fqdn')
156136
}
157137

158138
it 'should register with the IPA server' do
@@ -171,21 +151,19 @@ def skip_fips(host)
171151
'--principal=admin',
172152
# Admin password
173153
"--password='#{admin_password}'",
174-
# Don't update using authconfig
175-
'--noac'
176154
].join(' ')
177155

178156
on(client, ipa_command)
179157
end
180158

181159
it 'should have the IPA fact populated' do
182-
results = JSON.load(on(client, 'puppet facts').output)
160+
results = pfact_on(client, 'ipa')
183161

184-
expect(results['values']['ipa']).to_not be_nil
185-
expect(results['values']['ipa']['connected']).to eq true
186-
expect(results['values']['ipa']['server']).to eq ipa_server
187-
expect(results['values']['ipa']['domain']).to eq ipa_domain
188-
expect(results['values']['ipa']['realm']).to eq ipa_realm
162+
expect(results).to_not be_empty
163+
expect(results['connected']).to eq true
164+
expect(results['server']).to eq ipa_server
165+
expect(results['domain']).to eq ipa_domain
166+
expect(results['realm']).to eq ipa_realm
189167
end
190168

191169
it 'ipa fact should have unknown status when connection to IPA server is down' do
@@ -194,10 +172,10 @@ def skip_fips(host)
194172
on(server, 'ipactl stop')
195173
end
196174

197-
results = JSON.load(on(client, 'puppet facts').output)
175+
results = pfact_on(client, 'ipa')
198176

199-
expect(results['values']['ipa']).to_not be_nil
200-
expect(results['values']['ipa']['connected']).to eq false
177+
expect(results).to_not be_empty
178+
expect(results['connected']).to eq false
201179
end
202180

203181
it 'should restart the IPA server for further tests' do

spec/acceptance/suites/ipa_fact/nodesets/default.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ HOSTS:
99
server-el7:
1010
roles:
1111
- default
12-
# roles migrated from now-removed el6 node(s):
13-
- no
12+
- no_fips
1413
- server
1514
masterless: true
1615
platform: el-7-x86_64
@@ -19,20 +18,20 @@ HOSTS:
1918
vagrant_memsize: 2048
2019
vagrant_cpus: 2
2120

22-
client-el7:
21+
client-el8:
2322
roles:
2423
- client
2524
masterless: true
26-
platform: el-7-x86_64
27-
box: centos/7
25+
platform: el-8-x86_64
26+
box: generic/centos8
2827
hypervisor: <%= hypervisor %>
2928

30-
client-oel7:
29+
client-el7:
3130
roles:
3231
- client
3332
masterless: true
3433
platform: el-7-x86_64
35-
box: onyxpoint/oel-7-x86_64
34+
box: centos/7
3635
hypervisor: <%= hypervisor %>
3736

3837
CONFIG:

0 commit comments

Comments
 (0)