Skip to content

Commit 1e66c5f

Browse files
committed
Add convert plan; replaces upgrade_trusted_facts
TODO: test/fix The convert plan serves to upgrade peadm deployments created using 0.5.x of the module, as well as to adopt manually deployed PE infrastructure for management with peadm.
1 parent 1634b7f commit 1e66c5f

File tree

8 files changed

+176
-109
lines changed

8 files changed

+176
-109
lines changed

documentation/convert.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Convert infrastructure for use with the peadm module
2+
3+
The peadm::convert plan can be used to adopt manually deployed infrastructure for use with peadm, or to adopt infrastructure deployed with a version of peadm older than 1.0.0.
4+
5+
## Convert an Existing Deployment
6+
7+
Prepare to run the plan against all servers in the PE infrastructure, using a params.json file such as this one:
8+
9+
```json
10+
{
11+
"master_host": "pe-xl-core-0.lab1.puppet.vm",
12+
"master_replica_host": "pe-xl-core-1.lab1.puppet.vm",
13+
"compiler_hosts": [
14+
"pe-xl-compiler-0.lab1.puppet.vm",
15+
"pe-xl-compiler-1.lab1.puppet.vm"
16+
],
17+
18+
"compiler_pool_address": "puppet.lab1.puppet.vm",
19+
}
20+
```
21+
22+
See the [provision](provision.md#reference-architectures) documentation for a list of supported architectures. Note that for convert, *all infrastructure being converted must already be functional*; you cannot use convert to add new systems to the infrastructure, nor can you use it to change your architecture.
23+
24+
```
25+
bolt plan run peadm::convert --params @params.json
26+
```

documentation/old_versions_of_peadm.md

-66
This file was deleted.

manifests/setup/node_manager_yaml.pp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class peadm::setup::node_manager_yaml (
2+
String $master_host,
3+
) {
4+
5+
# Necessary to give the sandboxed Puppet executor the configuration
6+
# necessary to connect to the classifier`
7+
file { 'node_manager.yaml':
8+
ensure => file,
9+
mode => '0644',
10+
path => Deferred('peadm::node_manager_yaml_location'),
11+
content => epp('peadm/node_manager.yaml.epp', {
12+
server => $master_host,
13+
}),
14+
}
15+
16+
}

plans/action/configure.pp

+7-25
Original file line numberDiff line numberDiff line change
@@ -56,37 +56,19 @@
5656

5757
# Set up the console node groups to configure the various hosts in their roles
5858

59-
# Pending resolution of Bolt GH-1244, Target objects and their methods are
60-
# not accessible inside apply() blocks. Work around the limitation for now
61-
# by using string variables calculated outside the apply block. The
62-
# commented-out values should be used once GH-1244 is resolved.
63-
64-
# WORKAROUND: GH-1244
65-
$master_host_string = $master_target.peadm::target_name()
66-
$master_replica_host_string = $master_replica_target.peadm::target_name()
67-
$puppetdb_database_host_string = $puppetdb_database_target.peadm::target_name()
68-
$puppetdb_database_replica_host_string = $puppetdb_database_replica_target.peadm::target_name()
69-
7059
apply($master_target) {
71-
# Necessary to give the sandboxed Puppet executor the configuration
72-
# necessary to connect to the classifier`
73-
file { 'node_manager.yaml':
74-
ensure => file,
75-
mode => '0644',
76-
path => Deferred('peadm::node_manager_yaml_location'),
77-
content => epp('peadm/node_manager.yaml.epp', {
78-
server => $master_host_string,
79-
}),
60+
class { 'peadm::setup::node_manager_yaml':
61+
master_host => $master_target.peadm::target_name(),
8062
}
8163

8264
class { 'peadm::setup::node_manager':
8365
# WORKAROUND: GH-1244
84-
master_host => $master_host_string, # $master_target.peadm::target_name(),
85-
master_replica_host => $master_replica_host_string, # $master_replica_target.peadm::target_name(),
86-
puppetdb_database_host => $puppetdb_database_host_string, # $puppetdb_database_target.peadm::target_name(),
87-
puppetdb_database_replica_host => $puppetdb_database_replica_host_string, # $puppetdb_database_replica_target.peadm::target_name(),
66+
master_host => $master_target.peadm::target_name(),
67+
master_replica_host => $master_replica_target.peadm::target_name(),
68+
puppetdb_database_host => $puppetdb_database_target.peadm::target_name(),
69+
puppetdb_database_replica_host => $puppetdb_database_replica_target.peadm::target_name(),
8870
compiler_pool_address => $compiler_pool_address,
89-
require => File['node_manager.yaml'],
71+
require => Class['peadm::setup::node_manager_yaml'],
9072
}
9173
}
9274

plans/convert.pp

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
plan peadm::convert (
2+
# Standard
3+
Peadm::SingleTargetSpec $master_host,
4+
Optional[Peadm::SingleTargetSpec] $master_replica_host = undef,
5+
6+
# Large
7+
Optional[TargetSpec] $compiler_hosts = undef,
8+
9+
# Extra Large
10+
Optional[Peadm::SingleTargetSpec] $puppetdb_database_host = undef,
11+
Optional[Peadm::SingleTargetSpec] $puppetdb_database_replica_host = undef,
12+
13+
# Common Configuration
14+
Optional[Array[String]] $dns_alt_names = undef,
15+
Optional[String] $compiler_pool_address = undef,
16+
) {
17+
# Convert inputs into targets.
18+
$master_target = peadm::get_targets($master_host, 1)
19+
$master_replica_target = peadm::get_targets($master_replica_host, 1)
20+
$puppetdb_database_replica_target = peadm::get_targets($puppetdb_database_replica_host, 1)
21+
$compiler_targets = peadm::get_targets($compiler_hosts)
22+
$puppetdb_database_target = peadm::get_targets($puppetdb_database_host, 1)
23+
24+
# Ensure input valid for a supported architecture
25+
$arch = peadm::validate_architecture(
26+
$master_host,
27+
$master_replica_host,
28+
$puppetdb_database_host,
29+
$puppetdb_database_replica_host,
30+
$compiler_hosts,
31+
)
32+
33+
# Clusters A and B are used to divide PuppetDB availability for compilers
34+
if $arch['high-availability'] {
35+
$compiler_a_targets = $compiler_targets.filter |$index,$target| { $index % 2 == 0 }
36+
$compiler_b_targets = $compiler_targets.filter |$index,$target| { $index % 2 != 0 }
37+
}
38+
else {
39+
$compiler_a_targets = $compiler_targets
40+
$compiler_b_targets = []
41+
}
42+
43+
# Modify csr_attributes.yaml and insert the peadm-specific OIDs to identify
44+
# each server's role and availability group
45+
46+
run_plan('peadm::util::add_cert_extensions', $master_target,
47+
master_host => $master_target,
48+
extensions => {
49+
peadm::oid('peadm_role') => 'puppet/master',
50+
peadm::oid('peadm_availability_group') => 'A',
51+
},
52+
)
53+
54+
run_plan('peadm::util::add_cert_extensions', $master_replica_target,
55+
master_host => $master_target,
56+
extensions => {
57+
peadm::oid('peadm_role') => 'puppet/master',
58+
peadm::oid('peadm_availability_group') => 'B',
59+
},
60+
)
61+
62+
run_plan('peadm::util::add_cert_extensions', $puppetdb_database_target,
63+
master_host => $master_target,
64+
extensions => {
65+
peadm::oid('peadm_role') => 'puppet/puppetdb-database',
66+
peadm::oid('peadm_availability_group') => 'A',
67+
},
68+
)
69+
70+
run_plan('peadm::util::add_cert_extensions', $puppetdb_database_replica_target,
71+
master_host => $master_target,
72+
extensions => {
73+
peadm::oid('peadm_role') => 'puppet/puppetdb-database',
74+
peadm::oid('peadm_availability_group') => 'B',
75+
},
76+
)
77+
78+
run_plan('peadm::util::add_cert_extensions', $compiler_a_targets,
79+
master_host => $master_target,
80+
extensions => {
81+
peadm::oid('peadm_role') => 'puppet/compiler',
82+
peadm::oid('peadm_availability_group') => 'A',
83+
},
84+
)
85+
86+
run_plan('peadm::util::add_cert_extensions', $compiler_b_targets,
87+
master_host => $master_target,
88+
extensions => {
89+
peadm::oid('peadm_role') => 'puppet/compiler',
90+
peadm::oid('peadm_availability_group') => 'B',
91+
},
92+
)
93+
94+
# Create the necessary node groups in the console
95+
96+
apply($master_target) {
97+
class { 'peadm::setup::node_manager_yaml':
98+
master_host => $master_target.peadm::target_name(),
99+
}
100+
101+
class { 'peadm::setup::node_manager':
102+
master_host => $master_target.peadm::target_name(),
103+
master_replica_host => $master_replica_target.peadm::target_name(),
104+
puppetdb_database_host => $puppetdb_database_target.peadm::target_name(),
105+
puppetdb_database_replica_host => $puppetdb_database_replica_target.peadm::target_name(),
106+
compiler_pool_address => $compiler_pool_address,
107+
require => Class['peadm::setup::node_manager_yaml'],
108+
}
109+
}
110+
111+
# TODO: consider extending to ensure HA replica is provisioned/enabled
112+
113+
return("Conversion to peadm Puppet Enterprise ${arch['architecture']} succeeded.")
114+
}

plans/upgrade.pp

+1-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@
5858
fail_plan(@(HEREDOC/L))
5959
Required trusted facts are not present; upgrade cannot be completed. If \
6060
this infrastructure was provisioned with an old version of peadm, you may \
61-
need to run the peadm::misc::upgrade_trusted_facts plan against each of the \
62-
infrastructure nodes.
61+
need to run the peadm::convert plan\
6362
| HEREDOC
6463
}
6564

plans/misc/upgrade_trusted_facts.pp plans/util/add_cert_extensions.pp

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
plan peadm::misc::upgrade_trusted_facts (
2-
TargetSpec $targets,
3-
Peadm::SingleTargetSpec $master_host,
1+
plan peadm::util::add_cert_extensions (
2+
TargetSpec $targets,
3+
TargetSpec $master_host,
4+
Hash $extensions,
45
) {
5-
6-
# Convert input into array of Targets
76
$all_targets = peadm::get_targets($targets)
87
$master_target = peadm::get_targets($master_host, 1)
98

@@ -35,15 +34,12 @@
3534
$all_targets.map |$target| {
3635

3736
# This will be the new trusted fact data for this node
38-
$new_trusted = $certdata[$target]['extensions'] + {
39-
peadm::oid('peadm_role') => $certdata[$target]['extensions'][peadm::oid('pp_application')],
40-
peadm::oid('peadm_availability_group') => $certdata[$target]['extensions'][peadm::oid('pp_cluster')],
41-
}
37+
$extension_requests = $certdata[$target]['extensions'] + $extensions
4238

4339
# Make sure the csr_attributes.yaml file on the node matches
44-
run_plan('peadm::util::insert_csr_extensions', $target,
45-
extensions => $new_trusted,
46-
merge => false,
40+
run_plan('peadm::util::insert_csr_extension_requests', $target,
41+
extension_requests => $extension_requests,
42+
merge => false,
4743
)
4844

4945
# Everything starts the same; we always revoke the existing cert

plans/util/insert_csr_extensions.pp plans/util/insert_csr_extension_requests.pp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
plan peadm::util::insert_csr_extensions (
1+
plan peadm::util::insert_csr_extension_requests (
22
TargetSpec $targets,
3-
Hash $extensions,
3+
Hash $extension_requests,
44
Boolean $merge = true,
55
) {
66
get_targets($targets).each |$target| {
@@ -15,8 +15,8 @@
1515
# If we're not merging, only ours will be used; existing requests will be
1616
# overritten.
1717
$csr_file_data = $merge ? {
18-
true => $csr_attributes_data.deep_merge({'extension_requests' => $extensions}),
19-
false => ($csr_attributes_data + {'extension_requests' => $extensions}),
18+
true => $csr_attributes_data.deep_merge({'extension_requests' => $extension_requests}),
19+
false => ($csr_attributes_data + {'extension_requests' => $extension_requests}),
2020
}
2121

2222
run_task('peadm::mkdir_p_file', $target,

0 commit comments

Comments
 (0)