Skip to content

Commit 5510195

Browse files
authored
Merge pull request #23 from johnduarte/slv-366-make-pdb-pg-optional
SLV-366 Make external database host optional
2 parents 25d4d39 + 470f32b commit 5510195

File tree

7 files changed

+136
-35
lines changed

7 files changed

+136
-35
lines changed
Loading

documentation/large_deploy.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# PE Large Architecture
2+
3+
4+
## Overview
5+
6+
This module can also be used to deploy a Puppet Enterprise Large Architecture.
7+
Such an deployment differs from an Extra Large Architecture in that it does
8+
**not** include an external database. PuppetDB is served from the master.
9+
10+
**NOTE:** Currently, the module does not deploy a Large Architecture with HA.
11+
The currently supported deployment architecture is shown below.
12+
13+
![Large Architecture without HA](images/PE_Large_Architecture_no_HA.png)
14+
15+
16+
## Instructions
17+
18+
The process for deploying a PE Large Architecture is very similar to the
19+
[basic_usage](basic_usage.md) for deploying the XL Architecture. These two
20+
differ only in the parameters supplied to the bolt plans. Specifically, the
21+
`puppetdb_database_host`, `master_replica_host`, and
22+
`puppetdb_database_replica_host` parameters need to be omitted in order to
23+
deploy a PE Large Architecture.
24+
25+
Ensuring that the parameters above are omitted from the `params.json` file,
26+
the [basic usage instructions](basic_usage.md#basic-usage-instructions) can be
27+
used to run the `pe_xl` plan in order to install and configure the deployment.
28+
29+
Example nodes.yaml Bolt inventory file:
30+
31+
```yaml
32+
---
33+
groups:
34+
- name: pe_xl_nodes
35+
config:
36+
transport: ssh
37+
ssh:
38+
host-key-check: false
39+
user: centos
40+
run-as: root
41+
tty: true
42+
nodes:
43+
- pe-xl-core-0.lab1.puppet.vm
44+
- pe-xl-compiler-0.lab1.puppet.vm
45+
- pe-xl-compiler-1.lab1.puppet.vm
46+
```
47+
48+
Example params.json Bolt parameters file:
49+
50+
```json
51+
{
52+
"install": true,
53+
"configure": true,
54+
"upgrade": false,
55+
56+
"master_host": "pe-xl-core-0.lab1.puppet.vm",
57+
"compiler_hosts": [
58+
"pe-xl-compiler-0.lab1.puppet.vm",
59+
"pe-xl-compiler-1.lab1.puppet.vm"
60+
],
61+
62+
"console_password": "puppetlabs",
63+
"dns_alt_names": [ "puppet", "puppet.lab1.puppet.vm" ],
64+
"compiler_pool_address": "puppet.lab1.puppet.vm",
65+
"version": "2018.1.4"
66+
}
67+
```

plans/configure.pp

+16-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#
33
plan pe_xl::configure (
44
String[1] $master_host,
5-
String[1] $puppetdb_database_host,
65
Array[String[1]] $compiler_hosts = [ ],
76

7+
Optional[String[1]] $puppetdb_database_host = undef,
88
Optional[String[1]] $master_replica_host = undef,
99
Optional[String[1]] $puppetdb_database_replica_host = undef,
1010

@@ -34,12 +34,24 @@
3434
default => fail('Must specify either both or neither of master_replica_host, puppetdb_database_replica_host'),
3535
}
3636

37+
# Ensure primary external database host for HA
38+
if $ha {
39+
if ! $puppetdb_database_host {
40+
fail("Must specify puppetdb_database_host for HA environment")
41+
}
42+
}
43+
3744
# Allow for the configure task to be run local to the master.
3845
$master_target = $executing_on_master ? {
3946
true => "local://${master_host}",
4047
false => $master_host,
4148
}
4249

50+
$puppetdb_database_target = $puppetdb_database_host ? {
51+
undef => $master_host,
52+
default => $puppetdb_database_host,
53+
}
54+
4355
# Retrieve and deploy Puppet modules from the Forge so that they can be used
4456
# for ensuring some configuration (node groups)
4557
[ ['WhatsARanjit-node_manager', '0.7.1'],
@@ -58,7 +70,7 @@
5870
run_task('pe_xl::configure_node_groups', $master_target,
5971
master_host => $master_host,
6072
master_replica_host => $master_replica_host,
61-
puppetdb_database_host => $puppetdb_database_host,
73+
puppetdb_database_host => $puppetdb_database_target,
6274
puppetdb_database_replica_host => $puppetdb_database_replica_host,
6375
compiler_pool_address => $compiler_pool_address,
6476
)
@@ -73,7 +85,7 @@
7385
# Run Puppet on the PuppetDB Database hosts to update their auth
7486
# configuration to allow the compilers to connect
7587
run_task('pe_xl::puppet_runonce', [
76-
$puppetdb_database_host,
88+
$puppetdb_database_target,
7789
$puppetdb_database_replica_host,
7890
].pe_xl::flatten_compact)
7991

@@ -100,7 +112,7 @@
100112
# Run Puppet everywhere to pick up last remaining config tweaks
101113
run_task('pe_xl::puppet_runonce', [
102114
$master_target,
103-
$puppetdb_database_host,
115+
$puppetdb_database_target,
104116
$compiler_hosts,
105117
$master_replica_host,
106118
$puppetdb_database_replica_host,

plans/install.pp

+27-10
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#
33
plan pe_xl::install (
44
String[1] $master_host,
5-
String[1] $puppetdb_database_host,
65
Array[String[1]] $compiler_hosts = [ ],
76

7+
Optional[String[1]] $puppetdb_database_host = undef,
88
Optional[String[1]] $master_replica_host = undef,
99
Optional[String[1]] $puppetdb_database_replica_host = undef,
1010

@@ -31,7 +31,11 @@
3131
$master_replica_host,
3232
].pe_xl::flatten_compact()
3333

34-
$ha_database_target = [
34+
$puppetdb_database_target = [
35+
$puppetdb_database_host,
36+
].pe_xl::flatten_compact()
37+
38+
$puppetdb_database_replica_target = [
3539
$puppetdb_database_replica_host,
3640
].pe_xl::flatten_compact()
3741

@@ -42,6 +46,13 @@
4246
default => fail('Must specify either both or neither of master_replica_host, puppetdb_database_replica_host'),
4347
}
4448

49+
# Ensure primary external database host for HA
50+
if $ha {
51+
if ! $puppetdb_database_host {
52+
fail("Must specify puppetdb_database_host for HA environment")
53+
}
54+
}
55+
4556
$all_hosts = [
4657
$core_hosts,
4758
$ha_hosts,
@@ -111,8 +122,8 @@
111122

112123
# Upload the pe.conf files to the hosts that need them
113124
pe_xl::file_content_upload($master_pe_conf, '/tmp/pe.conf', $master_host)
114-
pe_xl::file_content_upload($puppetdb_database_pe_conf, '/tmp/pe.conf', $puppetdb_database_host)
115-
pe_xl::file_content_upload($puppetdb_database_replica_pe_conf, '/tmp/pe.conf', $ha_database_target)
125+
pe_xl::file_content_upload($puppetdb_database_pe_conf, '/tmp/pe.conf', $puppetdb_database_target)
126+
pe_xl::file_content_upload($puppetdb_database_replica_pe_conf, '/tmp/pe.conf', $puppetdb_database_replica_target)
116127

117128
# Download the PE tarball and send it to the nodes that need it
118129
$pe_tarball_name = "puppet-enterprise-${version}-el-7-x86_64.tar.gz"
@@ -138,7 +149,7 @@
138149
| HEREDOC
139150
)
140151

141-
run_task('pe_xl::mkdir_p_file', $puppetdb_database_host,
152+
run_task('pe_xl::mkdir_p_file', $puppetdb_database_target,
142153
path => '/etc/puppetlabs/puppet/csr_attributes.yaml',
143154
content => @("HEREDOC"),
144155
---
@@ -149,7 +160,7 @@
149160
| HEREDOC
150161
)
151162

152-
run_task('pe_xl::mkdir_p_file', $ha_database_target,
163+
run_task('pe_xl::mkdir_p_file', $puppetdb_database_replica_target,
153164
path => '/etc/puppetlabs/puppet/csr_attributes.yaml',
154165
content => @("HEREDOC"),
155166
---
@@ -161,25 +172,31 @@
161172
)
162173

163174
# Get the master installation up and running. The installer will
164-
# "fail" because PuppetDB can't start. That's expected.
175+
# "fail" because PuppetDB can't start, if puppetdb_database_host
176+
# is set. That's expected.
177+
$shortcircuit_puppetdb = $puppetdb_database_host ? {
178+
undef => false,
179+
default => true,
180+
}
165181
without_default_logging() || {
166182
out::message("Starting: task pe_xl::pe_install on ${master_host}")
167183
run_task('pe_xl::pe_install', $master_host,
168-
_catch_errors => true,
184+
_catch_errors => $shortcircuit_puppetdb,
169185
tarball => $upload_tarball_path,
170186
peconf => '/tmp/pe.conf',
171-
shortcircuit_puppetdb => true,
187+
shortcircuit_puppetdb => $shortcircuit_puppetdb,
172188
)
173189
out::message("Finished: task pe_xl::pe_install on ${master_host}")
174190
}
175191
176192
# Configure autosigning for the puppetdb database hosts 'cause they need it
193+
$autosign_conf = $database_hosts.reduce |$memo,$host| { "${host}\n${memo}" }
177194
run_task('pe_xl::mkdir_p_file', $master_host,
178195
path => '/etc/puppetlabs/puppet/autosign.conf',
179196
owner => 'pe-puppet',
180197
group => 'pe-puppet',
181198
mode => '0644',
182-
content => $database_hosts.reduce |$memo,$host| { "${host}\n${memo}" },
199+
content => "$autosign_conf",
183200
)
184201
185202
# Run the PE installer on the puppetdb database hosts

tasks/configure_node_groups.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"type": "String[1]",
66
"description": "The certname of the master"
77
},
8-
"puppetdb_database_host": {
9-
"type": "String[1]",
10-
"description": "The certname of the PuppetDB database"
11-
},
128
"compiler_pool_address": {
139
"type": "String[1]",
1410
"description": "The service name to use for the compiler pool"
1511
},
12+
"puppetdb_database_host": {
13+
"type": "Optional[String[1]]",
14+
"description": "The certname of the PuppetDB database"
15+
},
1616
"master_replica_host": {
1717
"type": "Optional[String[1]]",
1818
"description": "The certname of the master replica"

tasks/configure_node_groups.sh

+15-12
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,21 @@ class configure_node_groups (
6060
variables => { 'pe_master' => true },
6161
}
6262
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' => { },
74-
},
63+
# Create the database group if a database host is external
64+
if ($puppetdb_database_host != $master_host) {
65+
# This class has to be included here because puppet_enterprise is declared
66+
# in the console with parameters. It is therefore not possible to include
67+
# puppet_enterprise::profile::database in code without causing a conflict.
68+
node_group { 'PE Database':
69+
ensure => present,
70+
parent => 'PE Infrastructure',
71+
environment => 'production',
72+
override_environment => false,
73+
rule => ['and', ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::puppetdb_database']],
74+
classes => {
75+
'puppet_enterprise::profile::database' => { },
76+
},
77+
}
7578
}
7679
7780
# Create data-only groups to store PuppetDB PostgreSQL database configuration

templates/master-pe.conf.epp

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<%- | String[1] $console_password,
2-
String[1] $master_host,
3-
String[1] $puppetdb_database_host,
4-
Array $dns_alt_names,
5-
Hash $r10k_sources,
1+
<%- | String[1] $console_password,
2+
String[1] $master_host,
3+
Optional[String] $puppetdb_database_host,
4+
Array $dns_alt_names,
5+
Hash $r10k_sources,
66
| -%>
77
#----------------------------------------------------------------------------
88
# Puppet Enterprise installer configuration file
@@ -20,11 +20,13 @@
2020
"puppet_enterprise::puppet_master_host": "<%= $master_host %>"
2121
"pe_install::puppet_master_dnsaltnames": <%= $dns_alt_names %>
2222

23+
<% if $puppetdb_database_host =~ String[1] { -%>
2324
# PuppetDB Database configuration
2425
# This parameter does not change the "role" of the master; the
2526
# master still considers itself a database host. It will reconfigure
2627
# PuppetDB though to use a different PostgreSQL host for that database.
2728
"puppet_enterprise::profile::puppetdb::database_host": "<%= $puppetdb_database_host %>"
29+
<% } -%>
2830

2931
# Code Manager
3032
# An initial configuration for code manager is required in order to fully

0 commit comments

Comments
 (0)