Skip to content

Commit 22833fa

Browse files
ragingradavidmalloncares
authored andcommitted
(PE-39397) Adding LDAP endpoint for 2023.8
As rbac-api/v1/ds has been deprecated, and remove in 2023.8, we need to utilise the new endpoint. Adding case for installs of versions 23.8 and above to use rbac-api/v1/command/ldap/create.
1 parent 8d174a7 commit 22833fa

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

Diff for: REFERENCE.md

+6
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,12 @@ Data type: `String`
13841384

13851385
The PE Main server
13861386

1387+
##### `pe_version`
1388+
1389+
Data type: `String`
1390+
1391+
The PE version
1392+
13871393
### <a name="pe_uninstall"></a>`pe_uninstall`
13881394

13891395
Uninstall Puppet Enterprise

Diff for: plans/subplans/configure.pp

+5
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,15 @@
124124
}
125125

126126
if $ldap_config {
127+
$pe_version = run_task('peadm::read_file', $primary_target,
128+
path => '/opt/puppetlabs/server/pe_version',
129+
)[0][content].chomp
130+
127131
# Run the task to configure ldap
128132
$ldap_result = run_task('peadm::pe_ldap_config', $primary_target,
129133
pe_main => $primary_target.peadm::certname(),
130134
ldap_config => $ldap_config,
135+
pe_version => $pe_version,
131136
'_catch_errors' => true,
132137
)
133138

Diff for: tasks/pe_ldap_config.json

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
"pe_main": {
99
"type": "String",
1010
"description": "The PE Main server"
11+
},
12+
"pe_version": {
13+
"type": "String",
14+
"description": "The PE version"
1115
}
1216
},
1317
"input_method": "stdin",

Diff for: tasks/pe_ldap_config.rb

+12-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def main
1212
params = JSON.parse(STDIN.read)
1313
data = params['ldap_config']
1414
pe_main = params['pe_main']
15+
pe_version = params['pe_version']
1516

1617
caf = ['/opt/puppetlabs/bin/puppet', 'config', 'print', 'localcacert']
1718
cafout, cafstatus = Open3.capture2(*caf)
@@ -31,15 +32,23 @@ def main
3132
raise 'Could not get the Key file path.'
3233
end
3334

34-
uri = URI("https://#{pe_main}:4433/rbac-api/v1/ds")
35-
https = Net::HTTP.new(uri.host, uri.port)
35+
if Gem::Version.new(pe_version) < Gem::Version.new('2023.8.0')
36+
ldap_path = URI('rbac-api/v1/ds')
37+
uri = URI("https://#{pe_main}:4433/#{ldap_path}")
38+
req = Net::HTTP::Put.new(uri, 'Content-type' => 'application/json')
39+
else
40+
ldap_path = URI('rbac-api/v1/command/ldap/create')
41+
uri = URI("https://#{pe_main}:4433/#{ldap_path}")
42+
req = Net::HTTP::Post.new(uri, 'Content-type' => 'application/json')
43+
end
44+
45+
https = Net::HTTP.new(pe_main, '4433')
3646
https.use_ssl = true
3747
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
3848
https.ca_file = cafout.strip
3949
https.cert = OpenSSL::X509::Certificate.new(File.read(certout.strip))
4050
https.key = OpenSSL::PKey::RSA.new(File.read(keyout.strip))
4151

42-
req = Net::HTTP::Put.new(uri, 'Content-type' => 'application/json')
4352
req.body = data.to_json
4453

4554
resp = https.request(req)

0 commit comments

Comments
 (0)