|
1 | | -# This plan is in development and currently considered experimental. |
2 | | -# |
3 | | -# @api private |
| 1 | +# @api public |
4 | 2 | # |
5 | 3 | # @summary Add a new compiler to a PE architecture or replace an existing one with new configuration. |
6 | 4 | # @param avail_group_letter _ Either A or B; whichever of the two letter designations the compiler is being assigned to |
|
9 | 7 | # @param primary_host _ The hostname and certname of the primary Puppet server |
10 | 8 | # @param primary_postgresql_host _ The hostname and certname of the PE-PostgreSQL server with availability group $avail_group_letter |
11 | 9 | plan peadm::add_compiler( |
12 | | - Enum['A', 'B'] $avail_group_letter, |
| 10 | + Enum['A', 'B'] $avail_group_letter = 'A' , |
13 | 11 | Optional[String[1]] $dns_alt_names = undef, |
14 | 12 | Peadm::SingleTargetSpec $compiler_host, |
15 | 13 | Peadm::SingleTargetSpec $primary_host, |
16 | | - Peadm::SingleTargetSpec $primary_postgresql_host, |
| 14 | + Optional[Peadm::SingleTargetSpec] $primary_postgresql_host = undef, |
17 | 15 | ) { |
18 | 16 | $compiler_target = peadm::get_targets($compiler_host, 1) |
19 | 17 | $primary_target = peadm::get_targets($primary_host, 1) |
20 | | - $primary_postgresql_target = peadm::get_targets($primary_postgresql_host, 1) |
21 | 18 |
|
22 | 19 | # Get current peadm config to determine where to setup additional rules for |
23 | 20 | # compiler's secondary PuppetDB instances |
24 | 21 | $peadm_config = run_task('peadm::get_peadm_config', $primary_target).first.value |
25 | 22 |
|
| 23 | + if $primary_postgresql_host == undef { |
| 24 | + # get the external PostgreSQL host for the specified availability group |
| 25 | + $external_postgresql_host = $avail_group_letter ? { |
| 26 | + 'A' => $peadm_config['params']['primary_postgresql_host'], |
| 27 | + default => $peadm_config['params']['replica_postgresql_host'], |
| 28 | + } |
| 29 | + |
| 30 | + # If the external_postgresql_host is undef, use the server for that availability group |
| 31 | + $postgresql_host = $external_postgresql_host ? { |
| 32 | + undef => $peadm_config['role-letter']['server'][$avail_group_letter], |
| 33 | + default => $external_postgresql_host, |
| 34 | + } |
| 35 | + |
| 36 | + if $postgresql_host == undef { |
| 37 | + fail_plan("No PostgreSQL host found for availability group ${avail_group_letter}") |
| 38 | + } |
| 39 | + |
| 40 | + $primary_postgresql_target = peadm::get_targets($postgresql_host, 1) |
| 41 | + } else { |
| 42 | + $primary_postgresql_target = peadm::get_targets($primary_postgresql_host, 1) |
| 43 | + } |
| 44 | + |
26 | 45 | # Return the opposite server than the compiler to be added so it can be |
27 | 46 | # configured with the appropriate rules for Puppet Server access from |
28 | 47 | # compiler |
|
84 | 103 | path => '/etc/puppetlabs/puppet/hiera.yaml' |
85 | 104 | ) |
86 | 105 |
|
87 | | - # On <compiler-host>, run the puppet agent |
| 106 | + # On <compiler-host>, run puppet agent |
88 | 107 | run_task('peadm::puppet_runonce', $compiler_target) |
89 | 108 |
|
90 | | - # On <primary_postgresql_host> run the puppet agent |
| 109 | + # On <primary_postgresql_host>, run puppet agent |
91 | 110 | run_task('peadm::puppet_runonce', $primary_postgresql_target) |
92 | 111 |
|
93 | | - # On replica puppetdb run the puppet agent |
| 112 | + # On <replica_puppetdb_target>, run puppet agent |
94 | 113 | run_task('peadm::puppet_runonce', $replica_puppetdb_target) |
95 | 114 |
|
96 | | - # On <primary_postgresql_host> start puppet.service |
| 115 | + # On <primary_postgresql_host>, start puppet.service |
97 | 116 | run_command('systemctl start puppet.service', peadm::flatten_compact([ |
98 | 117 | $primary_postgresql_target, |
99 | 118 | $replica_puppetdb_target, |
|
0 commit comments