Skip to content

Commit e97569b

Browse files
committed
(PE-38770) Install Plan accepts legacy_compilers key (#474)
* feat(peadm): add support for legacy compilers - Added `legacy_compilers` parameter to `peadm::install`, `peadm::subplans::install`, and `peadm::subplans::configure` plans. - Updated `peadm::assert_supported_architecture` function to handle `legacy_compilers`. - Modified various plans to include `legacy_compilers` in the installation and configuration processes. - Updated documentation to reflect the changes and added examples for `legacy_compilers`. This change allows the PEADM module to support legacy compilers in addition to the standard compilers. * feat(assert_supported_architecture): normalize and combine compiler variables - Normalize `$legacy_compilers` and `$compiler_hosts` to arrays, handling both strings and arrays. - Combine the normalized arrays into `$all_compilers`. - Set `$has_compilers` to `undef` if `$all_compilers` is empty, otherwise set it to `true`. - Update tests to cover scenarios with both `compiler_hosts` and `legacy_compilers`. This change ensures that the function correctly handles different types for compiler variables and improves robustness. * Updated REFERENCE.md to document the new parameter. * style(tests): use single quotes for consistency in spec files Updated all double quotes to single quotes in the `assert_supported_architecture_spec.rb` and `install_spec.rb` files to maintain consistency in string literals across the test suite. * refactor(plans): rename legacy_targets to legacy_compiler_targets Renamed the variable `legacy_targets` to `legacy_compiler_targets` across multiple plans for better clarity and consistency. This change affects the following plans: - convert_compiler_to_legacy.pp - subplans/configure.pp - subplans/install.pp The new variable name more accurately reflects its purpose, which is to target legacy compiler hosts. * docs(install): correct grammar in installation requirements section Corrected the grammar in the installation requirements section by changing "Puppets must not be installed" to "Puppet must not be installed" for clarity and accuracy.
1 parent 590af0b commit e97569b

File tree

9 files changed

+281
-95
lines changed

9 files changed

+281
-95
lines changed

REFERENCE.md

+52-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Type: Puppet Language
142142

143143
Assert that the architecture given is a supported one
144144

145-
#### `peadm::assert_supported_architecture(TargetSpec $primary_host, Variant[TargetSpec, Undef] $replica_host = undef, Variant[TargetSpec, Undef] $primary_postgresql_host = undef, Variant[TargetSpec, Undef] $replica_postgresql_host = undef, Variant[TargetSpec, Undef] $compiler_hosts = undef)`
145+
#### `peadm::assert_supported_architecture(TargetSpec $primary_host, Variant[TargetSpec, Undef] $replica_host = undef, Variant[TargetSpec, Undef] $primary_postgresql_host = undef, Variant[TargetSpec, Undef] $replica_postgresql_host = undef, Variant[TargetSpec, Undef] $compiler_hosts = undef, Variant[TargetSpec, Undef] $legacy_compilers = undef)`
146146

147147
The peadm::assert_supported_architecture function.
148148

@@ -168,6 +168,17 @@ Data type: `Variant[TargetSpec, Undef]`
168168

169169
Data type: `Variant[TargetSpec, Undef]`
170170

171+
<<<<<<< HEAD
172+
=======
173+
174+
175+
##### `legacy_compilers`
176+
177+
Data type: `Variant[TargetSpec, Undef]`
178+
179+
180+
181+
>>>>>>> d6467f9 ((PE-38770) Install Plan accepts legacy_compilers key (#474))
171182
### <a name="peadm--assert_supported_bolt_version"></a>`peadm::assert_supported_bolt_version`
172183
173184
Type: Puppet Language
@@ -1829,6 +1840,7 @@ Install a new PE cluster
18291840

18301841
The following parameters are available in the `peadm::install` plan:
18311842

1843+
<<<<<<< HEAD
18321844
- [`compiler_pool_address`](#-peadm--install--compiler_pool_address)
18331845
- [`internal_compiler_a_pool_address`](#-peadm--install--internal_compiler_a_pool_address)
18341846
- [`internal_compiler_b_pool_address`](#-peadm--install--internal_compiler_b_pool_address)
@@ -1857,6 +1869,37 @@ The following parameters are available in the `peadm::install` plan:
18571869
- [`download_mode`](#-peadm--install--download_mode)
18581870
- [`permit_unsafe_versions`](#-peadm--install--permit_unsafe_versions)
18591871
- [`token_lifetime`](#-peadm--install--token_lifetime)
1872+
=======
1873+
* [`compiler_pool_address`](#-peadm--install--compiler_pool_address)
1874+
* [`internal_compiler_a_pool_address`](#-peadm--install--internal_compiler_a_pool_address)
1875+
* [`internal_compiler_b_pool_address`](#-peadm--install--internal_compiler_b_pool_address)
1876+
* [`pe_installer_source`](#-peadm--install--pe_installer_source)
1877+
* [`ldap_config`](#-peadm--install--ldap_config)
1878+
* [`final_agent_state`](#-peadm--install--final_agent_state)
1879+
* [`stagingdir`](#-peadm--install--stagingdir)
1880+
* [`uploaddir`](#-peadm--install--uploaddir)
1881+
* [`primary_host`](#-peadm--install--primary_host)
1882+
* [`replica_host`](#-peadm--install--replica_host)
1883+
* [`compiler_hosts`](#-peadm--install--compiler_hosts)
1884+
* [`legacy_compilers`](#-peadm--install--legacy_compilers)
1885+
* [`primary_postgresql_host`](#-peadm--install--primary_postgresql_host)
1886+
* [`replica_postgresql_host`](#-peadm--install--replica_postgresql_host)
1887+
* [`console_password`](#-peadm--install--console_password)
1888+
* [`version`](#-peadm--install--version)
1889+
* [`dns_alt_names`](#-peadm--install--dns_alt_names)
1890+
* [`pe_conf_data`](#-peadm--install--pe_conf_data)
1891+
* [`code_manager_auto_configure`](#-peadm--install--code_manager_auto_configure)
1892+
* [`r10k_remote`](#-peadm--install--r10k_remote)
1893+
* [`r10k_private_key_file`](#-peadm--install--r10k_private_key_file)
1894+
* [`r10k_private_key_content`](#-peadm--install--r10k_private_key_content)
1895+
* [`r10k_known_hosts`](#-peadm--install--r10k_known_hosts)
1896+
* [`deploy_environment`](#-peadm--install--deploy_environment)
1897+
* [`license_key_file`](#-peadm--install--license_key_file)
1898+
* [`license_key_content`](#-peadm--install--license_key_content)
1899+
* [`download_mode`](#-peadm--install--download_mode)
1900+
* [`permit_unsafe_versions`](#-peadm--install--permit_unsafe_versions)
1901+
* [`token_lifetime`](#-peadm--install--token_lifetime)
1902+
>>>>>>> d6467f9 ((PE-38770) Install Plan accepts legacy_compilers key (#474))
18601903
18611904
##### <a name="-peadm--install--compiler_pool_address"></a>`compiler_pool_address`
18621905

@@ -1950,6 +1993,14 @@ Default value: `undef`
19501993

19511994
Data type: `Optional[TargetSpec]`
19521995

1996+
Default value: `undef`
1997+
1998+
##### <a name="-peadm--install--legacy_compilers"></a>`legacy_compilers`
1999+
2000+
Data type: `Optional[TargetSpec]`
2001+
2002+
2003+
19532004
Default value: `undef`
19542005

19552006
##### <a name="-peadm--install--primary_postgresql_host"></a>`primary_postgresql_host`

documentation/install.md

+67-63
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,68 @@
1-
# Install Puppet Enterprise using the peadm module
1+
# Install Puppet Enterprise using the PEADM module
22

3-
The peadm module can be used to install Puppet Enterprise on new infrastructure. Supported architectures include Standard, Large, and Extra Large.
3+
The PEADM module can be used to install Puppet Enterprise on new infrastructure. Supported architectures include Standard, Large, and Extra Large.
44

5-
The peadm install plan creates a base install. Once a base cluster is installed, you may need to continue and perform additional configuration and adjustments to reach your target state, depending on your use case.
5+
The PEADM install plan creates a base install. Once a base cluster is installed, you may need to continue and perform additional configuration and adjustments to reach your target state, depending on your use case.
66

77
## Reference Architectures
88

9-
When installing a new PE cluster using peadm, there are several different host parameters which can be specified. At a minimum, you must always specify the primary parameter. Depending on which architecture you are deploying, other host parameters may be needed as well. The following is a list of the architectures peadm can install and the required parameters.
10-
11-
* Standard
12-
- primary
13-
* Standard with DR
14-
- primary
15-
- primary-replica
16-
* Large
17-
- primary
18-
- compilers
19-
* Large with DR
20-
- primary
21-
- primary-replica
22-
- compilers
23-
* Extra Large
24-
- primary
25-
- pdb-database
26-
- compilers (optional)
27-
* Extra Large with DR
28-
- primary
29-
- primary-replica
30-
- pdb-database
31-
- pdb-database-replica
32-
- compilers (optional)
33-
34-
Supplying a combination of host parameters which does not match one of the supported architectures above will result in an unsupported architecture error.
9+
When installing a new PE cluster using PEADM, several different host parameters can be specified. At a minimum, you must always specify the primary parameter. Depending on which architecture you are deploying, other host parameters may be needed as well. The following is a list of the architectures PEADM can install and the required parameters.
10+
11+
- Standard
12+
- primary
13+
- Standard with DR
14+
- primary
15+
- primary-replica
16+
- Large
17+
- primary
18+
- compilers
19+
- Large with DR
20+
- primary
21+
- primary-replica
22+
- compilers
23+
- Extra Large
24+
- primary
25+
- pdb-database
26+
- compilers (optional)
27+
- Extra Large with DR
28+
- primary
29+
- primary-replica
30+
- pdb-database
31+
- pdb-database-replica
32+
- compilers (optional)
33+
34+
Supplying a combination of host parameters that do not match one of the supported architectures above will result in an unsupported architecture error.
3535

3636
## Requirements
3737

38-
* Puppet must not be installed on any of the target PE cluster hosts prior to beginning install.
38+
Puppet must not be installed on any of the target PE cluster hosts before beginning installation.
3939

4040
## Usage
4141

4242
### Bolt 3 usage
43+
4344
We will name the bolt project `large_ha_peadm` in this example but the project name can be anything.
4445

4546
1. Install Bolt on a jumphost. This can be the primary, or any other system. (via package)
4647
2. Run `mkdir large_ha_peadm && cd large_ha_peadm && bolt project init large_ha_peadm --modules puppetlabs-peadm`
47-
4. Create an inventory file with connection information. Example included below.
48-
5. Create a parameters file. Example included below.
49-
6. Run `bolt plan run peadm::install --params @params.json ` after the inventory and params files are created.
50-
48+
3. Create an inventory file with connection information. Example included below.
49+
4. Create a parameters file. Example included below.
50+
5. Run `bolt plan run peadm::install --params @params.json ` after the inventory and params files are created.
5151

5252
### Bolt 2 usage
5353

54-
1. Install Bolt on a jumphost. This can be the primary, or any other system.
55-
2. Download or git clone the peadm module and put it somewhere on the jumphost. e.g. ~/modules/peadm.
56-
3. Download or git clone the module dependencies, and put them somewhere on the jumphost. e.g. ~/modules/stdlib, ~/modules/node\_manager, etc.
57-
4. Create an inventory file with connection information. Example included below.
58-
5. Create a parameters file. Example included below.
59-
6. Run the peadm::install plan with the inputs created. Example:
54+
1. Install Bolt on a jumphost. This can be the primary or any other system.
55+
2. Download or git clone the PEADM module and put it somewhere on the jumphost. e.g. ~/modules/peadm.
56+
3. Download or git clone the module dependencies, and put them somewhere on the jumphost. e.g. ~/modules/stdlib, ~/modules/node_manager, etc.
57+
4. Create an inventory file with connection information. Example included below.
58+
5. Create a parameters file. Example included below.
59+
6. Run the peadm::install plan with the inputs created. Example:
6060

6161
bolt plan run peadm::install \
6262
--inventory inventory.yaml \
6363
--modulepath ~/modules \
6464
--params @params.json
6565

66-
6766
Example inventory.yaml Bolt inventory file:
6867

6968
```yaml
@@ -85,9 +84,13 @@ groups:
8584
uri: 10.234.6.45
8685
- name: pe-xl-compiler-1.lab1.puppet.vm
8786
uri: 10.234.14.131
87+
- name: pe-xl-legacy-compiler-0.lab1.puppet.vm
88+
uri: 10.234.6.46
89+
- name: pe-xl-legacy-compiler-1.lab1.puppet.vm
90+
uri: 10.234.6.47
8891
```
8992
90-
Example params.json Bolt parameters file (shown: Extra Large with DR):
93+
example params.json bolt parameters file (shown: extra large with dr):
9194
9295
```json
9396
{
@@ -99,9 +102,12 @@ Example params.json Bolt parameters file (shown: Extra Large with DR):
99102
"pe-xl-compiler-0.lab1.puppet.vm",
100103
"pe-xl-compiler-1.lab1.puppet.vm"
101104
],
102-
105+
"legacy_compilers": [
106+
"pe-xl-legacy-compiler-0.lab1.puppet.vm",
107+
"pe-xl-legacy-compiler-1.lab1.puppet.vm"
108+
],
103109
"console_password": "puppetlabs",
104-
"dns_alt_names": [ "puppet", "puppet.lab1.puppet.vm" ],
110+
"dns_alt_names": ["puppet", "puppet.lab1.puppet.vm"],
105111
"compiler_pool_address": "puppet.lab1.puppet.vm",
106112
"version": "2021.7.0"
107113
}
@@ -113,41 +119,40 @@ Example params.json Bolt parameters file (shown: Standard):
113119
{
114120
"primary_host": "pe-xl-core-0.lab1.puppet.vm",
115121
"console_password": "puppetlabs",
116-
"dns_alt_names": [ "puppet", "puppet.lab1.puppet.vm" ],
122+
"dns_alt_names": ["puppet", "puppet.lab1.puppet.vm"],
117123
"version": "2021.7.9"
118124
}
119125
```
120126

121-
Review the [peadm::install plan](../plans/install.pp) to learn about more advanced installation options. For example, it is possible to: supply an ssh private key and git clone URL for a control-repo as part of installation; supply the LDAP configuration data for PE; specify where the installer tarball is uploaded; and similar complete automation tie-ins.
127+
Review the [peadm::install plan](../plans/install.pp) to learn about more advanced installation options. For example, it is possible to: supply an SSH private key and git clone URL for a control-repo as part of installation; supply the LDAP configuration data for PE; specify where the installer tarball is uploaded; and similar complete automation tie-ins.
122128

123129
## Offline usage
124130

125131
The peadm::install plan downloads installation content from an online repository by default. To perform an offline installation, you can prefetch the needed content and place it in the staging directory on the Bolt host. If content is available in the staging directory, peadm::install will not try to download it.
126132

127133
The default staging directory is `/tmp`. If a different staging dir is being used, it can be specified using the `stagingdir` parameter to the peadm::install plan.
128134

129-
The content needed is the PE installation tarball for the target version. The installation content should be in the staging dir, and should have its original name. E.g. `/tmp/puppet-enterprise-2021.4.0-el-7-x86_64.tar.gz`.
135+
The content needed is the PE installation tarball for the target version. The installation content should be in the staging dir and should have its original name. E.g. `/tmp/puppet-enterprise-2021.4.0-el-7-x86_64.tar.gz`.
130136

131137
Installation content can be downloaded from [https://puppet.com/try-puppet/puppet-enterprise/download/](https://puppet.com/try-puppet/puppet-enterprise/download/).
132138

133-
If you wish to prevent the bolt host from transferring the installer tarball to the targets you can place the installer tar files on the target hosts in the _upload directory_. This can save time over slow networks, but is best to just perform the bolt task on the target node (puppetserver). The default _upload directory_ is `/tmp`. If a different upload dir is being used, it can be specified using the `uploaddir` parameter to the peadm::install plan. With default parameters the tar file will need to exist in the directories for offline configuration:
139+
If you wish to prevent the bolt host from transferring the installer tarball to the targets you can place the installer tar files on the target hosts in the _upload directory_. This can save time over slow networks, but is best to just perform the bolt task on the target node (puppetserver). The default _upload directory_ is `/tmp`. If a different upload dir is being used, it can be specified using the `uploaddir` parameter to the peadm::install plan. With default parameters, the tar file will need to exist in the directories for offline configuration:
134140

135-
* /tmp on the Bolt host
136-
* /tmp on the primary
137-
* /tmp on the primary PuppetDB PostgreSQL (if used)
138-
* /tmp on the replica PuppetDB PostgreSQL (if used)
141+
- /tmp on the Bolt host
142+
- /tmp on the primary
143+
- /tmp on the primary PuppetDB PostgreSQL (if used)
144+
- /tmp on the replica PuppetDB PostgreSQL (if used)
139145

140146
## Online usage
141147

142-
The peadm::install plan can be configured to download installation content directly to hosts. To configure online installation, set the `download_mode` parameter of the `peadm::install` plan to `direct`. The direct mode is often more efficient when PE hosts have a route to the internet.
148+
The peadm::install plan can be configured to download installation content directly to hosts. To configure the online installation, set the `download_mode` parameter of the `peadm::install` plan to `direct`. The direct mode is often more efficient when PE hosts have a route to the internet.
143149

144150
## Hostnames and Certificate Names
145151

146152
The various host parameters given to the peadm::install or peadm::action::install plans will be set as Puppet certificate names. You must use the names here that you want the servers to be identified as by Puppet.
147153

148154
While it is not required that target names match hostnames, it _is_ required that target names be resolvable.
149-
150-
In the event that Bolt will reach servers by IP address or external DNS name rather than internal DNS name or desired certname, a Bolt inventory file should be used to specify URIs for each name. For example:
155+
If Bolt will reach servers by IP address or external DNS name rather than internal DNS name or desired certname, a Bolt inventory file should be used to specify URIs for each name. For example:
151156

152157
```yaml
153158
---
@@ -158,28 +163,27 @@ targets:
158163
uri: 10.234.14.131
159164
```
160165
161-
A parameters JSON file can then reference the target names, which will become the Puppet certificate names, and Bolt will still be able to reach the systems by using the IP addresses or other DNS name specified as the URIs in the inventory.yaml file.
166+
A parameters JSON file can then reference the target names, which will become the Puppet certificate names, and Bolt will still be able to reach the systems by using the IP addresses or other DNS names specified as the URIs in the inventory.yaml file.
162167
163168
```json
164169
{
165170
"primary_host": "pe-xl-core-0.lab1.puppet.vm",
166171
"replica_host": "pe-xl-core-1.lab1.puppet.vm",
167172

168173
"console_password": "puppetlabs",
169-
"dns_alt_names": [ "puppet", "puppet.lab1.puppet.vm" ],
174+
"dns_alt_names": ["puppet", "puppet.lab1.puppet.vm"],
170175
"compiler_pool_address": "puppet.lab1.puppet.vm",
171176
"version": "2021.7.0"
172177
}
173178
```
174179

175180
## Implementation Reference
176181

177-
Provisioning can be broken down into two actions: [install](../plans/action/install.pp), and [configure](../plans/subplans/configure.pp). Installation currently requires ssh access to the un-installed nodes, but configure can be performed using the Orchestrator transport if installation has already been completed.
178-
179-
Besides getting Puppet Enterprise installed, the key configuration supporting Large and Extra Large architectures is laid out in four classification groups. Links are provided below to a Markdown document that describes the groups, and also to the Puppet manifest that actually configures them:
182+
Provisioning can be broken down into two actions: [install](../plans/action/install.pp), and [configure](../plans/subplans/configure.pp). The installation currently requires SSH access to the uninstalled nodes, but configuration can be performed using the Orchestrator transport if the installation has already been completed.
180183

181-
* [classification.md](classification.md)
182-
* [peadm::setup::node\_manager class](../manifests/setup/node_manager.pp)
184+
Besides getting Puppet Enterprise installed, the key configuration supporting Large and Extra-large architectures is laid out in four classification groups. Links are provided below to a Markdown document that describes the groups, and also to the Puppet manifest that configures them:
183185

184-
The reference implementation uses trusted facts to put nodes in the right groups. Because the important puppet\_enterprise::\* class parameters and data are specified in the console, it should also be safe to have a pe.conf present on both the primary, and the primary replica nodes.
186+
- [classification.md](classification.md)
187+
- [peadm::setup::node_manager class](../manifests/setup/node_manager.pp)
185188

189+
The reference implementation uses trusted facts to put nodes in the right groups. Because the important puppet_enterprise::\* class parameters and data are specified in the console, it should also be safe to have a pe.conf present on both the primary and the primary replica nodes.

functions/assert_supported_architecture.pp

+27-3
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,45 @@ function peadm::assert_supported_architecture (
55
Variant[TargetSpec, Undef] $primary_postgresql_host = undef,
66
Variant[TargetSpec, Undef] $replica_postgresql_host = undef,
77
Variant[TargetSpec, Undef] $compiler_hosts = undef,
8+
Variant[TargetSpec, Undef] $legacy_compilers = undef,
89
) >> Hash {
10+
# Normalize $legacy_compilers to an array
11+
$legacy_compilers_array = $legacy_compilers ? {
12+
undef => [],
13+
String => [$legacy_compilers],
14+
Array => $legacy_compilers,
15+
default => fail("Unexpected type for \$legacy_compilers: ${legacy_compilers}"),
16+
}
17+
18+
# Normalize $compiler_hosts to an array
19+
$compiler_hosts_array = $compiler_hosts ? {
20+
undef => [],
21+
String => [$compiler_hosts],
22+
Array => $compiler_hosts,
23+
default => fail("Unexpected type for \$compiler_hosts: ${compiler_hosts}"),
24+
}
25+
$all_compilers = $legacy_compilers_array + $compiler_hosts_array
26+
27+
# Set $has_compilers to undef if $all_compilers is empty, otherwise set it to true
28+
$has_compilers = empty($all_compilers) ? {
29+
true => undef,
30+
default => true,
31+
}
32+
933
$result = case [
1034
!!($primary_host),
1135
!!($replica_host),
1236
!!($primary_postgresql_host),
1337
!!($replica_postgresql_host),
1438
] {
1539
[true, false, false, false]: { # Standard or Large, no DR
16-
({ 'disaster-recovery' => false, 'architecture' => $compiler_hosts ? {
40+
({ 'disaster-recovery' => false, 'architecture' => $has_compilers ? {
1741
undef => 'standard',
1842
default => 'large',
1943
} })
2044
}
2145
[true, true, false, false]: { # Standard or Large, DR
22-
({ 'disaster-recovery' => true, 'architecture' => $compiler_hosts ? {
46+
({ 'disaster-recovery' => true, 'architecture' => $has_compilers ? {
2347
undef => 'standard',
2448
default => 'large',
2549
} })
@@ -44,7 +68,7 @@ function peadm::assert_supported_architecture (
4468
<% if $replica_postgresql_host { -%>
4569
- pdb-database-replica
4670
<% } -%>
47-
<% if $compiler_hosts { -%>
71+
<% if $has_compilers { -%>
4872
- compilers
4973
<% } -%>
5074

0 commit comments

Comments
 (0)