Skip to content

Commit 721bd4f

Browse files
author
petergmurphy
committed
(PE-40371) Add migration plan for standard architecture
This commit adds a migration plan which utilises backup, install and restore plans to install and restore PE on new infrastructure with a standard architecture. This commit also introduces a new 'migration' option for backup and restore plans, enabling a new migration plan.
1 parent e5f627c commit 721bd4f

File tree

5 files changed

+108
-5
lines changed

5 files changed

+108
-5
lines changed

Diff for: REFERENCE.md

+62-2
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@
6969
* [`enable_replica`](#enable_replica): Execute the enable replica puppet command
7070
* [`filesize`](#filesize): Return the size of a file in bytes
7171
* [`get_group_rules`](#get_group_rules): Run on a PE primary node to return the rules currently applied to the PE Infrastructure Agent group
72+
* [`get_node_group`](#get_node_group): Gets a node group by its ID from the PE Node Classifier
7273
* [`get_peadm_config`](#get_peadm_config): Run on a PE primary node to return the currently configured PEAdm parameters
7374
* [`get_psql_version`](#get_psql_version): Run on a PE PSQL node to return the major version of the PSQL server currently installed
7475
* [`infrastatus`](#infrastatus): Runs puppet infra status and returns the output
7576
* [`mkdir_p_file`](#mkdir_p_file): Create a file with the specified content at the specified location
7677
* [`mv`](#mv): Wrapper task for mv command
78+
* [`node_group_pin`](#node_group_pin): Pins nodes to a specified PE node group
7779
* [`os_identification`](#os_identification): Return the operating system runnin gon the target as a string
7880
* [`pe_install`](#pe_install): Install Puppet Enterprise from a tarball
7981
* [`pe_ldap_config`](#pe_ldap_config): Set the ldap config in the PE console
@@ -108,6 +110,7 @@ Supported use cases:
108110
* [`peadm::backup_ca`](#peadm--backup_ca)
109111
* [`peadm::convert`](#peadm--convert): Convert an existing PE cluster to a PEAdm-managed cluster
110112
* [`peadm::install`](#peadm--install): Install a new PE cluster
113+
* [`peadm::migrate`](#peadm--migrate): Migrate a PE primary server to a new host
111114
* [`peadm::modify_certificate`](#peadm--modify_certificate): Modify the certificate of one or more targets
112115
* [`peadm::replace_failed_postgresql`](#peadm--replace_failed_postgresql): Replaces a failed PostgreSQL host
113116
* [`peadm::restore`](#peadm--restore): Restore puppet primary configuration
@@ -1235,6 +1238,20 @@ Run on a PE primary node to return the rules currently applied to the PE Infrast
12351238

12361239
**Supports noop?** false
12371240

1241+
### <a name="get_node_group"></a>`get_node_group`
1242+
1243+
Gets a node group by its ID from the PE Node Classifier
1244+
1245+
**Supports noop?** false
1246+
1247+
#### Parameters
1248+
1249+
##### `group_id`
1250+
1251+
Data type: `String`
1252+
1253+
The UUID of the node group to retrieve
1254+
12381255
### <a name="get_peadm_config"></a>`get_peadm_config`
12391256

12401257
Run on a PE primary node to return the currently configured PEAdm parameters
@@ -1325,6 +1342,26 @@ Data type: `String`
13251342

13261343
New path of file
13271344

1345+
### <a name="node_group_pin"></a>`node_group_pin`
1346+
1347+
Pins nodes to a specified PE node group
1348+
1349+
**Supports noop?** false
1350+
1351+
#### Parameters
1352+
1353+
##### `node_certnames`
1354+
1355+
Data type: `Array[String]`
1356+
1357+
The certnames of the nodes to pin
1358+
1359+
##### `group_name`
1360+
1361+
Data type: `String`
1362+
1363+
The name of the node group to pin the nodes to
1364+
13281365
### <a name="os_identification"></a>`os_identification`
13291366

13301367
Return the operating system runnin gon the target as a string
@@ -1876,7 +1913,7 @@ This should be the primary puppetserver for the puppet cluster
18761913

18771914
##### <a name="-peadm--backup--backup_type"></a>`backup_type`
18781915

1879-
Data type: `Enum['recovery', 'custom']`
1916+
Data type: `Enum['recovery', 'custom', 'migration']`
18801917

18811918
Currently, the recovery and custom backup types are supported
18821919

@@ -2311,6 +2348,29 @@ Data type: `String`
23112348

23122349
Default value: `'1y'`
23132350

2351+
### <a name="peadm--migrate"></a>`peadm::migrate`
2352+
2353+
Migrate a PE primary server to a new host
2354+
2355+
#### Parameters
2356+
2357+
The following parameters are available in the `peadm::migrate` plan:
2358+
2359+
* [`old_primary_host`](#-peadm--migrate--old_primary_host)
2360+
* [`new_primary_host`](#-peadm--migrate--new_primary_host)
2361+
2362+
##### <a name="-peadm--migrate--old_primary_host"></a>`old_primary_host`
2363+
2364+
Data type: `Peadm::SingleTargetSpec`
2365+
2366+
The existing PE primary server that will be migrated from
2367+
2368+
##### <a name="-peadm--migrate--new_primary_host"></a>`new_primary_host`
2369+
2370+
Data type: `Peadm::SingleTargetSpec`
2371+
2372+
The new server that will become the PE primary server
2373+
23142374
### <a name="peadm--modify_certificate"></a>`peadm::modify_certificate`
23152375

23162376
Certificates can be modified by adding extensions, removing extensions, or
@@ -2444,7 +2504,7 @@ This should be the primary puppetserver for the puppet cluster
24442504

24452505
##### <a name="-peadm--restore--restore_type"></a>`restore_type`
24462506

2447-
Data type: `Enum['recovery', 'recovery-db', 'custom']`
2507+
Data type: `Enum['recovery', 'recovery-db', 'custom', 'migration']`
24482508

24492509
Choose from `recovery`, `recovery-db` and `custom`
24502510

Diff for: functions/migration_opts_default.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ function peadm::migration_opts_default () {
77
'config' => false,
88
'orchestrator' => true,
99
'puppetdb' => true,
10-
'rbac' => true,
10+
'rbac' => false,
1111
}
1212
}

Diff for: plans/backup.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Peadm::SingleTargetSpec $targets,
1313

1414
# backup type determines the backup options
15-
Enum['recovery', 'custom'] $backup_type = 'recovery',
15+
Enum['recovery', 'custom', 'migration'] $backup_type = 'recovery',
1616

1717
# Which data to backup
1818
Peadm::Recovery_opts $backup = {},

Diff for: plans/migrate.pp

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# @summary Migrate a PE primary server to a new host
2+
#
3+
# @param old_primary_host
4+
# The existing PE primary server that will be migrated from
5+
# @param new_primary_host
6+
# The new server that will become the PE primary server
7+
#
8+
plan peadm::migrate (
9+
Peadm::SingleTargetSpec $old_primary_host,
10+
Peadm::SingleTargetSpec $new_primary_host,
11+
) {
12+
peadm::assert_supported_bolt_version()
13+
14+
$backup_file = run_plan('peadm::backup', $old_primary_host, {
15+
backup_type => 'migration',
16+
})
17+
18+
download_file($backup_file['path'], 'backup', $old_primary_host)
19+
20+
$backup_filename = basename($backup_file['path'])
21+
$remote_backup_path = "/tmp/${backup_filename}"
22+
$current_dir = system::env('PWD')
23+
24+
upload_file("${current_dir}/downloads/backup/${old_primary_host}/${backup_filename}", $remote_backup_path, $new_primary_host)
25+
26+
$old_primary_target = get_targets($old_primary_host)[0]
27+
$old_primary_password = peadm::get_pe_conf($old_primary_target)['console_admin_password']
28+
$old_pe_conf = run_task('peadm::get_peadm_config', $old_primary_target).first.value
29+
30+
run_plan('peadm::install', {
31+
primary_host => $new_primary_host,
32+
console_password => $old_primary_password,
33+
code_manager_auto_configure => true,
34+
download_mode => 'direct',
35+
version => $old_pe_conf['pe_version'],
36+
})
37+
38+
run_plan('peadm::restore', {
39+
targets => $new_primary_host,
40+
restore_type => 'migration',
41+
input_file => $remote_backup_path,
42+
})
43+
}

Diff for: plans/restore.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Peadm::SingleTargetSpec $targets,
1313

1414
# restore type determines the restore options
15-
Enum['recovery', 'recovery-db', 'custom'] $restore_type = 'recovery',
15+
Enum['recovery', 'recovery-db', 'custom', 'migration'] $restore_type = 'recovery',
1616

1717
# Which data to restore
1818
Peadm::Recovery_opts $restore = {},

0 commit comments

Comments
 (0)