@@ -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
0 commit comments