|
20 | 20 | Optional[String[1]] $puppetdb_database_replica_host = undef, |
21 | 21 | ) { |
22 | 22 |
|
| 23 | + if ([$master_replica_host, $puppetdb_database_replica_host].filter |$_| { $_ }.size == 1) { |
| 24 | + fail('Must pass both master_replica_host and puppetdb_database_replica_host, or neither') |
| 25 | + } |
| 26 | + |
23 | 27 | ################################################## |
24 | 28 | # PE INFRASTRUCTURE GROUPS |
25 | 29 | ################################################## |
26 | 30 |
|
| 31 | + # Hiera data tuning for compilers |
| 32 | + $compiler_data = { |
| 33 | + 'puppet_enterprise::profile::puppetdb' => { |
| 34 | + 'gc_interval' => '0', |
| 35 | + }, |
| 36 | + 'puppet_enterprise::puppetdb' => { |
| 37 | + 'command_processing_threads' => 2, |
| 38 | + 'write_maximum_pool_size' => 4, |
| 39 | + 'read_maximum_pool_size' => 10, |
| 40 | + }, |
| 41 | + } |
| 42 | + |
27 | 43 | # We modify this group's rule such that all PE infrastructure nodes will be |
28 | 44 | # members. |
29 | 45 | node_group { 'PE Infrastructure Agent': |
|
44 | 60 | }, |
45 | 61 | } |
46 | 62 |
|
47 | | - # We need to pre-create this group so that the master replica can be |
48 | | - # identified as running PuppetDB, so that Puppet will create a pg_ident |
49 | | - # authorization rule for it on the PostgreSQL nodes. |
50 | | - node_group { 'PE HA Replica': |
51 | | - ensure => 'present', |
52 | | - parent => 'PE Infrastructure', |
53 | | - rule => ['or', ['=', 'name', $master_replica_host]], |
54 | | - classes => { |
55 | | - 'puppet_enterprise::profile::primary_master_replica' => { } |
| 63 | + # This class has to be included here because puppet_enterprise is declared |
| 64 | + # in the console with parameters. It is therefore not possible to include |
| 65 | + # puppet_enterprise::profile::database in code without causing a conflict. |
| 66 | + node_group { 'PE Database': |
| 67 | + ensure => present, |
| 68 | + parent => 'PE Infrastructure', |
| 69 | + environment => 'production', |
| 70 | + override_environment => false, |
| 71 | + rule => ['and', ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::puppetdb_database']], |
| 72 | + classes => { |
| 73 | + 'puppet_enterprise::profile::database' => { }, |
56 | 74 | }, |
57 | | - variables => { 'pe_xl_replica' => true }, |
58 | 75 | } |
59 | 76 |
|
60 | 77 | # Create data-only groups to store PuppetDB PostgreSQL database configuration |
|
76 | 93 | }, |
77 | 94 | } |
78 | 95 |
|
79 | | - node_group { 'PE Master B': |
80 | | - ensure => present, |
81 | | - parent => 'PE Infrastructure', |
82 | | - rule => ['and', |
83 | | - ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::master'], |
84 | | - ['=', ['trusted', 'extensions', 'pp_cluster'], 'B'], |
85 | | - ], |
86 | | - data => { |
87 | | - 'puppet_enterprise::profile::primary_master_replica' => { |
88 | | - 'database_host_puppetdb' => $puppetdb_database_replica_host, |
89 | | - }, |
90 | | - 'puppet_enterprise::profile::puppetdb' => { |
91 | | - 'database_host' => $puppetdb_database_replica_host, |
92 | | - }, |
93 | | - }, |
94 | | - } |
95 | | - |
96 | | - # Hiera data tuning for compilers |
97 | | - $compiler_data = { |
98 | | - 'puppet_enterprise::profile::puppetdb' => { |
99 | | - 'gc_interval' => '0', |
100 | | - }, |
101 | | - 'puppet_enterprise::puppetdb' => { |
102 | | - 'command_processing_threads' => 2, |
103 | | - 'write_maximum_pool_size' => 4, |
104 | | - 'read_maximum_pool_size' => 10, |
105 | | - }, |
106 | | - } |
107 | | - |
108 | | - # Configure the compilers for HA, grouped into two pools, each pool |
109 | | - # having an affinity for one "availability zone" or the other. Even with an |
110 | | - # affinity, note that data from each compiler is replicated to both |
111 | | - # "availability zones". |
| 96 | + # Configure the A pool for compilers. There are up to two pools for HA, each |
| 97 | + # having an affinity for one "availability zone" or the other. |
112 | 98 | node_group { 'PE Compiler Group A': |
113 | 99 | ensure => 'present', |
114 | 100 | parent => 'PE Master', |
|
121 | 107 | 'database_host' => $puppetdb_database_host, |
122 | 108 | }, |
123 | 109 | 'puppet_enterprise::profile::master' => { |
124 | | - 'puppetdb_host' => ['${clientcert}', $master_replica_host], # lint:ignore:single_quote_string_with_variables |
| 110 | + 'puppetdb_host' => ['${clientcert}', $master_replica_host].filter |$_| { $_ }, # lint:ignore:single_quote_string_with_variables |
125 | 111 | 'puppetdb_port' => [8081], |
126 | 112 | } |
127 | 113 | }, |
128 | 114 | data => $compiler_data, |
129 | 115 | } |
130 | 116 |
|
131 | | - node_group { 'PE Compiler Group B': |
132 | | - ensure => 'present', |
133 | | - parent => 'PE Master', |
134 | | - rule => ['and', |
135 | | - ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::compiler'], |
136 | | - ['=', ['trusted', 'extensions', 'pp_cluster'], 'B'], |
137 | | - ], |
138 | | - classes => { |
139 | | - 'puppet_enterprise::profile::puppetdb' => { |
140 | | - 'database_host' => $puppetdb_database_replica_host, |
| 117 | + # Create the replica and B groups if a replica master and database host are |
| 118 | + # supplied |
| 119 | + if ($master_replica_host and $puppetdb_database_replica_host) { |
| 120 | + # We need to pre-create this group so that the master replica can be |
| 121 | + # identified as running PuppetDB, so that Puppet will create a pg_ident |
| 122 | + # authorization rule for it on the PostgreSQL nodes. |
| 123 | + node_group { 'PE HA Replica': |
| 124 | + ensure => 'present', |
| 125 | + parent => 'PE Infrastructure', |
| 126 | + rule => ['or', ['=', 'name', $master_replica_host]], |
| 127 | + classes => { |
| 128 | + 'puppet_enterprise::profile::primary_master_replica' => { } |
141 | 129 | }, |
142 | | - 'puppet_enterprise::profile::master' => { |
143 | | - 'puppetdb_host' => ['${clientcert}', $master_host], # lint:ignore:single_quote_string_with_variables |
144 | | - 'puppetdb_port' => [8081], |
145 | | - } |
146 | | - }, |
147 | | - data => $compiler_data, |
148 | | - } |
| 130 | + variables => { 'pe_xl_replica' => true }, |
| 131 | + } |
149 | 132 |
|
150 | | - # This class has to be included here because puppet_enterprise is declared |
151 | | - # in the console with parameters. It is therefore not possible to include |
152 | | - # puppet_enterprise::profile::database in code without causing a conflict. |
153 | | - node_group { 'PE Database': |
154 | | - ensure => present, |
155 | | - parent => 'PE Infrastructure', |
156 | | - environment => 'production', |
157 | | - override_environment => false, |
158 | | - rule => ['and', ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::puppetdb_database']], |
159 | | - classes => { |
160 | | - 'puppet_enterprise::profile::database' => { }, |
161 | | - }, |
| 133 | + node_group { 'PE Master B': |
| 134 | + ensure => present, |
| 135 | + parent => 'PE Infrastructure', |
| 136 | + rule => ['and', |
| 137 | + ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::master'], |
| 138 | + ['=', ['trusted', 'extensions', 'pp_cluster'], 'B'], |
| 139 | + ], |
| 140 | + data => { |
| 141 | + 'puppet_enterprise::profile::primary_master_replica' => { |
| 142 | + 'database_host_puppetdb' => $puppetdb_database_replica_host, |
| 143 | + }, |
| 144 | + 'puppet_enterprise::profile::puppetdb' => { |
| 145 | + 'database_host' => $puppetdb_database_replica_host, |
| 146 | + }, |
| 147 | + }, |
| 148 | + } |
| 149 | + |
| 150 | + node_group { 'PE Compiler Group B': |
| 151 | + ensure => 'present', |
| 152 | + parent => 'PE Master', |
| 153 | + rule => ['and', |
| 154 | + ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::compiler'], |
| 155 | + ['=', ['trusted', 'extensions', 'pp_cluster'], 'B'], |
| 156 | + ], |
| 157 | + classes => { |
| 158 | + 'puppet_enterprise::profile::puppetdb' => { |
| 159 | + 'database_host' => $puppetdb_database_replica_host, |
| 160 | + }, |
| 161 | + 'puppet_enterprise::profile::master' => { |
| 162 | + 'puppetdb_host' => ['${clientcert}', $master_host], # lint:ignore:single_quote_string_with_variables |
| 163 | + 'puppetdb_port' => [8081], |
| 164 | + } |
| 165 | + }, |
| 166 | + data => $compiler_data, |
| 167 | + } |
162 | 168 | } |
163 | 169 |
|
164 | 170 | } |
0 commit comments