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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'plans/subplans/configure.pp', line 15
plan peadm::subplans::configure (
# Standard
Peadm::SingleTargetSpec $primary_host,
Optional[Peadm::SingleTargetSpec] $replica_host = undef,
# Large
Optional[TargetSpec] $compiler_hosts = undef,
# Extra Large
Optional[Peadm::SingleTargetSpec] $primary_postgresql_host = undef,
Optional[Peadm::SingleTargetSpec] $replica_postgresql_host = undef,
# Common Configuration
String $compiler_pool_address = $primary_host.peadm::certname(),
Optional[String] $internal_compiler_a_pool_address = undef,
Optional[String] $internal_compiler_b_pool_address = undef,
Optional[String] $token_file = undef,
Optional[String] $deploy_environment = undef,
# Other
String $stagingdir = '/tmp',
) {
# TODO: get and validate PE version
# Convert inputs into targets.
$primary_target = peadm::get_targets($primary_host, 1)
$replica_target = peadm::get_targets($replica_host, 1)
$replica_postgresql_target = peadm::get_targets($replica_postgresql_host, 1)
$compiler_targets = peadm::get_targets($compiler_hosts)
$primary_postgresql_target = peadm::get_targets($primary_postgresql_host, 1)
# Ensure input valid for a supported architecture
$arch = peadm::assert_supported_architecture(
$primary_host,
$replica_host,
$primary_postgresql_host,
$replica_postgresql_host,
$compiler_hosts,
)
# Define the global hiera.yaml file on the Master; and syncronize to any Replica and Compilers.
# This enables Data in the Classifier/Console, which is used/required by this architecture.
# Necessary, for example, when promoting the Replica due to PE-18400 (and others).
$global_hiera_yaml = run_task('peadm::read_file', $primary_target,
path => '/etc/puppetlabs/puppet/hiera.yaml',
).first['content']
run_task('peadm::mkdir_p_file', peadm::flatten_compact([
$replica_target,
$compiler_targets,
]),
path => '/etc/puppetlabs/puppet/hiera.yaml',
owner => 'root',
group => 'root',
mode => '0644',
content => $global_hiera_yaml,
)
# Set up the console node groups to configure the various hosts in their roles
apply($primary_target) {
class { 'peadm::setup::node_manager_yaml':
primary_host => $primary_target.peadm::certname(),
}
class { 'peadm::setup::node_manager':
primary_host => $primary_target.peadm::certname(),
replica_host => $replica_target.peadm::certname(),
primary_postgresql_host => $primary_postgresql_target.peadm::certname(),
replica_postgresql_host => $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,
require => Class['peadm::setup::node_manager_yaml'],
}
}
if $arch['disaster-recovery'] {
# Run the PE Replica Provision
run_task('peadm::provision_replica', $primary_target,
replica => $replica_target.peadm::certname(),
token_file => $token_file,
# Race condition, where the provision command checks PuppetDB status and
# probably gets "starting", but fails out because that's not "running".
# Can remove flag when that issue is fixed.
legacy => true,
)
}
# Run Puppet everywhere to pick up last remaining config tweaks
run_task('peadm::puppet_runonce', peadm::flatten_compact([
$primary_target,
$primary_postgresql_target,
$compiler_targets,
$replica_target,
$replica_postgresql_target,
]))
# Deploy an environment if a deploy environment is specified
if $deploy_environment {
run_task('peadm::code_manager', $primary_target,
action => "deploy ${deploy_environment}",
)
}
# Ensure Puppet agent service is running now that configuration is complete
run_command('systemctl start puppet', peadm::flatten_compact([
$primary_target,
$replica_target,
$primary_postgresql_target,
$replica_postgresql_target,
$compiler_targets,
]))
return("Configuration of Puppet Enterprise ${arch['architecture']} succeeded.")
}
|