Skip to content

Commit

Permalink
(PE-38814) add_compiler - Making primary_postgresql_host and avail_gr…
Browse files Browse the repository at this point in the history
…oup_letter optional

primary_postgresql_host, if not provided will be determined through get_peadm_config
avail_group_letter, is defaulting to A
  • Loading branch information
ragingra committed Jul 29, 2024
1 parent cafbeb1 commit 14efe76
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
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

0 comments on commit 14efe76

Please sign in to comment.