Skip to content

Commit db6e58e

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 db6e58e

File tree

5 files changed

+72
-5
lines changed

5 files changed

+72
-5
lines changed

Diff for: REFERENCE.md

+26-2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Supported use cases:
108108
* [`peadm::backup_ca`](#peadm--backup_ca)
109109
* [`peadm::convert`](#peadm--convert): Convert an existing PE cluster to a PEAdm-managed cluster
110110
* [`peadm::install`](#peadm--install): Install a new PE cluster
111+
* [`peadm::migrate`](#peadm--migrate): Migrate a PE primary server to a new host
111112
* [`peadm::modify_certificate`](#peadm--modify_certificate): Modify the certificate of one or more targets
112113
* [`peadm::replace_failed_postgresql`](#peadm--replace_failed_postgresql): Replaces a failed PostgreSQL host
113114
* [`peadm::restore`](#peadm--restore): Restore puppet primary configuration
@@ -1876,7 +1877,7 @@ This should be the primary puppetserver for the puppet cluster
18761877

18771878
##### <a name="-peadm--backup--backup_type"></a>`backup_type`
18781879

1879-
Data type: `Enum['recovery', 'custom']`
1880+
Data type: `Enum['recovery', 'custom', 'migration']`
18801881

18811882
Currently, the recovery and custom backup types are supported
18821883

@@ -2311,6 +2312,29 @@ Data type: `String`
23112312

23122313
Default value: `'1y'`
23132314

2315+
### <a name="peadm--migrate"></a>`peadm::migrate`
2316+
2317+
Migrate a PE primary server to a new host
2318+
2319+
#### Parameters
2320+
2321+
The following parameters are available in the `peadm::migrate` plan:
2322+
2323+
* [`old_primary_host`](#-peadm--migrate--old_primary_host)
2324+
* [`new_primary_host`](#-peadm--migrate--new_primary_host)
2325+
2326+
##### <a name="-peadm--migrate--old_primary_host"></a>`old_primary_host`
2327+
2328+
Data type: `Peadm::SingleTargetSpec`
2329+
2330+
The existing PE primary server that will be migrated from
2331+
2332+
##### <a name="-peadm--migrate--new_primary_host"></a>`new_primary_host`
2333+
2334+
Data type: `Peadm::SingleTargetSpec`
2335+
2336+
The new server that will become the PE primary server
2337+
23142338
### <a name="peadm--modify_certificate"></a>`peadm::modify_certificate`
23152339

23162340
Certificates can be modified by adding extensions, removing extensions, or
@@ -2444,7 +2468,7 @@ This should be the primary puppetserver for the puppet cluster
24442468

24452469
##### <a name="-peadm--restore--restore_type"></a>`restore_type`
24462470

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

24492473
Choose from `recovery`, `recovery-db` and `custom`
24502474

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)