Skip to content

(PE-40239) Adding check for missing legacy flag #547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions plans/upgrade.pp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,29 @@

peadm::assert_supported_pe_version($_version, $permit_unsafe_versions)

# Gather certificate extension information from all systems
$cert_extensions_temp = run_task('peadm::cert_data', $all_targets).reduce({}) |$memo,$result| {
$memo + { $result.target.peadm::certname => $result['extensions'] }
}

$compiler_missing_legacy_targets = $cert_extensions_temp.filter |$name,$exts| {
($name in $compiler_targets.map |$t| { $t.name }) and (peadm::oid('peadm_legacy_compiler') in $exts and $exts[peadm::oid('peadm_legacy_compiler')] == undef)
}.keys

run_plan('peadm::modify_certificate', $compiler_missing_legacy_targets,
primary_host => $primary_target,
add_extensions => {
peadm::oid('peadm_legacy_compiler') => 'false',
},
)

# Gather certificate extension information from all systems
$cert_extensions = run_task('peadm::cert_data', $all_targets).reduce({}) |$memo,$result| {
$memo + { $result.target.peadm::certname => $result['extensions'] }
}

$convert_targets = $cert_extensions.filter |$name,$exts| {
($name in $compiler_targets.map |$t| { $t.name }) and ($exts['pp_auth_role'] == undef)
($name in $compiler_targets.map |$t| { $t.name }) and ('pp_auth_role' in $exts and $exts['pp_auth_role'] == undef)
}.keys

# Determine PE version currently installed on primary
Expand All @@ -151,8 +167,8 @@

# Ensure needed trusted facts are available
if $cert_extensions.any |$_,$cert| {
[peadm::oid('peadm_role'), 'pp_auth_role'].all |$ext| { $cert[$ext] == undef } or
$cert[peadm::oid('peadm_availability_group')] == undef
[peadm::oid('peadm_role'), 'pp_auth_role'].all |$ext| { $ext in $cert and $cert[$ext] == undef } or
(peadm::oid('peadm_availability_group') in $cert and $cert[peadm::oid('peadm_availability_group')] == undef)
} {
# lint:ignore:strict_indent
fail_plan(@(HEREDOC/L))
Expand Down
6 changes: 3 additions & 3 deletions spec/plans/upgrade_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def allow_standard_non_returning_calls
.with_params('path' => '/opt/puppetlabs/server/pe_build')
.always_return({ 'content' => '2021.7.3' })

expect_task('peadm::cert_data').return_for_targets('primary' => trusted_primary)
expect_task('peadm::cert_data').return_for_targets('primary' => trusted_primary).be_called_times(2)

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

expect_task('peadm::cert_data').return_for_targets('primary' => trusted_primary,
'compiler' => trusted_compiler)
'compiler' => trusted_compiler).be_called_times(2)

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

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

Expand Down
Loading