|
12 | 12 | # }'
|
13 | 13 | #
|
14 | 14 | class pe_xl::setup::node_manager (
|
15 |
| - String[1] $master_host, |
16 |
| - String[1] $master_replica_host, |
17 |
| - String[1] $puppetdb_database_host, |
18 |
| - String[1] $puppetdb_database_replica_host, |
19 |
| - String[1] $compiler_pool_address, |
20 |
| - Boolean $manage_environment_groups = true, |
21 |
| - Pattern[/\A[a-z0-9_]+\Z/] $default_environment = 'production', |
22 |
| - Array[Pattern[/\A[a-z0-9_]+\Z/]] $environments = ['production'], |
| 15 | + String[1] $master_host, |
| 16 | + String[1] $puppetdb_database_host, |
| 17 | + String[1] $compiler_pool_address, |
| 18 | + |
| 19 | + Optional[String[1]] $master_replica_host = undef, |
| 20 | + Optional[String[1]] $puppetdb_database_replica_host = undef, |
23 | 21 | ) {
|
24 | 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 | + |
25 | 27 | ##################################################
|
26 | 28 | # PE INFRASTRUCTURE GROUPS
|
27 | 29 | ##################################################
|
28 | 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 | + |
29 | 43 | # We modify this group's rule such that all PE infrastructure nodes will be
|
30 | 44 | # members.
|
31 | 45 | node_group { 'PE Infrastructure Agent':
|
|
46 | 60 | },
|
47 | 61 | }
|
48 | 62 |
|
49 |
| - # We need to pre-create this group so that the master replica can be |
50 |
| - # identified as running PuppetDB, so that Puppet will create a pg_ident |
51 |
| - # authorization rule for it on the PostgreSQL nodes. |
52 |
| - node_group { 'PE HA Replica': |
53 |
| - ensure => 'present', |
54 |
| - parent => 'PE Infrastructure', |
55 |
| - rule => ['or', ['=', 'name', $master_replica_host]], |
56 |
| - classes => { |
57 |
| - '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' => { }, |
58 | 74 | },
|
59 |
| - variables => { 'pe_xl_replica' => true }, |
60 | 75 | }
|
61 | 76 |
|
62 | 77 | # Create data-only groups to store PuppetDB PostgreSQL database configuration
|
|
78 | 93 | },
|
79 | 94 | }
|
80 | 95 |
|
81 |
| - node_group { 'PE Master B': |
82 |
| - ensure => present, |
83 |
| - parent => 'PE Infrastructure', |
84 |
| - rule => ['and', |
85 |
| - ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::master'], |
86 |
| - ['=', ['trusted', 'extensions', 'pp_cluster'], 'B'], |
87 |
| - ], |
88 |
| - data => { |
89 |
| - 'puppet_enterprise::profile::primary_master_replica' => { |
90 |
| - 'database_host_puppetdb' => $puppetdb_database_replica_host, |
91 |
| - }, |
92 |
| - 'puppet_enterprise::profile::puppetdb' => { |
93 |
| - 'database_host' => $puppetdb_database_replica_host, |
94 |
| - }, |
95 |
| - }, |
96 |
| - } |
97 |
| - |
98 |
| - # Hiera data tuning for compilers |
99 |
| - $compiler_data = { |
100 |
| - 'puppet_enterprise::profile::puppetdb' => { |
101 |
| - 'gc_interval' => '0', |
102 |
| - }, |
103 |
| - 'puppet_enterprise::puppetdb' => { |
104 |
| - 'command_processing_threads' => 2, |
105 |
| - 'write_maximum_pool_size' => 4, |
106 |
| - 'read_maximum_pool_size' => 10, |
107 |
| - }, |
108 |
| - } |
109 |
| - |
110 |
| - # Configure the compilers for HA, grouped into two pools, each pool |
111 |
| - # having an affinity for one "availability zone" or the other. Even with an |
112 |
| - # affinity, note that data from each compiler is replicated to both |
113 |
| - # "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. |
114 | 98 | node_group { 'PE Compiler Group A':
|
115 | 99 | ensure => 'present',
|
116 | 100 | parent => 'PE Master',
|
|
123 | 107 | 'database_host' => $puppetdb_database_host,
|
124 | 108 | },
|
125 | 109 | 'puppet_enterprise::profile::master' => {
|
126 |
| - '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 |
127 | 111 | 'puppetdb_port' => [8081],
|
128 | 112 | }
|
129 | 113 | },
|
130 | 114 | data => $compiler_data,
|
131 | 115 | }
|
132 | 116 |
|
133 |
| - node_group { 'PE Compiler Group B': |
134 |
| - ensure => 'present', |
135 |
| - parent => 'PE Master', |
136 |
| - rule => ['and', |
137 |
| - ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::compiler'], |
138 |
| - ['=', ['trusted', 'extensions', 'pp_cluster'], 'B'], |
139 |
| - ], |
140 |
| - classes => { |
141 |
| - 'puppet_enterprise::profile::puppetdb' => { |
142 |
| - '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' => { } |
143 | 129 | },
|
144 |
| - 'puppet_enterprise::profile::master' => { |
145 |
| - 'puppetdb_host' => ['${clientcert}', $master_host], # lint:ignore:single_quote_string_with_variables |
146 |
| - 'puppetdb_port' => [8081], |
147 |
| - } |
148 |
| - }, |
149 |
| - data => $compiler_data, |
150 |
| - } |
151 |
| - |
152 |
| - # This class has to be included here because puppet_enterprise is declared |
153 |
| - # in the console with parameters. It is therefore not possible to include |
154 |
| - # puppet_enterprise::profile::database in code without causing a conflict. |
155 |
| - node_group { 'PE Database': |
156 |
| - ensure => present, |
157 |
| - parent => 'PE Infrastructure', |
158 |
| - environment => 'production', |
159 |
| - override_environment => false, |
160 |
| - rule => ['and', ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::puppetdb_database']], |
161 |
| - classes => { |
162 |
| - 'puppet_enterprise::profile::database' => { }, |
163 |
| - }, |
164 |
| - } |
165 |
| - |
166 |
| - |
167 |
| - if ($manage_environment_groups) { |
168 |
| - |
169 |
| - ################################################## |
170 |
| - # ENVIRONMENT GROUPS |
171 |
| - ################################################## |
172 |
| - |
173 |
| - node_group { 'All Environments': |
174 |
| - ensure => present, |
175 |
| - description => 'Environment group parent and default', |
176 |
| - environment => $default_environment, |
177 |
| - override_environment => true, |
178 |
| - parent => 'All Nodes', |
179 |
| - rule => ['and', ['~', 'name', '.*']], |
| 130 | + variables => { 'pe_xl_replica' => true }, |
180 | 131 | }
|
181 | 132 |
|
182 |
| - node_group { 'Agent-specified environment': |
183 |
| - ensure => present, |
184 |
| - description => 'This environment group exists for unusual testing and development only. Expect it to be empty', |
185 |
| - environment => 'agent-specified', |
186 |
| - override_environment => true, |
187 |
| - parent => 'All Environments', |
188 |
| - rule => [ ], |
| 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 | + }, |
189 | 148 | }
|
190 | 149 |
|
191 |
| - $environments.each |$env| { |
192 |
| - $title_env = capitalize($env) |
193 |
| - |
194 |
| - node_group { "${title_env} environment": |
195 |
| - ensure => present, |
196 |
| - environment => $env, |
197 |
| - override_environment => true, |
198 |
| - parent => 'All Environments', |
199 |
| - rule => ['and', ['=', ['trusted', 'extensions', 'pp_environment'], $env]], |
200 |
| - } |
201 |
| - |
202 |
| - node_group { "${title_env} one-time run exception": |
203 |
| - ensure => present, |
204 |
| - description => "Allow ${env} nodes to request a different puppet environment for a one-time run", |
205 |
| - environment => 'agent-specified', |
206 |
| - override_environment => true, |
207 |
| - parent => "${title_env} environment", |
208 |
| - rule => ['and', ['~', ['fact', 'agent_specified_environment'], '.+']], |
209 |
| - } |
| 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, |
210 | 167 | }
|
211 |
| - |
212 | 168 | }
|
| 169 | + |
213 | 170 | }
|
0 commit comments