Skip to content

Commit e13fe4c

Browse files
authored
(PE-38771) Convert plan accepts legacy compilers key in params.json (#476)
* feat(convert): add support for legacy compilers - Introduced `legacy_compilers` parameter to handle legacy compiler hosts. - Added logic to filter and categorize legacy compiler targets. - Updated certificate modification steps to include legacy compiler targets with appropriate extensions. * feat(convert): ensure all targets are up-to-date post conversion - Added a step to run puppet on all targets after restarting services. - Ensures all targets are fully up-to-date after conversion. * docs(convert): update documentation for PEADM module - Corrected the module name from 'peadm' to 'PEADM' for consistency. - Added 'legacy_compilers' section in the example JSON parameters. - Improved clarity in the description of the `begin_at_step` parameter. - Fixed minor grammatical issues in the instructions for converting compilers to legacy. * - Updated REFERENCE.md to include the new parameter.
1 parent bdc7941 commit e13fe4c

File tree

3 files changed

+72
-5
lines changed

3 files changed

+72
-5
lines changed

Diff for: REFERENCE.md

+9
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,7 @@ The following parameters are available in the `peadm::convert` plan:
17191719
* [`primary_host`](#-peadm--convert--primary_host)
17201720
* [`replica_host`](#-peadm--convert--replica_host)
17211721
* [`compiler_hosts`](#-peadm--convert--compiler_hosts)
1722+
* [`legacy_compilers`](#-peadm--convert--legacy_compilers)
17221723
* [`primary_postgresql_host`](#-peadm--convert--primary_postgresql_host)
17231724
* [`replica_postgresql_host`](#-peadm--convert--replica_postgresql_host)
17241725
* [`compiler_pool_address`](#-peadm--convert--compiler_pool_address)
@@ -1747,6 +1748,14 @@ Data type: `Optional[TargetSpec]`
17471748

17481749

17491750

1751+
Default value: `undef`
1752+
1753+
##### <a name="-peadm--convert--legacy_compilers"></a>`legacy_compilers`
1754+
1755+
Data type: `Optional[TargetSpec]`
1756+
1757+
1758+
17501759
Default value: `undef`
17511760

17521761
##### <a name="-peadm--convert--primary_postgresql_host"></a>`primary_postgresql_host`

Diff for: documentation/convert.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Convert infrastructure for use with the peadm module
1+
# Convert infrastructure for use with the PEADM module
22

3-
The peadm::convert plan can be used to adopt manually deployed infrastructure for use with peadm, or to adopt infrastructure deployed with an older version of peadm.
3+
The peadm::convert plan can be used to adopt manually deployed infrastructure for use with PEADM or to adopt infrastructure deployed with an older version of peadm.
44

55
## Convert an Existing Deployment
66

@@ -14,7 +14,10 @@ Prepare to run the plan against all servers in the PE infrastructure, using a pa
1414
"pe-xl-compiler-0.lab1.puppet.vm",
1515
"pe-xl-compiler-1.lab1.puppet.vm"
1616
],
17-
17+
"legacy_compilers": [
18+
"pe-xl-legacy-compiler-0.lab1.puppet.vm",
19+
"pe-xl-legacy-compiler-1.lab1.puppet.vm"
20+
],
1821
"compiler_pool_address": "puppet.lab1.puppet.vm"
1922
}
2023
```
@@ -29,13 +32,13 @@ bolt plan run peadm::convert --params @params.json
2932

3033
This plan is broken down into steps. Normally, the plan runs through all the steps from start to finish. The name of each step is displayed during the plan run, as the step begins.
3134

32-
The `begin_at_step` parameter can be used to facilitate re-running this plan after a failed attempt, skipping past any steps that already completed successfully on the first try and picking up again at the step specified. The step name to resume at can be read from the previous run logs. A full list of available values for this parameter can be viewed by running `bolt plan show peadm::convert`.
35+
The `begin_at_step` parameter can be used to facilitate re-running this plan after a failed attempt, skipping past any steps that were already completed successfully on the first try and picking up again at the step specified. The step name to resume can be read from the previous run logs. A full list of available values for this parameter can be viewed by running `bolt plan show peadm::convert`.
3336

3437
## Convert compilers to legacy
3538

3639
### Puppet Enterprise installed with puppetlabs-peadm version 3.21 or later
3740

38-
To convert compilers to legacy compilers use the `peadm::convert_compiler_to_legacy` plan. This plan will create the needed Node group and Classifier rules to make the compilers legacy. Also will add certificate extensions to those nodes.
41+
To convert compilers to legacy compilers use the `peadm::convert_compiler_to_legacy` plan. This plan will create the needed Node group and Classifier rules to make compilers legacy. Also will add certificate extensions to those nodes.
3942

4043
```shell
4144
bolt plan run peadm::convert_compiler_to_legacy legacy_hosts=compiler1.example.com,compiler2.example.com primary_host=primary.example.com

Diff for: plans/convert.pp

+55
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# Large
1212
Optional[TargetSpec] $compiler_hosts = undef,
13+
Optional[TargetSpec] $legacy_compilers = undef,
1314

1415
# Extra Large
1516
Optional[Peadm::SingleTargetSpec] $primary_postgresql_host = undef,
@@ -36,13 +37,15 @@
3637
$replica_target = peadm::get_targets($replica_host, 1)
3738
$replica_postgresql_target = peadm::get_targets($replica_postgresql_host, 1)
3839
$compiler_targets = peadm::get_targets($compiler_hosts)
40+
$legacy_compiler_targets = peadm::get_targets($legacy_compilers)
3941
$primary_postgresql_target = peadm::get_targets($primary_postgresql_host, 1)
4042

4143
$all_targets = peadm::flatten_compact([
4244
$primary_target,
4345
$replica_target,
4446
$replica_postgresql_target,
4547
$compiler_targets,
48+
$legacy_compiler_targets,
4649
$primary_postgresql_target,
4750
])
4851

@@ -53,6 +56,7 @@
5356
$primary_postgresql_host,
5457
$replica_postgresql_host,
5558
$compiler_hosts,
59+
$legacy_compilers,
5660
)
5761

5862
out::message('# Gathering information')
@@ -115,10 +119,36 @@
115119
$index % 2 != 0
116120
}
117121
}
122+
$legacy_compiler_a_targets = $legacy_compiler_targets.filter |$index,$target| {
123+
$exts = $cert_extensions[$target.peadm::certname()]
124+
if ($exts[peadm::oid('peadm_availability_group')] in ['A', 'B']) {
125+
$exts[peadm::oid('peadm_availability_group')] == 'A'
126+
}
127+
elsif ($exts[peadm::oid('pp_cluster')] in ['A', 'B']) {
128+
$exts[peadm::oid('pp_cluster')] == 'A'
129+
}
130+
else {
131+
$index % 2 == 0
132+
}
133+
}
134+
$legacy_compiler_b_targets = $legacy_compiler_targets.filter |$index,$target| {
135+
$exts = $cert_extensions[$target.peadm::certname()]
136+
if ($exts[peadm::oid('peadm_availability_group')] in ['A', 'B']) {
137+
$exts[peadm::oid('peadm_availability_group')] == 'B'
138+
}
139+
elsif ($exts[peadm::oid('pp_cluster')] in ['A', 'B']) {
140+
$exts[peadm::oid('pp_cluster')] == 'B'
141+
}
142+
else {
143+
$index % 2 != 0
144+
}
145+
}
118146
}
119147
else {
120148
$compiler_a_targets = $compiler_targets
121149
$compiler_b_targets = []
150+
$legacy_compiler_a_targets = $legacy_compiler_targets
151+
$legacy_compiler_b_targets = []
122152
}
123153

124154
# Modify csr_attributes.yaml and insert the peadm-specific OIDs to identify
@@ -185,6 +215,7 @@
185215
add_extensions => {
186216
peadm::oid('pp_auth_role') => 'pe_compiler',
187217
peadm::oid('peadm_availability_group') => 'A',
218+
peadm::oid('peadm_legacy_compiler') => 'false',
188219
},
189220
)
190221
},
@@ -194,6 +225,27 @@
194225
add_extensions => {
195226
peadm::oid('pp_auth_role') => 'pe_compiler',
196227
peadm::oid('peadm_availability_group') => 'B',
228+
peadm::oid('peadm_legacy_compiler') => 'false',
229+
},
230+
)
231+
},
232+
background('modify-compilers-a-certs') || {
233+
run_plan('peadm::modify_certificate', $legacy_compiler_a_targets,
234+
primary_host => $primary_target,
235+
add_extensions => {
236+
peadm::oid('pp_auth_role') => 'pe_compiler',
237+
peadm::oid('peadm_availability_group') => 'A',
238+
peadm::oid('peadm_legacy_compiler') => 'true',
239+
},
240+
)
241+
},
242+
background('modify-compilers-b-certs') || {
243+
run_plan('peadm::modify_certificate', $legacy_compiler_b_targets,
244+
primary_host => $primary_target,
245+
add_extensions => {
246+
peadm::oid('pp_auth_role') => 'pe_compiler',
247+
peadm::oid('peadm_availability_group') => 'B',
248+
peadm::oid('peadm_legacy_compiler') => 'true',
197249
},
198250
)
199251
},
@@ -252,6 +304,9 @@
252304
# completion
253305
run_command('systemctl restart pe-puppetserver.service pe-puppetdb.service',
254306
$all_targets - $primary_target - $primary_postgresql_target - $replica_postgresql_target)
307+
308+
# Run puppet on all targets again to ensure everything is fully up-to-date
309+
run_task('peadm::puppet_runonce', $all_targets)
255310
}
256311

257312
return("Conversion to peadm Puppet Enterprise ${arch['architecture']} completed.")

0 commit comments

Comments
 (0)