Skip to content

Commit 6d77920

Browse files
ragingradavidmalloncares
authored andcommitted
Adding check for missing legacy flag
If missing, adding legacy false to compilers
1 parent 2aaacfc commit 6d77920

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

plans/upgrade.pp

+19-3
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,29 @@
135135

136136
peadm::assert_supported_pe_version($_version, $permit_unsafe_versions)
137137

138+
# Gather certificate extension information from all systems
139+
$cert_extensions_temp = run_task('peadm::cert_data', $all_targets).reduce({}) |$memo,$result| {
140+
$memo + { $result.target.peadm::certname => $result['extensions'] }
141+
}
142+
143+
$compiler_missing_legacy_targets = $cert_extensions_temp.filter |$name,$exts| {
144+
($name in $compiler_targets.map |$t| { $t.name }) and (peadm::oid('peadm_legacy_compiler') in $exts and $exts[peadm::oid('peadm_legacy_compiler')] == undef)
145+
}.keys
146+
147+
run_plan('peadm::modify_certificate', $compiler_missing_legacy_targets,
148+
primary_host => $primary_target,
149+
add_extensions => {
150+
peadm::oid('peadm_legacy_compiler') => 'false',
151+
},
152+
)
153+
138154
# Gather certificate extension information from all systems
139155
$cert_extensions = run_task('peadm::cert_data', $all_targets).reduce({}) |$memo,$result| {
140156
$memo + { $result.target.peadm::certname => $result['extensions'] }
141157
}
142158

143159
$convert_targets = $cert_extensions.filter |$name,$exts| {
144-
($name in $compiler_targets.map |$t| { $t.name }) and ($exts['pp_auth_role'] == undef)
160+
($name in $compiler_targets.map |$t| { $t.name }) and ('pp_auth_role' in $exts and $exts['pp_auth_role'] == undef)
145161
}.keys
146162

147163
# Determine PE version currently installed on primary
@@ -151,8 +167,8 @@
151167

152168
# Ensure needed trusted facts are available
153169
if $cert_extensions.any |$_,$cert| {
154-
[peadm::oid('peadm_role'), 'pp_auth_role'].all |$ext| { $cert[$ext] == undef } or
155-
$cert[peadm::oid('peadm_availability_group')] == undef
170+
[peadm::oid('peadm_role'), 'pp_auth_role'].all |$ext| { $ext in $cert and $cert[$ext] == undef } or
171+
(peadm::oid('peadm_availability_group') in $cert and $cert[peadm::oid('peadm_availability_group')] == undef)
156172
} {
157173
# lint:ignore:strict_indent
158174
fail_plan(@(HEREDOC/L))

spec/plans/upgrade_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def allow_standard_non_returning_calls
2828
.with_params('path' => '/opt/puppetlabs/server/pe_build')
2929
.always_return({ 'content' => '2021.7.3' })
3030

31-
expect_task('peadm::cert_data').return_for_targets('primary' => trusted_primary)
31+
expect_task('peadm::cert_data').return_for_targets('primary' => trusted_primary).be_called_times(2)
3232

3333
expect(run_plan('peadm::upgrade',
3434
'primary_host' => 'primary',
@@ -44,7 +44,7 @@ def allow_standard_non_returning_calls
4444
.always_return({ 'content' => '2021.7.3' })
4545

4646
expect_task('peadm::cert_data').return_for_targets('primary' => trusted_primary,
47-
'compiler' => trusted_compiler)
47+
'compiler' => trusted_compiler).be_called_times(2)
4848

4949
expect(run_plan('peadm::upgrade',
5050
'primary_host' => 'primary',
@@ -93,7 +93,7 @@ def allow_standard_non_returning_calls
9393
.with_params('path' => '/opt/puppetlabs/server/pe_build')
9494
.always_return({ 'content' => installed_version })
9595

96-
expect_task('peadm::cert_data').return_for_targets('primary' => trusted_primary)
96+
expect_task('peadm::cert_data').return_for_targets('primary' => trusted_primary).be_called_times(2)
9797
expect_task('peadm::get_group_rules').return_for_targets('primary' => { '_output' => '{"rules": []}' })
9898
end
9999

0 commit comments

Comments
 (0)