Skip to content

Commit

Permalink
(PE-40371) Add migration plan for standard architecture
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
petergmurphy committed Feb 24, 2025
1 parent e5f627c commit 3544a79
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 5 deletions.
64 changes: 62 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@
* [`enable_replica`](#enable_replica): Execute the enable replica puppet command
* [`filesize`](#filesize): Return the size of a file in bytes
* [`get_group_rules`](#get_group_rules): Run on a PE primary node to return the rules currently applied to the PE Infrastructure Agent group
* [`get_node_group`](#get_node_group): Gets a node group by its ID from the PE Node Classifier
* [`get_peadm_config`](#get_peadm_config): Run on a PE primary node to return the currently configured PEAdm parameters
* [`get_psql_version`](#get_psql_version): Run on a PE PSQL node to return the major version of the PSQL server currently installed
* [`infrastatus`](#infrastatus): Runs puppet infra status and returns the output
* [`mkdir_p_file`](#mkdir_p_file): Create a file with the specified content at the specified location
* [`mv`](#mv): Wrapper task for mv command
* [`node_group_pin`](#node_group_pin): Pins nodes to a specified PE node group
* [`os_identification`](#os_identification): Return the operating system runnin gon the target as a string
* [`pe_install`](#pe_install): Install Puppet Enterprise from a tarball
* [`pe_ldap_config`](#pe_ldap_config): Set the ldap config in the PE console
Expand Down Expand Up @@ -108,6 +110,7 @@ Supported use cases:
* [`peadm::backup_ca`](#peadm--backup_ca)
* [`peadm::convert`](#peadm--convert): Convert an existing PE cluster to a PEAdm-managed cluster
* [`peadm::install`](#peadm--install): Install a new PE cluster
* [`peadm::migrate`](#peadm--migrate)
* [`peadm::modify_certificate`](#peadm--modify_certificate): Modify the certificate of one or more targets
* [`peadm::replace_failed_postgresql`](#peadm--replace_failed_postgresql): Replaces a failed PostgreSQL host
* [`peadm::restore`](#peadm--restore): Restore puppet primary configuration
Expand Down Expand Up @@ -1235,6 +1238,20 @@ Run on a PE primary node to return the rules currently applied to the PE Infrast

**Supports noop?** false

### <a name="get_node_group"></a>`get_node_group`

Gets a node group by its ID from the PE Node Classifier

**Supports noop?** false

#### Parameters

##### `group_id`

Data type: `String`

The UUID of the node group to retrieve

### <a name="get_peadm_config"></a>`get_peadm_config`

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

New path of file

### <a name="node_group_pin"></a>`node_group_pin`

Pins nodes to a specified PE node group

**Supports noop?** false

#### Parameters

##### `node_certnames`

Data type: `Array[String]`

The certnames of the nodes to pin

##### `group_name`

Data type: `String`

The name of the node group to pin the nodes to

### <a name="os_identification"></a>`os_identification`

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

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

Data type: `Enum['recovery', 'custom']`
Data type: `Enum['recovery', 'custom', 'migration']`

Currently, the recovery and custom backup types are supported

Expand Down Expand Up @@ -2311,6 +2348,29 @@ Data type: `String`

Default value: `'1y'`

### <a name="peadm--migrate"></a>`peadm::migrate`

The peadm::migrate class.

#### Parameters

The following parameters are available in the `peadm::migrate` plan:

* [`old_primary_host`](#-peadm--migrate--old_primary_host)
* [`new_primary_host`](#-peadm--migrate--new_primary_host)

##### <a name="-peadm--migrate--old_primary_host"></a>`old_primary_host`

Data type: `Peadm::SingleTargetSpec`



##### <a name="-peadm--migrate--new_primary_host"></a>`new_primary_host`

Data type: `Peadm::SingleTargetSpec`



### <a name="peadm--modify_certificate"></a>`peadm::modify_certificate`

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

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

Data type: `Enum['recovery', 'recovery-db', 'custom']`
Data type: `Enum['recovery', 'recovery-db', 'custom', 'migration']`

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

Expand Down
2 changes: 1 addition & 1 deletion functions/migration_opts_default.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ function peadm::migration_opts_default () {
'config' => false,
'orchestrator' => true,
'puppetdb' => true,
'rbac' => true,
'rbac' => false,
}
}
2 changes: 1 addition & 1 deletion plans/backup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Peadm::SingleTargetSpec $targets,

# backup type determines the backup options
Enum['recovery', 'custom'] $backup_type = 'recovery',
Enum['recovery', 'custom', 'migration'] $backup_type = 'recovery',

# Which data to backup
Peadm::Recovery_opts $backup = {},
Expand Down
36 changes: 36 additions & 0 deletions plans/migrate.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
plan peadm::migrate (
Peadm::SingleTargetSpec $old_primary_host,
Peadm::SingleTargetSpec $new_primary_host,
) {
peadm::assert_supported_bolt_version()

$backup_file = run_plan('peadm::backup', $old_primary_host, {
backup_type => 'migration',
})

download_file($backup_file['path'], 'backup', $old_primary_host)

$backup_filename = basename($backup_file['path'])
$remote_backup_path = "/tmp/${backup_filename}"
$current_dir = system::env('PWD')

upload_file("${current_dir}/downloads/backup/${old_primary_host}/${backup_filename}", $remote_backup_path, $new_primary_host)

$old_primary_target = get_targets($old_primary_host)[0]
$old_primary_password = peadm::get_pe_conf($old_primary_target)['console_admin_password']
$old_pe_conf = run_task('peadm::get_peadm_config', $old_primary_target).first.value

run_plan('peadm::install', {
primary_host => $new_primary_host,
console_password => $old_primary_password,
code_manager_auto_configure => true,
download_mode => 'direct',
version => $old_pe_conf['pe_version'],
})

run_plan('peadm::restore', {
targets => $new_primary_host,
restore_type => 'migration',
input_file => $remote_backup_path,
})
}
2 changes: 1 addition & 1 deletion plans/restore.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Peadm::SingleTargetSpec $targets,

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

# Which data to restore
Peadm::Recovery_opts $restore = {},
Expand Down

0 comments on commit 3544a79

Please sign in to comment.