Skip to content

Commit ebb96d1

Browse files
committed
Expand scenario where clean failure is acceptable
Acceptable failures when running clean on a primary expanded to address scenarios where an infrastructure component is cleaned by another process, e.g. puppet infrastructure forget
1 parent 5486105 commit ebb96d1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

plans/subplans/modify_certificate.pp

+4-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
$certdata = run_task('peadm::cert_data', $target).first.value
2222
$certname = $certdata['certname']
2323

24-
25-
2624
$target_is_primary = ($certname == $primary_certname)
2725

2826
# These vars represent what the extensions currently are, vs. what they should be
@@ -68,13 +66,13 @@
6866
# fail the plan unless it's a known circumstance in which it's okay to proceed.
6967
# Scenario 1: the primary's cert can't be cleaned because it's already revoked.
7068
# Scenario 2: the primary's cert can't be cleaned because it's been deleted.
71-
# Scenario 3: a component's cert can't be cleaned because it was previously by some other function.
69+
# Scenario 3: any component's cert can't be cleaned because it's been deleted.
7270
unless ($target_is_primary and
7371
($ca_clean_result[merged_output] =~ /certificate revoked/ or
74-
$ca_clean_result[merged_output] =~ /Could not find 'hostcert'/ or
75-
$ca_clean_result[merged_output] =~ /Could not find files to clean/))
72+
$ca_clean_result[merged_output] =~ /Could not find 'hostcert'/)) or
73+
($ca_clean_result[merged_output] =~ /Could not find files to clean/)
7674
{
77-
fail_plan($ca_clean_result)
75+
fail_plan($ca_clean_result[merged_output])
7876
}
7977
}
8078

plans/subplans/prepare_agent.pp

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@
4040
$certstatus = run_task('peadm::cert_valid_status', $primary_target,
4141
certname => $agent_target.peadm::certname()).first.value
4242

43+
# Obtain data about certificate from agent
44+
$certdata = run_task('peadm::cert_data', $agent_target).first.value
45+
4346
if ($certstatus['certificate-status'] == 'invalid') {
4447
$force_regenerate = true
4548
$skip_csr = true
4649
} else {
50+
if $certdata['certificate-exists'] and $certstatus['reason'] =~ /The private key is missing from/ {
51+
out::message("Agent: ${agent_target.peadm::certname()} has a local cert but Primary: ${primary_target.peadm::certname()} does not, force agent clean")
52+
run_task('peadm::ssl_clean', $agent_target, certname => $agent_target.peadm::certname())
53+
}
4754
$force_regenerate = false
4855
$skip_csr = false
49-
5056
}
5157
5258
# Ensures scenarios where agent was pre-installed but never on-boarding and

0 commit comments

Comments
 (0)