Skip to content
27 changes: 27 additions & 0 deletions plans/migrate.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,41 @@
# @param upgrade_version
# Optional version to upgrade to after migration is complete
#
#
plan peadm::migrate (
Peadm::SingleTargetSpec $old_primary_host,
Peadm::SingleTargetSpec $new_primary_host,
Optional[String] $upgrade_version = undef,
Optional[Peadm::SingleTargetSpec] $replica_host = undef,
) {
# pre-migration checks
out::message('This plan is a work in progress and it is not recommended to be used until it is fully implemented and supported')
peadm::assert_supported_bolt_version()
if $upgrade_version and $upgrade_version != '' and !empty($upgrade_version) {
$permit_unsafe_versions = false
peadm::assert_supported_pe_version($upgrade_version, $permit_unsafe_versions)
}

$all_hosts = peadm::flatten_compact([
$old_primary_host,
$new_primary_host,
$replica_host ? { undef => [], default => [$replica_host] }
].flatten)
run_command('hostname', $all_hosts) # verify can connect to targets

# verify the cluster we are migrating from is operational and is a supported architecture
$cluster = run_task('peadm::get_peadm_config', $old_primary_host).first.value
$error = getvar('cluster.error')
if $error {
fail_plan($error)
}
$arch = peadm::assert_supported_architecture(
getvar('cluster.params.primary_host'),
getvar('cluster.params.replica_host'),
getvar('cluster.params.primary_postgresql_host'),
getvar('cluster.params.replica_postgresql_host'),
getvar('cluster.params.compiler_hosts'),
)

$backup_file = run_plan('peadm::backup', $old_primary_host, {
backup_type => 'migration',
Expand Down
Loading