-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathconfigure.pp
150 lines (130 loc) · 5.66 KB
/
configure.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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# @summary Configure first-time classification and HA setup
#
plan peadm::action::configure (
# Standard
Peadm::SingleTargetSpec $master_host,
Optional[Peadm::SingleTargetSpec] $master_replica_host = undef,
# Large
Optional[TargetSpec] $compiler_hosts = undef,
# Extra Large
Optional[Peadm::SingleTargetSpec] $puppetdb_database_host = undef,
Optional[Peadm::SingleTargetSpec] $puppetdb_database_replica_host = undef,
# Common Configuration
String $compiler_pool_address = $master_host,
Optional[String] $token_file = undef,
Optional[String] $deploy_environment = undef,
# Other
String $stagingdir = '/tmp',
) {
# Convert inputs into targets.
$master_target = peadm::get_targets($master_host, 1)
$master_replica_target = peadm::get_targets($master_replica_host, 1)
$puppetdb_database_replica_target = peadm::get_targets($puppetdb_database_replica_host, 1)
$compiler_targets = peadm::get_targets($compiler_hosts)
$puppetdb_database_target = $puppetdb_database_host ? {
undef => $master_target,
default => peadm::get_targets($puppetdb_database_host, 1)
}
# Ensure input valid for a supported architecture
$arch = peadm::validate_architecture(
$master_host,
$master_replica_host,
$puppetdb_database_host,
$puppetdb_database_replica_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', $master_target,
path => '/etc/puppetlabs/puppet/hiera.yaml',
).first['content']
run_task('peadm::mkdir_p_file', peadm::flatten_compact([
$master_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
# Pending resolution of Bolt GH-1244, Target objects and their methods are
# not accessible inside apply() blocks. Work around the limitation for now
# by using string variables calculated outside the apply block. The
# commented-out values should be used once GH-1244 is resolved.
# WORKAROUND: GH-1244
$master_host_string = $master_target.peadm::target_name()
$master_replica_host_string = $master_replica_target.peadm::target_name()
$puppetdb_database_host_string = $puppetdb_database_target.peadm::target_name()
$puppetdb_database_replica_host_string = $puppetdb_database_replica_target.peadm::target_name()
apply($master_target) {
# Necessary to give the sandboxed Puppet executor the configuration
# necessary to connect to the classifier`
file { 'node_manager.yaml':
ensure => file,
mode => '0644',
path => Deferred('peadm::node_manager_yaml_location'),
content => epp('peadm/node_manager.yaml.epp', {
server => $master_host_string,
}),
}
class { 'peadm::setup::node_manager':
# WORKAROUND: GH-1244
master_host => $master_host_string, # $master_target.peadm::target_name(),
master_replica_host => $master_replica_host_string, # $master_replica_target.peadm::target_name(),
puppetdb_database_host => $puppetdb_database_host_string, # $puppetdb_database_target.peadm::target_name(),
puppetdb_database_replica_host => $puppetdb_database_replica_host_string, # $puppetdb_database_replica_target.peadm::target_name(),
compiler_pool_address => $compiler_pool_address,
require => File['node_manager.yaml'],
}
}
# Run Puppet in no-op on the compilers so that their status in PuppetDB
# is updated and they can be identified by the puppet_enterprise module as
# CMs
run_task('peadm::puppet_runonce', peadm::flatten_compact([
$compiler_targets,
$master_replica_target,
]),
noop => true,
)
# Run Puppet on the PuppetDB Database hosts to update their auth
# configuration to allow the compilers to connect
run_task('peadm::puppet_runonce', peadm::flatten_compact([
$puppetdb_database_target,
$puppetdb_database_replica_target,
]))
# Run Puppet on the master to ensure all services configured and
# running in prep for provisioning the replica. This is done separately so
# that a service restart of pe-puppetserver doesn't cause Puppet runs on
# other nodes to fail.
run_task('peadm::puppet_runonce', $master_target)
if $arch['high-availability'] {
# Run the PE Replica Provision
run_task('peadm::provision_replica', $master_target,
master_replica => $master_replica_target.peadm::target_name(),
token_file => $token_file,
)
# Run the PE Replica Enable
run_task('peadm::enable_replica', $master_target,
master_replica => $master_replica_target.peadm::target_name(),
token_file => $token_file,
)
}
# Run Puppet everywhere to pick up last remaining config tweaks
run_task('peadm::puppet_runonce', peadm::flatten_compact([
$master_target,
$puppetdb_database_target,
$compiler_targets,
$master_replica_target,
$puppetdb_database_replica_target,
]))
# Deploy an environment if a deploy environment is specified
if $deploy_environment {
run_task('peadm::code_manager', $master_target,
action => "deploy ${deploy_environment}",
)
}
return("Configuration of Puppet Enterprise ${arch['architecture']} succeeded.")
}