Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

##### <a name="-peadm--add_database--targets"></a>`targets`

Expand Down Expand Up @@ -1843,6 +1844,14 @@ Optional[Enum[

Default value: `undef`

##### <a name="-peadm--add_database--is_migration"></a>`is_migration`

Data type: `Optional[Boolean]`



Default value: `false`

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

Add or replace a replica host.
Expand Down
12 changes: 9 additions & 3 deletions plans/add_database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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')
}

Expand Down Expand Up @@ -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 {
Expand Down
15 changes: 14 additions & 1 deletion plans/migrate.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions spec/acceptance/peadm_spec/plans/test_migration.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading