Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PE-38814) add_compiler - Making primary_postgresql_host and avail_group_letter optional #468

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1571,10 +1571,12 @@ The following parameters are available in the `peadm::add_compiler` plan:

##### <a name="-peadm--add_compiler--avail_group_letter"></a>`avail_group_letter`

Data type: `Enum['A', 'B']`
Data type: `Optional[Enum['A', 'B']]`

_ Either A or B; whichever of the two letter designations the compiler is being assigned to

Default value: `'A'`

##### <a name="-peadm--add_compiler--compiler_host"></a>`compiler_host`

Data type: `Peadm::SingleTargetSpec`
Expand All @@ -1597,10 +1599,12 @@ _ The hostname and certname of the primary Puppet server

##### <a name="-peadm--add_compiler--primary_postgresql_host"></a>`primary_postgresql_host`

Data type: `Peadm::SingleTargetSpec`
Data type: `Optional[Peadm::SingleTargetSpec]`

_ The hostname and certname of the PE-PostgreSQL server with availability group $avail_group_letter

Default value: `undef`

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

The peadm::add_database class.
Expand Down
23 changes: 20 additions & 3 deletions plans/add_compiler.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,37 @@
# @param primary_host _ The hostname and certname of the primary Puppet server
# @param primary_postgresql_host _ The hostname and certname of the PE-PostgreSQL server with availability group $avail_group_letter
plan peadm::add_compiler(
Enum['A', 'B'] $avail_group_letter,
Optional[Enum['A', 'B']] $avail_group_letter = 'A' ,
Optional[String[1]] $dns_alt_names = undef,
Peadm::SingleTargetSpec $compiler_host,
Peadm::SingleTargetSpec $primary_host,
Peadm::SingleTargetSpec $primary_postgresql_host,
Optional[Peadm::SingleTargetSpec] $primary_postgresql_host = undef,
) {
$compiler_target = peadm::get_targets($compiler_host, 1)
$primary_target = peadm::get_targets($primary_host, 1)
$primary_postgresql_target = peadm::get_targets($primary_postgresql_host, 1)

# Get current peadm config to determine where to setup additional rules for
# compiler's secondary PuppetDB instances
$peadm_config = run_task('peadm::get_peadm_config', $primary_target).first.value

if $primary_postgresql_host == undef {
# get the external PostgreSQL host for the specified availability group
$external_postgresql_host = $avail_group_letter ? {
'A' => $peadm_config['params']['primary_postgresql_host'],
default => $peadm_config['params']['replica_postgresql_host'],
}

# If the external_postgresql_host is undef, use the server for that availability group
$postgresql_host = $external_postgresql_host ? {
undef => $peadm_config['role-letter']['server'][$avail_group_letter],
default => $external_postgresql_host,
}

$primary_postgresql_target = peadm::get_targets($postgresql_host, 1)
} else {
$primary_postgresql_target = peadm::get_targets($primary_postgresql_host, 1)
}

# Return the opposite server than the compiler to be added so it can be
# configured with the appropriate rules for Puppet Server access from
# compiler
Expand Down
Loading