File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -214,11 +214,12 @@ def facts_hash(node)
214
214
'fqdn' => node ,
215
215
'domain' => node . split ( '.' , 2 ) . last ,
216
216
'clientcert' => node ,
217
- 'networking' => {
218
- 'fqdn' => node ,
219
- 'domain' => node . split ( '.' , 2 ) . last ,
220
- 'hostname' => node . split ( '.' ) . first
221
- }
217
+ }
218
+
219
+ networking_facts = {
220
+ 'hostname' => node_facts [ 'hostname' ] ,
221
+ 'fqdn' => node_facts [ 'fqdn' ] ,
222
+ 'domain' => node_facts [ 'domain' ] ,
222
223
}
223
224
224
225
result_facts = if RSpec . configuration . default_facts . any?
@@ -231,6 +232,8 @@ def facts_hash(node)
231
232
result_facts . merge! ( munge_facts ( facts ) ) if self . respond_to? ( :facts )
232
233
result_facts . merge! ( munge_facts ( node_facts ) )
233
234
235
+ ( result_facts [ 'networking' ] ||= { } ) . merge! ( networking_facts )
236
+
234
237
# Facter currently supports lower case facts. Bug FACT-777 has been submitted to support case sensitive
235
238
# facts.
236
239
downcase_facts = Hash [ result_facts . map { |k , v | [ k . downcase , v ] } ]
Original file line number Diff line number Diff line change 8
8
let ( :node ) { 'test123.test.com' }
9
9
let ( :facts ) do
10
10
{
11
- :fqdn => 'notthis.test.com' ,
11
+ :fqdn => 'notthis.test.com' ,
12
+ :networking => {
13
+ :primary => 'eth0' ,
14
+ } ,
12
15
}
13
16
end
14
17
15
18
it { should contain_notify ( 'test123.test.com' ) }
16
19
it { should_not contain_notify ( 'notthis.test.com' ) }
20
+
21
+ context 'existing networking facts should not be clobbered' , :if => Puppet . version . to_f >= 4.0 do
22
+ let ( :pre_condition ) { 'notify { [$facts["networking"]["primary"], $facts["networking"]["hostname"]]: }' }
23
+
24
+ it { should contain_notify ( 'eth0' ) }
25
+ it { should contain_notify ( 'test123' ) }
26
+ end
17
27
end
18
28
end
You can’t perform that action at this time.
0 commit comments