Skip to content

Commit 037999f

Browse files
authored
Merge pull request #128 from puppetlabs/better-idempotency-for-convert
Don't re-issue certs if they have required exts
2 parents d028159 + 4ab8330 commit 037999f

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

Diff for: CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# PEADM module
22

3+
## Unreleased
4+
### Summary
5+
6+
Readme updates and further convert plan efficiency improvements
7+
8+
### Features
9+
10+
- In the peadm::convert plan, certificates which already contain requested extensions will not be re-issued. This will accelerate the convert process, or allow re-runs of the convert process to move more quickly.
11+
12+
### Improvements
13+
14+
- The README now provides more detailed information on how customers using the peadm module should go about getting support for it.
15+
316
## 2.3.0
417
### Summary
518

Diff for: plans/convert.pp

+3-5
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,8 @@
177177
peadm::plan_step('convert-compilers-a') || {
178178
run_plan('peadm::util::add_cert_extensions', $compiler_a_targets,
179179
master_host => $master_target,
180-
remove => ['1.3.6.1.4.1.34380.1.3.13'], # OID form of pp_auth_role
181180
extensions => {
182-
'pp_auth_role' => 'pe_compiler',
181+
peadm::oid('pp_auth_role') => 'pe_compiler',
183182
peadm::oid('peadm_availability_group') => 'A',
184183
},
185184
)
@@ -188,9 +187,8 @@
188187
peadm::plan_step('convert-compilers-b') || {
189188
run_plan('peadm::util::add_cert_extensions', $compiler_b_targets,
190189
master_host => $master_target,
191-
remove => ['1.3.6.1.4.1.34380.1.3.13'], # OID form of pp_auth_role
192190
extensions => {
193-
'pp_auth_role' => 'pe_compiler',
191+
peadm::oid('pp_auth_role') => 'pe_compiler',
194192
peadm::oid('peadm_availability_group') => 'B',
195193
},
196194
)
@@ -236,5 +234,5 @@
236234
run_task('peadm::puppet_runonce', $all_targets - $master_target)
237235
}
238236

239-
return("Conversion to peadm Puppet Enterprise ${arch['architecture']} succeeded.")
237+
return("Conversion to peadm Puppet Enterprise ${arch['architecture']} completed.")
240238
}

Diff for: plans/util/add_cert_extensions.pp

+11-2
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,20 @@
3838

3939
# Loop through and recert each target one at at time, because Bolt lacks
4040
# real parallelism
41-
$all_targets.map |$target| {
41+
$all_targets.each |$target| {
4242
$certname = $certdata[$target]['certname']
43+
$existing_exts = $certdata[$target]['extensions']
4344

4445
# This will be the new trusted fact data for this node
45-
$extension_requests = $certdata[$target]['extensions'] + $extensions
46+
$extension_requests = $existing_exts + $extensions
47+
48+
# If the existing certificate meets all the requirements, there's no need
49+
# to regenerate it. Skip it and move on to the next.
50+
if (($extension_requests.all |$key,$val| { $existing_exts[$key] == $val }) and
51+
!($remove.any |$key| { $key in $existing_exts.keys })) {
52+
out::message("${certname} already has requested extensions; certificate will not be re-issued")
53+
next()
54+
}
4655

4756
# Everything starts the same; we always stop the agent and revoke the
4857
# existing cert. We use `run_command` in case the master is 2019.x but

0 commit comments

Comments
 (0)