Skip to content

Commit 08ec2d4

Browse files
authored
Fix ipa fact (#299)
Also fix beaker tests for ipa fact. Closes #296
1 parent d10bc45 commit 08ec2d4

7 files changed

Lines changed: 37 additions & 16 deletions

File tree

.fixtures.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ fixtures:
55
simpkv: https://github.com/simp/pupmod-simp-simpkv.git
66
stdlib: https://github.com/simp/puppetlabs-stdlib.git
77
systemd: https://github.com/simp/puppet-systemd.git
8+
augeasproviders_sysctl: https://github.com/simp/augeasproviders_sysctl.git
9+
augeasproviders_core: https://github.com/simp/augeasproviders_core.git
810

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

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* Fri Dec 13 2024 Steven Pritchard <steve@sicura.us> - 4.12.3
2+
- Fix `ipa` fact (#296)
3+
14
* Fri Jan 19 2024 ben <benrobertson9876@gmail.com> - 4.12.2
25
- Fix simplib__crypto_policy_state fact to include custom policies
36

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ group :system_tests do
3838
gem 'bcrypt_pbkdf'
3939
gem 'beaker'
4040
gem 'beaker-rspec'
41-
gem 'simp-beaker-helpers', ENV.fetch('SIMP_BEAKER_HELPERS_VERSION', ['>= 1.32.1', '< 2'])
41+
gem 'simp-beaker-helpers', ENV.fetch('SIMP_BEAKER_HELPERS_VERSION', ['>= 1.34.3', '< 2'])
4242
end
4343

4444
# Evaluate extra gemfiles if they exist

lib/facter/ipa.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
# We won't know if we are connected to a server until later
7070
defaults['connected'] = false
7171

72-
klist_retval = Puppet::Util::Execution.execute("#{klist} -s")
72+
klist_retval = Puppet::Util::Execution.execute("#{klist} -s", fail_on_fail: false)
7373
unless klist_retval.exitstatus.zero?
7474
# Obtain host Kerberos token so we can use IPA API
7575
kinit_msg = Facter::Core::Execution.execute("#{kinit} -k 2>&1", options = {:timeout => kinit_timeout})

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simp-simplib",
3-
"version": "4.12.2",
3+
"version": "4.12.3",
44
"author": "SIMP Team",
55
"summary": "A collection of common SIMP functions, facts, and types",
66
"license": "Apache-2.0",

spec/acceptance/suites/ipa_fact/ipa_fact_spec.rb

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,17 @@ def skip_fips(host)
3535
on(host, 'puppet resource package ipa-client ensure=present')
3636
end
3737

38+
it 'enables ipv6' do
39+
on(host, 'puppet resource sysctl net.ipv6.conf.all.disable_ipv6 ensure=present value=0 target=/etc/sysctl.conf')
40+
on(host, 'puppet resource sysctl net.ipv6.conf.lo.disable_ipv6 ensure=present value=0 target=/etc/sysctl.conf')
41+
end
42+
43+
it 'configures the firewall' do
44+
on(host, 'systemctl is-active firewalld.service && firewall-cmd --add-port={{80,443,389,636,88,464,53}/tcp,{88,464,53,123}/udp} --permanent')
45+
end
46+
3847
it 'should ensure hostname is set to the FQDN' do
39-
hostname = pfact_on(host, 'fqdn')
48+
hostname = pfact_on(host, 'networking.fqdn')
4049
on(host, "hostnamectl set-hostname #{hostname}")
4150

4251
# DBus may need to be restarted after updating, and a reboot is the only way
@@ -52,7 +61,7 @@ def skip_fips(host)
5261
results = apply_manifest_on(server, manifest)
5362
expect(results.output).to match(/Notice: Type => NilClass Content => null/)
5463

55-
expect(pfact_on(server, 'ipa')).to be_empty
64+
expect(pfact_on(server, 'ipa')).to be_nil.or be_empty
5665
end
5766
end
5867

@@ -65,7 +74,7 @@ def skip_fips(host)
6574
results = apply_manifest_on(server, manifest)
6675
expect(results.output).to match(/Notice: Type => NilClass Content => null/)
6776

68-
expect(pfact_on(server, 'ipa')).to be_empty
77+
expect(pfact_on(server, 'ipa')).to be_nil.or be_empty
6978
end
7079
end
7180

@@ -74,7 +83,7 @@ def skip_fips(host)
7483
it 'ipa fact should contain domain and IPA server' do
7584
# ipa-server-install installs both the IPA server and client.
7685
# The fact uses the client env.
77-
fqdn = pfact_on(server, 'fqdn')
86+
fqdn = pfact_on(server, 'networking.fqdn')
7887

7988
cmd = [
8089
'umask 0022 &&',
@@ -96,7 +105,8 @@ def skip_fips(host)
96105

97106
results = pfact_on(server, 'ipa')
98107

99-
expect(results).to_not be_empty
108+
expect(results).to be_a(Hash)
109+
expect(results).not_to be_empty
100110
expect(results['connected']).to eq true
101111
expect(results['server']).to eq fqdn
102112
expect(results['domain']).to eq ipa_domain
@@ -109,7 +119,8 @@ def skip_fips(host)
109119

110120
results = pfact_on(server, 'ipa')
111121

112-
expect(results).to_not be_empty
122+
expect(results).to be_a(Hash)
123+
expect(results).not_to be_empty
113124
expect(results['connected']).to eq false
114125
end
115126

@@ -126,16 +137,17 @@ def skip_fips(host)
126137

127138
context 'prior to registration' do
128139
it 'should not have an IPA fact' do
129-
expect(pfact_on(client, 'ipa')).to be_empty
140+
expect(pfact_on(client, 'ipa')).to be_nil.or be_empty
130141
end
131142
end
132143

133144
context 'after registration' do
134145
let(:ipa_server) {
135-
pfact_on(hosts_with_role(hosts, 'server').first, 'fqdn')
146+
pfact_on(hosts_with_role(hosts, 'server').first, 'networking.fqdn')
136147
}
137148

138149
it 'should register with the IPA server' do
150+
os = fact_on(client, 'os')
139151
ipa_command = [
140152
# Unattended installation
141153
'ipa-client-install -U',
@@ -152,14 +164,17 @@ def skip_fips(host)
152164
# Admin password
153165
"--password='#{admin_password}'",
154166
].join(' ')
167+
# Force ntpd support on EL7
168+
ipa_command += ' --force-ntpd' if os.dig('release', 'major') == '7'
155169

156170
on(client, ipa_command)
157171
end
158172

159173
it 'should have the IPA fact populated' do
160174
results = pfact_on(client, 'ipa')
161175

162-
expect(results).to_not be_empty
176+
expect(results).to be_a(Hash)
177+
expect(results).not_to be_empty
163178
expect(results['connected']).to eq true
164179
expect(results['server']).to eq ipa_server
165180
expect(results['domain']).to eq ipa_domain
@@ -174,7 +189,8 @@ def skip_fips(host)
174189

175190
results = pfact_on(client, 'ipa')
176191

177-
expect(results).to_not be_empty
192+
expect(results).to be_a(Hash)
193+
expect(results).not_to be_empty
178194
expect(results['connected']).to eq false
179195
end
180196

spec/unit/facter/ipa_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
before(:each) do
8282
allow(File).to receive(:exist?).with('/etc/ipa/default.conf').and_return(true)
8383
allow(File).to receive(:read).with('/etc/ipa/default.conf').and_return(default_conf.dup)
84-
allow(Puppet::Util::Execution).to receive(:execute).with('/usr/bin/klist -s').and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))
84+
allow(Puppet::Util::Execution).to receive(:execute).with('/usr/bin/klist -s', fail_on_fail: false).and_return(Puppet::Util::Execution::ProcessOutput.new('', 0))
8585
allow(Facter::Core::Execution).to receive(:execute).with(ipa_env_query, ipa_query_options).and_return(ipa_env)
8686
allow(Facter::Core::Execution).to receive(:execute).with(ipa_env_server_query, ipa_query_options).and_return(ipa_server_env)
8787
end
@@ -103,7 +103,7 @@
103103
before(:each) do
104104
allow(File).to receive(:exist?).with('/etc/ipa/default.conf').and_return(true)
105105
allow(File).to receive(:read).with('/etc/ipa/default.conf').and_return(default_conf)
106-
allow(Puppet::Util::Execution).to receive(:execute).with('/usr/bin/klist -s').and_return(Puppet::Util::Execution::ProcessOutput.new('', 1))
106+
allow(Puppet::Util::Execution).to receive(:execute).with('/usr/bin/klist -s', fail_on_fail: false).and_return(Puppet::Util::Execution::ProcessOutput.new('', 1))
107107
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/kinit -k 2>&1', kinit_query_options).and_return('')
108108
allow(Facter::Core::Execution).to receive(:execute).with(ipa_env_query, ipa_query_options).and_return(ipa_env)
109109
allow(Facter::Core::Execution).to receive(:execute).with(ipa_env_server_query, ipa_query_options).and_return(ipa_server_env)
@@ -125,7 +125,7 @@
125125
before(:each) do
126126
allow(File).to receive(:exist?).with('/etc/ipa/default.conf').and_return(true)
127127
allow(File).to receive(:read).with('/etc/ipa/default.conf').and_return(default_conf)
128-
allow(Puppet::Util::Execution).to receive(:execute).with('/usr/bin/klist -s').and_return(Puppet::Util::Execution::ProcessOutput.new('', 1))
128+
allow(Puppet::Util::Execution).to receive(:execute).with('/usr/bin/klist -s', fail_on_fail: false).and_return(Puppet::Util::Execution::ProcessOutput.new('', 1))
129129
allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/kinit -k 2>&1', kinit_query_options).and_return('some error message')
130130
allow(Facter::Core::Execution).to receive(:execute).with(ipa_env_query, ipa_query_options).and_return('')
131131
end

0 commit comments

Comments
 (0)