Skip to content

Commit 4145ed9

Browse files
committed
Make B node groups optional
So that if an HA master replica and database are not passed in, the classification will cleanly create only the A groups.
1 parent 2a45d09 commit 4145ed9

File tree

2 files changed

+169
-161
lines changed

2 files changed

+169
-161
lines changed

manifests/setup/node_manager.pp

+79-73
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,26 @@
2020
Optional[String[1]] $puppetdb_database_replica_host = undef,
2121
) {
2222

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+
2327
##################################################
2428
# PE INFRASTRUCTURE GROUPS
2529
##################################################
2630

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+
2743
# We modify this group's rule such that all PE infrastructure nodes will be
2844
# members.
2945
node_group { 'PE Infrastructure Agent':
@@ -44,17 +60,18 @@
4460
},
4561
}
4662

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' => { },
5674
},
57-
variables => { 'pe_xl_replica' => true },
5875
}
5976

6077
# Create data-only groups to store PuppetDB PostgreSQL database configuration
@@ -76,39 +93,8 @@
7693
},
7794
}
7895

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.
11298
node_group { 'PE Compiler Group A':
11399
ensure => 'present',
114100
parent => 'PE Master',
@@ -121,44 +107,64 @@
121107
'database_host' => $puppetdb_database_host,
122108
},
123109
'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
125111
'puppetdb_port' => [8081],
126112
}
127113
},
128114
data => $compiler_data,
129115
}
130116

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' => { }
141129
},
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+
}
149132

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+
}
162168
}
163169

164170
}

0 commit comments

Comments
 (0)