forked from puppetlabs/puppetlabs-peadm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_classification.pp
78 lines (68 loc) · 3.4 KB
/
update_classification.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# @api private
#
# @summary Configure classification
#
plan peadm::util::update_classification (
# Standard
Peadm::SingleTargetSpec $targets,
Optional[Hash] $peadm_config = undef,
Optional[Peadm::SingleTargetSpec] $replica_host = undef,
# Extra Large
Optional[Peadm::SingleTargetSpec] $primary_postgresql_host = undef,
Optional[Peadm::SingleTargetSpec] $replica_postgresql_host = undef,
# Common Configuration
Optional[String] $compiler_pool_address = undef,
Optional[String] $internal_compiler_a_pool_address = undef,
Optional[String] $internal_compiler_b_pool_address = undef,
) {
# Convert inputs into targets.
$primary_target = peadm::get_targets($targets, 1)
$replica_target = peadm::get_targets($replica_host, 1)
$primary_postgresql_target = peadm::get_targets($primary_postgresql_host, 1)
$replica_postgresql_target = peadm::get_targets($replica_postgresql_host, 1)
# Makes this more easily usable outside a plan
if $peadm_config {
$current = $peadm_config['params']
} else {
$current = run_task('peadm::get_peadm_config', $primary_target).first.value['params']
}
# When a replica in configured, the B side of the deployment requires that
# replica_postgresql_host to be set, if it is not then PuppetDB will be left
# non-functional. Doing this will allow both sides of the deployment to start
# up and be functional until the second PostgreSQL node can be provisioned and configured.
if (! $replica_postgresql_target.peadm::certname()) and $current['replica_host'] {
out::message('Overriding replica_postgresql_host while in transitive state')
$overridden_replica_postgresql_target = $primary_postgresql_target
} else {
$overridden_replica_postgresql_target = $replica_postgresql_target
}
$filtered = {
'primary_host' => $primary_target.peadm::certname(),
'replica_host' => $replica_target.peadm::certname(),
'primary_postgresql_host' => $primary_postgresql_target.peadm::certname(),
'replica_postgresql_host' => $overridden_replica_postgresql_target.peadm::certname(),
'compiler_pool_address' => $compiler_pool_address,
'internal_compiler_a_pool_address' => $internal_compiler_a_pool_address,
'internal_compiler_b_pool_address' => $internal_compiler_b_pool_address
}.filter |$parameter| { $parameter[1] }
$new = merge($current, $filtered)
out::message('Classification to be updated using the following hash...')
out::message($new)
apply($primary_target) {
class { 'peadm::setup::node_manager_yaml':
primary_host => $primary_target.peadm::certname(),
}
class { 'peadm::setup::node_manager':
primary_host => $new['primary_host'],
server_a_host => $new['primary_host'],
server_b_host => $new['replica_host'],
postgresql_a_host => $new['primary_postgresql_host'],
postgresql_b_host => $new['replica_postgresql_host'],
compiler_pool_address => $new['compiler_pool_address'],
internal_compiler_a_pool_address => $new['internal_compiler_a_pool_address'],
internal_compiler_b_pool_address => $new['internal_compiler_b_pool_address'],
require => Class['peadm::setup::node_manager_yaml'],
}
}
return('The classification of Puppet Enterprise components has succeeded.')
}