diff --git a/.github/workflows/test-migration.yaml b/.github/workflows/test-migration.yaml index 59633b11..4339a002 100644 --- a/.github/workflows/test-migration.yaml +++ b/.github/workflows/test-migration.yaml @@ -40,7 +40,7 @@ jobs: - standard - standard-with-dr - large - # - extra-large + - extra-large - large-with-dr # - extra-large-with-dr version: [2021.7.9, 2023.8.2, 2025.2.0] diff --git a/REFERENCE.md b/REFERENCE.md index 38d60c1f..48d95cde 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -1804,6 +1804,7 @@ The following parameters are available in the `peadm::add_database` plan: * [`primary_host`](#-peadm--add_database--primary_host) * [`mode`](#-peadm--add_database--mode) * [`begin_at_step`](#-peadm--add_database--begin_at_step) +* [`is_migration`](#-peadm--add_database--is_migration) ##### `targets` @@ -1843,6 +1844,14 @@ Optional[Enum[ Default value: `undef` +##### `is_migration` + +Data type: `Optional[Boolean]` + + + +Default value: `false` + ### `peadm::add_replica` Add or replace a replica host. diff --git a/plans/add_database.pp b/plans/add_database.pp index 72860bba..19079002 100644 --- a/plans/add_database.pp +++ b/plans/add_database.pp @@ -9,6 +9,7 @@ 'update-db-settings', 'cleanup-db', 'finalize']] $begin_at_step = undef, + Optional[Boolean] $is_migration = false, ) { $primary_target = peadm::get_targets($primary_host, 1) $postgresql_target = peadm::get_targets($targets, 1) @@ -22,8 +23,9 @@ $compilers = $peadm_config['params']['compilers'] - # Bail if this is trying to be ran against Standard - if $compilers.empty { + # Bail if this is trying to be ran against Standard. We need to allow this plan to progress for a migration + # though as initially the installation will not have compilers added + if $compilers.empty and !$is_migration { fail_plan('Plan peadm::add_database is only applicable for L and XL deployments') } @@ -59,11 +61,15 @@ if $operating_mode == 'init' { # If no other PSQL node then match primary group letter - $avail_group_letter = peadm::flatten_compact($roles['server'].map |$k,$v| { + $calculated_group_letter = peadm::flatten_compact($roles['server'].map |$k,$v| { if $v == $primary_host { $k } })[0] + $avail_group_letter = $calculated_group_letter ? { + undef => $is_migration ? { true => 'A', default => undef }, + default => $calculated_group_letter, + } # Assume PuppetDB backend hosted on Primary if in init mode $source_db_host = $primary_host } else { diff --git a/plans/migrate.pp b/plans/migrate.pp index 108d18d8..0b24ef50 100644 --- a/plans/migrate.pp +++ b/plans/migrate.pp @@ -8,12 +8,17 @@ # The new server that will become the PE primary server # @param upgrade_version # Optional version to upgrade to after migration is complete +# @param replica_host +# Optional new server that will become the PE replica server +# @param primary_postgresql_host +# Optional new server that will become the primary postgresql server # plan peadm::migrate ( Peadm::SingleTargetSpec $old_primary_host, Peadm::SingleTargetSpec $new_primary_host, Optional[String] $upgrade_version = undef, Optional[Peadm::SingleTargetSpec] $replica_host = undef, + Optional[Peadm::SingleTargetSpec] $primary_postgresql_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') @@ -25,7 +30,8 @@ $new_hosts = peadm::flatten_compact([ $new_primary_host, - $replica_host ? { undef => [], default => [$replica_host] } + $replica_host ? { undef => [], default => [$replica_host] }, + $primary_postgresql_host ? { undef => [], default => [$primary_postgresql_host] } ].flatten) $all_hosts = peadm::flatten_compact([ $old_primary_host, @@ -118,6 +124,13 @@ out::message('No nodes to purge from old configuration') } + if $primary_postgresql_host { + run_plan('peadm::add_database', targets => $primary_postgresql_host, + primary_host => $new_primary_host, + is_migration => true, + ) + } + if $replica_host { run_plan('peadm::add_replica', { primary_host => $new_primary_host, diff --git a/spec/acceptance/peadm_spec/plans/test_migration.pp b/spec/acceptance/peadm_spec/plans/test_migration.pp index 7f17e636..ba2347ac 100644 --- a/spec/acceptance/peadm_spec/plans/test_migration.pp +++ b/spec/acceptance/peadm_spec/plans/test_migration.pp @@ -30,6 +30,7 @@ new_primary_host => $new_primary_target, upgrade_version => $upgrade_version, replica_host => $new_replica_target, + primary_postgresql_host => $new_primary_postgresql_target, ) # run infra status on the new primary