Skip to content

Commit e5c499c

Browse files
authored
Merge pull request #18 from reidmv/stop-managing-environments
Stop managing environments
2 parents adfeaf2 + 4145ed9 commit e5c499c

File tree

6 files changed

+184
-287
lines changed

6 files changed

+184
-287
lines changed

Diff for: documentation/images/pe-xl-classification.png

257 KB
Loading

Diff for: manifests/setup/node_manager.pp

+82-125
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,34 @@
1212
# }'
1313
#
1414
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,
2321
) {
2422

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+
2527
##################################################
2628
# PE INFRASTRUCTURE GROUPS
2729
##################################################
2830

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+
2943
# We modify this group's rule such that all PE infrastructure nodes will be
3044
# members.
3145
node_group { 'PE Infrastructure Agent':
@@ -46,17 +60,18 @@
4660
},
4761
}
4862

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' => { },
5874
},
59-
variables => { 'pe_xl_replica' => true },
6075
}
6176

6277
# Create data-only groups to store PuppetDB PostgreSQL database configuration
@@ -78,39 +93,8 @@
7893
},
7994
}
8095

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.
11498
node_group { 'PE Compiler Group A':
11599
ensure => 'present',
116100
parent => 'PE Master',
@@ -123,91 +107,64 @@
123107
'database_host' => $puppetdb_database_host,
124108
},
125109
'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
127111
'puppetdb_port' => [8081],
128112
}
129113
},
130114
data => $compiler_data,
131115
}
132116

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' => { }
143129
},
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 },
180131
}
181132

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+
},
189148
}
190149

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,
210167
}
211-
212168
}
169+
213170
}

Diff for: plans/configure.pp

-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
Boolean $executing_on_master = false,
1616

1717
String[1] $compiler_pool_address = $master_host,
18-
Boolean $manage_environment_groups = true,
1918
Optional[String[1]] $token_file = undef,
2019
Optional[String[1]] $deploy_environment = undef,
2120

@@ -49,7 +48,6 @@
4948
puppetdb_database_host => $puppetdb_database_host,
5049
puppetdb_database_replica_host => $puppetdb_database_replica_host,
5150
compiler_pool_address => $compiler_pool_address,
52-
manage_environment_groups => $manage_environment_groups,
5351
)
5452

5553
# Run Puppet in no-op on the compilers so that their status in PuppetDB

Diff for: plans/init.pp

-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
Optional[Hash] $r10k_sources = undef,
2121
Optional[Array[String[1]]] $dns_alt_names = undef,
2222
Optional[Boolean] $executing_on_master = undef,
23-
Optional[Boolean] $manage_environment_groups = undef,
2423

2524
Optional[String[1]] $compiler_pool_address = undef,
2625
Optional[String[1]] $deploy_environment = undef,
@@ -55,7 +54,6 @@
5554

5655
executing_on_master => $executing_on_master,
5756
compiler_pool_address => $compiler_pool_address,
58-
manage_environment_groups => $manage_environment_groups,
5957
deploy_environment => $deploy_environment,
6058

6159
stagingdir => $stagingdir,

Diff for: tasks/configure_node_groups.json

+10-14
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,24 @@
22
"description": "Configure console node groups for a new install",
33
"parameters": {
44
"master_host": {
5-
"type": "String",
5+
"type": "String[1]",
66
"description": "The certname of the master"
77
},
8-
"master_replica_host": {
9-
"type": "String",
10-
"description": "The certname of the master replica"
11-
},
128
"puppetdb_database_host": {
13-
"type": "String",
9+
"type": "String[1]",
1410
"description": "The certname of the PuppetDB database"
1511
},
16-
"puppetdb_database_replica_host": {
17-
"type": "String",
18-
"description": "The certname of the PuppetDB database replica"
19-
},
2012
"compiler_pool_address": {
21-
"type": "String",
13+
"type": "String[1]",
2214
"description": "The service name to use for the compiler pool"
2315
},
24-
"manage_environment_groups": {
25-
"type": "Boolean",
26-
"description": "This will regroup the production and additional PE Environment groups"
16+
"master_replica_host": {
17+
"type": "Optional[String[1]]",
18+
"description": "The certname of the master replica"
19+
},
20+
"puppetdb_database_replica_host": {
21+
"type": "Optional[String[1]]",
22+
"description": "The certname of the PuppetDB database replica"
2723
}
2824
},
2925
"input_method": "environment",

0 commit comments

Comments
 (0)