Skip to content

Commit 90a1318

Browse files
author
petergmurphy
committed
New changes
1 parent bba2ae0 commit 90a1318

13 files changed

+252
-82
lines changed

Diff for: REFERENCE.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
* [`backup_classification`](#backup_classification): A task to call the classification api and write to file
6161
* [`cert_data`](#cert_data): Return certificate data related to the Puppet agent
6262
* [`cert_valid_status`](#cert_valid_status): Check primary for valid state of a certificate
63+
* [`check_pe_master_rules`](#check_pe_master_rules): Checks if the PE Master group rules have already been updated to support 'pe_compiler_legacy' as a pp_auth_role
6364
* [`classify_compilers`](#classify_compilers): Classify compilers as legacy or non-legacy
6465
* [`code_manager`](#code_manager): Perform various code manager actions
6566
* [`code_manager_enabled`](#code_manager_enabled): Run on a PE primary node to check if Code Manager is enabled.
@@ -91,6 +92,7 @@
9192
* [`ssl_clean`](#ssl_clean): Clean an agent's certificate
9293
* [`submit_csr`](#submit_csr): Submit a certificate signing request
9394
* [`transform_classification_groups`](#transform_classification_groups): Transform the user groups from a source backup to a list of groups on the target server
95+
* [`update_pe_master_rules`](#update_pe_master_rules): Updates the PE Master group rules to replace pe_compiler with a regex match for any pe_compiler role
9496
* [`validate_rbac_token`](#validate_rbac_token): Check an RBAC token stored in a file is valid
9597
* [`wait_until_service_ready`](#wait_until_service_ready): Return when the orchestrator service is healthy, or timeout after 15 seconds
9698

@@ -130,7 +132,6 @@ Supported use cases:
130132
* `peadm::subplans::modify_certificate`
131133
* `peadm::subplans::prepare_agent`
132134
* `peadm::uninstall`: Single-entry-point plan for uninstalling Puppet Enterprise
133-
* `peadm::update_compiler_extensions`
134135
* `peadm::util::code_sync_status`
135136
* `peadm::util::copy_file`
136137
* `peadm::util::db_disable_pglogical`
@@ -1111,6 +1112,12 @@ Data type: `String`
11111112

11121113
The certifcate name to check validation of
11131114

1115+
### <a name="check_pe_master_rules"></a>`check_pe_master_rules`
1116+
1117+
Checks if the PE Master group rules have already been updated to support 'pe_compiler_legacy' as a pp_auth_role
1118+
1119+
**Supports noop?** false
1120+
11141121
### <a name="classify_compilers"></a>`classify_compilers`
11151122

11161123
Classify compilers as legacy or non-legacy
@@ -1643,6 +1650,12 @@ Data type: `String`
16431650

16441651
Location of target node group yaml file and where to create the transformed file
16451652

1653+
### <a name="update_pe_master_rules"></a>`update_pe_master_rules`
1654+
1655+
Updates the PE Master group rules to replace pe_compiler with a regex match for any pe_compiler role
1656+
1657+
**Supports noop?** false
1658+
16461659
### <a name="validate_rbac_token"></a>`validate_rbac_token`
16471660

16481661
Check an RBAC token stored in a file is valid

Diff for: manifests/setup/legacy_compiler_group.pp

+4-6
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010

1111
node_group { 'PE Legacy Compiler':
1212
ensure => 'present',
13-
parent => 'PE Infrastructure',
13+
parent => 'PE Master',
1414
purge_behavior => 'rule',
1515
rule => ['=', ['trusted', 'extensions', 'pp_auth_role'], 'pe_compiler_legacy'],
1616
classes => {
17-
'puppet_enterprise::profile::master' => {
18-
'puppetdb_host' => [$internal_compiler_a_pool_address, $internal_compiler_b_pool_address].filter |$_| { $_ },
19-
'puppetdb_port' => [8081],
20-
'replication_mode' => 'none',
21-
'code_manager_auto_configure' => true,
17+
'puppet_enterprise::profile::master' => {
18+
'puppetdb_host' => [$internal_compiler_a_pool_address, $internal_compiler_b_pool_address].filter |$_| { $_ },
19+
'puppetdb_port' => [8081],
2220
},
2321
},
2422
}

Diff for: plans/add_compilers.pp

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
$compiler_targets = peadm::get_targets($compiler_hosts)
1717
$primary_target = peadm::get_targets($primary_host, 1)
1818

19+
# Check if PE Master rules have been updated to support pe_compiler_legacy
20+
$rules_check = run_task('peadm::check_pe_master_rules', $primary_host).first.value
21+
unless $rules_check['updated'] {
22+
fail_plan('Please run the Convert plan to convert your Puppet infrastructure to be managed by this version of PEADM.')
23+
}
24+
1925
# Get current peadm config to determine where to setup additional rules for
2026
# compiler's secondary PuppetDB instances
2127
$peadm_config = run_task('peadm::get_peadm_config', $primary_target).first.value

Diff for: plans/convert.pp

+45-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,48 @@
6060

6161
out::message('# Gathering information')
6262

63+
$cert_extensions_temp = run_task('peadm::cert_data', $all_targets).reduce({}) |$memo,$result| {
64+
$memo + { $result.target.peadm::certname() => $result['extensions'] }
65+
}
66+
67+
# Add legacy compiler role to compilers that are missing it
68+
$compilers_with_legacy_compiler_flag = $cert_extensions_temp.filter |$name,$exts| {
69+
($name in $compiler_targets.map |$t| { $t.name } or $name in $legacy_compiler_targets.map |$t| { $t.name }) and
70+
($exts[peadm::oid('peadm_legacy_compiler')] != undef)
71+
}
72+
73+
if $compilers_with_legacy_compiler_flag.size > 0 {
74+
$legacy_compilers_with_flag = $compilers_with_legacy_compiler_flag.filter |$name,$exts| {
75+
$exts[peadm::oid('peadm_legacy_compiler')] == 'true'
76+
}.keys
77+
78+
$modern_compilers_with_flag = $compilers_with_legacy_compiler_flag.filter |$name,$exts| {
79+
$exts[peadm::oid('peadm_legacy_compiler')] == 'false'
80+
}.keys
81+
82+
if $modern_compilers_with_flag.size > 0 {
83+
run_plan('peadm::modify_certificate', $modern_compilers_with_flag,
84+
primary_host => $primary_target,
85+
remove_extensions => [peadm::oid('peadm_legacy_compiler')],
86+
)
87+
}
88+
89+
if $legacy_compilers_with_flag.size > 0 {
90+
run_plan('peadm::modify_certificate', $legacy_compilers_with_flag,
91+
primary_host => $primary_target,
92+
add_extensions => {
93+
'pp_auth_role' => 'pe_compiler_legacy',
94+
},
95+
remove_extensions => [peadm::oid('peadm_legacy_compiler'), peadm::oid('pp_auth_role')],
96+
)
97+
}
98+
99+
run_task('peadm::puppet_runonce', peadm::flatten_compact([
100+
$compiler_targets,
101+
$legacy_compiler_targets,
102+
]))
103+
}
104+
63105
# Get trusted fact information for all compilers. Use peadm::certname() as
64106
# the hash key because the apply block below will break trying to parse the
65107
# $compiler_extensions variable if it has Target-type hash keys.
@@ -318,6 +360,9 @@
318360
run_command('systemctl restart pe-puppetserver.service pe-puppetdb.service', $compiler_targets)
319361
}
320362
363+
# Update PE Master rules to support legacy compilers
364+
run_task('peadm::update_pe_master_rules', $primary_target)
365+
321366
# Run puppet on all targets again to ensure everything is fully up-to-date
322367
run_task('peadm::puppet_runonce', $all_targets)
323368
}
@@ -333,7 +378,5 @@
333378
# lint:endignore
334379
}
335380
336-
run_task('peadm::update_pe_master_rules', $primary_target)
337-
338381
return("Conversion to peadm Puppet Enterprise ${arch['architecture']} completed.")
339382
}

Diff for: plans/convert_compiler_to_legacy.pp

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
$primary_target = peadm::get_targets($primary_host, 1)
88
$convert_legacy_compiler_targets = peadm::get_targets($legacy_hosts)
99

10+
# Check if PE Master rules have been updated to support pe_compiler_legacy
11+
$rules_check = run_task('peadm::check_pe_master_rules', $primary_target).first.value
12+
unless $rules_check['updated'] {
13+
fail_plan('Please run the Convert plan to convert your Puppet infrastructure to be managed by this version of PEADM.')
14+
}
15+
1016
$cluster = run_task('peadm::get_peadm_config', $primary_host).first.value
1117
$error = getvar('cluster.error')
1218
if $error {

Diff for: plans/install.pp

-2
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@
143143
final_agent_state => $final_agent_state,
144144
)
145145

146-
run_task('peadm::update_pe_master_rules', $primary_host)
147-
148146
# Return a string banner reporting on what was done
149147
return([$install_result, $configure_result])
150148
}

Diff for: plans/subplans/configure.pp

+4
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,9 @@
174174
$legacy_compiler_targets,
175175
]))
176176

177+
# Update PE Master rules to support legacy compilers
178+
run_task('peadm::update_pe_master_rules', $primary_host)
179+
run_task('peadm::puppet_runonce', $legacy_compiler_targets)
180+
177181
return("Configuration of Puppet Enterprise ${arch['architecture']} succeeded.")
178182
}

Diff for: plans/update_compiler_extensions.pp

-20
This file was deleted.

Diff for: plans/upgrade.pp

+3-32
Original file line numberDiff line numberDiff line change
@@ -146,41 +146,12 @@
146146
($exts[peadm::oid('peadm_legacy_compiler')] != undef)
147147
}
148148

149-
run_task('peadm::update_pe_master_rules', $primary_target)
150-
151149
if $compilers_with_legacy_compiler_flag.size > 0 {
152-
$legacy_compilers = $compilers_with_legacy_compiler_flag.filter |$name,$exts| {
153-
$exts[peadm::oid('peadm_legacy_compiler')] == 'true'
154-
}.keys
155-
156-
$modern_compilers = $compilers_with_legacy_compiler_flag.filter |$name,$exts| {
157-
$exts[peadm::oid('peadm_legacy_compiler')] == 'false'
158-
}.keys
159-
160-
if $modern_compilers.size > 0 {
161-
out::message('MODERN COMPILERS: Beginning removal of legacy compiler flag')
162-
out::message($modern_compilers)
163-
run_plan('peadm::modify_certificate', $modern_compilers,
164-
primary_host => $primary_target,
165-
remove_extensions => [peadm::oid('peadm_legacy_compiler')],
166-
)
167-
out::message('MODERN COMPILERS: Removed legacy compiler flag')
168-
}
169-
170-
if $legacy_compilers.size > 0 {
171-
out::message('LEGACY COMPILERS: Beginning addition of legacy compiler role and removal of legacy compiler flag')
172-
out::message($legacy_compilers)
173-
run_plan('peadm::modify_certificate', $legacy_compilers,
174-
primary_host => $primary_target,
175-
add_extensions => {
176-
'pp_auth_role' => 'pe_compiler_legacy',
177-
},
178-
remove_extensions => [peadm::oid('peadm_legacy_compiler'), peadm::oid('pp_auth_role')],
179-
)
180-
out::message('LEGACY COMPILERS: Added legacy compiler role and removed legacy compiler flag')
181-
}
150+
fail_plan('Please run the Convert plan to convert your Puppet infrastructure to be managed by this version of PEADM.')
182151
}
183152

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

Diff for: tasks/check_pe_master_rules.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"description": "Checks if the PE Master group rules have already been updated to support 'pe_compiler_legacy' as a pp_auth_role",
3+
"input_method": "stdin",
4+
"private": true,
5+
"implementations": [
6+
{"name": "check_pe_master_rules.rb"}
7+
],
8+
"parameters": {},
9+
"supports_noop": false,
10+
"output": {
11+
"updated": {
12+
"description": "Whether the PE Master rules have already been updated",
13+
"type": "Boolean"
14+
},
15+
"message": {
16+
"description": "A message describing the current state of the PE Master rules",
17+
"type": "String"
18+
},
19+
"error": {
20+
"description": "Error message if the task failed",
21+
"type": "Optional[String]"
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)