File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,18 @@ def self.default_vendormoduledir
58
58
end
59
59
end
60
60
61
+ def self . default_cadir
62
+ return "" if Puppet ::Util ::Platform . windows?
63
+ old_ca_dir = "#{ Puppet [ :ssldir ] } /ca"
64
+ new_ca_dir = '/etc/puppetlabs/puppetserver/ca'
65
+
66
+ if File . exist? ( "#{ new_ca_dir } /ca_crt.pem" )
67
+ new_ca_dir
68
+ else
69
+ old_ca_dir
70
+ end
71
+ end
72
+
61
73
############################################################################################
62
74
# NOTE: For information about the available values for the ":type" property of settings,
63
75
# see the docs for Settings.define_settings
@@ -1150,7 +1162,7 @@ def self.initialize_default_settings!(settings)
1150
1162
:desc => "The name to use the Certificate Authority certificate." ,
1151
1163
} ,
1152
1164
:cadir => {
1153
- :default => "$ssldir/ca" ,
1165
+ :default => lambda { default_cadir } ,
1154
1166
:type => :directory ,
1155
1167
:desc => "The root directory for the certificate authority." ,
1156
1168
} ,
Original file line number Diff line number Diff line change 234
234
Puppet . initialize_settings
235
235
end
236
236
end
237
+
238
+ describe "the default cadir" , :unless => Puppet ::Util ::Platform . windows? do
239
+ it 'defaults to inside the ssldir if not migrated' do
240
+ expect ( File ) . to receive ( :exist? ) . with ( '/etc/puppetlabs/puppetserver/ca/ca_crt.pem' ) . and_return ( false )
241
+ expect ( Puppet . default_cadir ) . to eq ( "#{ Puppet [ :ssldir ] } /ca" )
242
+ end
243
+
244
+ it 'returns the new location if there is CA content there' do
245
+ expect ( File ) . to receive ( :exist? ) . with ( '/etc/puppetlabs/puppetserver/ca/ca_crt.pem' ) . and_return ( true )
246
+ expect ( Puppet . default_cadir ) . to eq ( '/etc/puppetlabs/puppetserver/ca' )
247
+ end
248
+
249
+ it 'returns an empty string for Windows platforms' , :if => Puppet ::Util ::Platform . windows? do
250
+ expect ( Puppet . default_cadir ) . to eq ( "" )
251
+ end
252
+ end
237
253
end
You can’t perform that action at this time.
0 commit comments