Skip to content

(PE-39789) Support custom environment #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 33 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ You can use PEADM to deploy and manage PE installations for standard, large, and

#### Table of contents

- [Puppet Enterprise Administration Module (PEADM)](#puppet-enterprise-pe-administration-adm-module)
- [Table of contents](#table-of-contents)
- [Puppet Enterprise Administration Module (PEADM)](#puppet-enterprise-pe-administration-adm-module) - [Table of contents](#table-of-contents)
- [Support](#support)
- [Overview](#overview)
- [What PEADM affects](#what-peadm-affects)
Expand All @@ -24,14 +23,14 @@ You can use PEADM to deploy and manage PE installations for standard, large, and

PEADM is a supported PE module. If you are a PE customer with the standard or premium support service, you can contact [Support](https://portal.perforce.com/s/topic/0TO4X000000DbNgWAK/puppet) or your Technical Account Manager for assistance.


## Overview

This is the standard workflow for installing PEADM.

1. [Install Bolt](https://www.puppet.com/docs/bolt/latest/bolt_installing) on a jump host.
2. To create a Bolt project that includes the PEADM module, run:</br>`mkdir <YOUR_PROJECT> && cd <YOUR_PROJECT> && bolt project init <YOUR_PROJECT> --modules puppetlabs-peadm`
3. In the Bolt project directory, update the `inventory.yaml` file with connection information for the servers you plan to use for hosting PE infrastructure. For example:

```yaml
---
groups:
Expand All @@ -55,57 +54,60 @@ groups:

### What PEADM affects

* The `peadm::install` plan adds a number of custom original identifier (OID) trusted facts to the certificates of deployed PE infrastructure nodes. These trusted facts are used by PEADM plans to identify nodes that host PE infrastructure components.
* Depending on the scale of your architecture, up to four node groups may be created to configure `puppet_enterprise` class parameters for the following PE infrastructure components:
* The primary server
* The primary server replica
* PostgreSQL nodes (database servers)
* Compilers (compiler hosts are designated as belonging to availability group A or B)
- The `peadm::install` plan adds a number of custom original identifier (OID) trusted facts to the certificates of deployed PE infrastructure nodes. These trusted facts are used by PEADM plans to identify nodes that host PE infrastructure components.
- Depending on the scale of your architecture, up to four node groups may be created to configure `puppet_enterprise` class parameters for the following PE infrastructure components:
- The primary server
- The primary server replica
- PostgreSQL nodes (database servers)
- Compilers (compiler hosts are designated as belonging to availability group A or B)

### What PEADM does not affect

* PEADM does not impact regular PE operations. After using it to deploy a new PE installation or upgrade an existing one, PEADM is not required until you want to use it to upgrade PE or expand your installation.
* Using PEADM to install PE or upgrade PE does not prevent you from using documented PE procedures such as setting up disaster recovery or performing a manual upgrade.
- PEADM does not impact regular PE operations. After using it to deploy a new PE installation or upgrade an existing one, PEADM is not required until you want to use it to upgrade PE or expand your installation.
- Using PEADM to install PE or upgrade PE does not prevent you from using documented PE procedures such as setting up disaster recovery or performing a manual upgrade.

### Requirements

* PEADM is compatible with Puppet Enterprise 2019.8.1 or newer versions.
* PEADM requires [Bolt](https://www.puppet.com/docs/bolt/latest/bolt_installing) version 3.17.0 or newer and works on operating systems supported by Bolt.
**Note:** You can use PEADM to install Puppet Enterprise (PE) onto any operating system platform that is supported by the specific PE version you want to install. To review operating system platforms supported by specific PE versions, refer to the PE documentation.
* To successfully convert your current PE installation to a PEADM-managed installation, ensure that the PE setting for editing classifier configuration data is enabled. This setting is enabled by default on new PE installations, but it could be disabled if the relevant configuration was removed from your global hiera.yaml file. See the [PE docs](https://www.puppet.com/docs/pe/latest/config_console.html#enable_console_configuration_data) for more information.
- PEADM is compatible with Puppet Enterprise 2019.8.1 or newer versions.
- PEADM requires [Bolt](https://www.puppet.com/docs/bolt/latest/bolt_installing) version 3.17.0 or newer and works on operating systems supported by Bolt.
**Note:** You can use PEADM to install Puppet Enterprise (PE) onto any operating system platform that is supported by the specific PE version you want to install. To review operating system platforms supported by specific PE versions, refer to the PE documentation.
- To successfully convert your current PE installation to a PEADM-managed installation, ensure that the PE setting for editing classifier configuration data is enabled. This setting is enabled by default on new PE installations, but it could be disabled if the relevant configuration was removed from your global hiera.yaml file. See the [PE docs](https://www.puppet.com/docs/pe/latest/config_console.html#enable_console_configuration_data) for more information.

## Usage

For instructions on using PEADM plans, see the following PEADM docs:

* [Install](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/install.md)
* [Upgrade](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/upgrade.md)
* [Convert](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/convert.md)
* [Status](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/status.md)
- [Install](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/install.md)
- [Upgrade](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/upgrade.md)
- [Convert](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/convert.md)
- [Status](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/status.md)

## Reference

To understand which architecture is right for you, see the following information on the Puppet documentation site:

* [PE architectures](https://puppet.com/docs/pe/latest/choosing_an_architecture.html)
* [PE multi-region reference architectures](https://puppet.com/docs/patterns-and-tactics/latest/reference-architectures/pe-multi-region-reference-architectures.html)

- [PE architectures](https://puppet.com/docs/pe/latest/choosing_an_architecture.html)
- [PE multi-region reference architectures](https://puppet.com/docs/patterns-and-tactics/latest/reference-architectures/pe-multi-region-reference-architectures.html)

To learn more about the PEADM module and its uses, see the following PEADM docs:

* [Recovery procedures](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/recovery.md)
* [Architectures](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/architectures.md)
* [Expanding deployment](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/expanding.md)
* [Classification](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/classification.md)
* [Testing](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/pre_post_checks.md)
* [Docker based examples](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/docker_examples.md)
* [Release process](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/release_process.md)
- [Recovery procedures](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/recovery.md)
- [Architectures](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/architectures.md)
- [Expanding deployment](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/expanding.md)
- [Classification](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/classification.md)
- [Testing](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/pre_post_checks.md)
- [Docker based examples](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/docker_examples.md)
- [Release process](https://github.com/puppetlabs/puppetlabs-peadm/blob/main/documentation/release_process.md)

## Getting help

* If you find a bug, you can [create a GitHub issue](https://github.com/puppetlabs/puppetlabs-peadm/issues).
* For PE customers using PEADM and experiencing outages or other issues, [contact the Support team](https://portal.perforce.com/s/topic/0TO4X000000DbNgWAK/puppet).
- If you find a bug, you can [create a GitHub issue](https://github.com/puppetlabs/puppetlabs-peadm/issues).
- For PE customers using PEADM and experiencing outages or other issues, [contact the Support team](https://portal.perforce.com/s/topic/0TO4X000000DbNgWAK/puppet).

## License

This codebase is licensed under Apache 2.0. However, the open source dependencies included in this codebase might be subject to other software licenses such as AGPL, GPL2.0, and MIT.

## Contributors

The list of contributors can be found at: [https://github.com/puppetlabs/puppetlabs-peadm/graphs/contributors](https://github.com/puppetlabs/puppetlabs-peadm/graphs/contributors).
55 changes: 55 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* [`peadm::file_or_content`](#peadm--file_or_content)
* [`peadm::flatten_compact`](#peadm--flatten_compact)
* [`peadm::generate_pe_conf`](#peadm--generate_pe_conf): Generate a pe.conf file in JSON format
* [`peadm::get_node_group_environment`](#peadm--get_node_group_environment): check if a custom PE environment is set in pe.conf
* [`peadm::get_pe_conf`](#peadm--get_pe_conf)
* [`peadm::get_targets`](#peadm--get_targets): Accept undef or a SingleTargetSpec, and return an Array[Target, 1, 0]. This differs from get_target() in that: - It returns an Array[Target
* [`peadm::migration_opts_default`](#peadm--migration_opts_default)
Expand Down Expand Up @@ -715,6 +716,24 @@ Data type: `Hash`
A hash of settings to set in the config file. Any keys that are set to
undef will not be included in the config file.

### <a name="peadm--get_node_group_environment"></a>`peadm::get_node_group_environment`

Type: Puppet Language

check if a custom PE environment is set in pe.conf

#### `peadm::get_node_group_environment(Peadm::SingleTargetSpec $primary)`

The peadm::get_node_group_environment function.

Returns: `String` the desired environment for PE specific node groups

##### `primary`

Data type: `Peadm::SingleTargetSpec`

the FQDN for the primary, here we will read the pe.conf from

### <a name="peadm--get_pe_conf"></a>`peadm::get_pe_conf`

Type: Puppet Language
Expand Down Expand Up @@ -1563,11 +1582,20 @@ The peadm::add_database class.

The following parameters are available in the `peadm::add_database` plan:

* [`node_group_environment`](#-peadm--add_database--node_group_environment)
* [`targets`](#-peadm--add_database--targets)
* [`primary_host`](#-peadm--add_database--primary_host)
* [`mode`](#-peadm--add_database--mode)
* [`begin_at_step`](#-peadm--add_database--begin_at_step)

##### <a name="-peadm--add_database--node_group_environment"></a>`node_group_environment`

Data type: `String[1]`

environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production

Default value: `peadm::get_node_group_environment($primary_host)`

##### <a name="-peadm--add_database--targets"></a>`targets`

Data type: `Peadm::SingleTargetSpec`
Expand Down Expand Up @@ -1692,6 +1720,7 @@ management using PEAdm.

The following parameters are available in the `peadm::convert` plan:

* [`node_group_environment`](#-peadm--convert--node_group_environment)
* [`primary_host`](#-peadm--convert--primary_host)
* [`replica_host`](#-peadm--convert--replica_host)
* [`compiler_hosts`](#-peadm--convert--compiler_hosts)
Expand All @@ -1703,6 +1732,14 @@ The following parameters are available in the `peadm::convert` plan:
* [`dns_alt_names`](#-peadm--convert--dns_alt_names)
* [`begin_at_step`](#-peadm--convert--begin_at_step)

##### <a name="-peadm--convert--node_group_environment"></a>`node_group_environment`

Data type: `String[1]`

environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production

Default value: `peadm::get_node_group_environment($primary_host)`

##### <a name="-peadm--convert--primary_host"></a>`primary_host`

Data type: `Peadm::SingleTargetSpec`
Expand Down Expand Up @@ -1805,6 +1842,7 @@ The following parameters are available in the `peadm::install` plan:
* [`final_agent_state`](#-peadm--install--final_agent_state)
* [`stagingdir`](#-peadm--install--stagingdir)
* [`uploaddir`](#-peadm--install--uploaddir)
* [`node_group_environment`](#-peadm--install--node_group_environment)
* [`primary_host`](#-peadm--install--primary_host)
* [`replica_host`](#-peadm--install--replica_host)
* [`compiler_hosts`](#-peadm--install--compiler_hosts)
Expand Down Expand Up @@ -1904,6 +1942,14 @@ for offline usage.

Default value: `undef`

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

Data type: `String[1]`

environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production

Default value: `peadm::get_node_group_environment($primary_host)`

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

Data type: `Peadm::SingleTargetSpec`
Expand Down Expand Up @@ -2277,6 +2323,7 @@ The following parameters are available in the `peadm::upgrade` plan:
* [`r10k_known_hosts`](#-peadm--upgrade--r10k_known_hosts)
* [`stagingdir`](#-peadm--upgrade--stagingdir)
* [`uploaddir`](#-peadm--upgrade--uploaddir)
* [`node_group_environment`](#-peadm--upgrade--node_group_environment)
* [`primary_host`](#-peadm--upgrade--primary_host)
* [`replica_host`](#-peadm--upgrade--replica_host)
* [`compiler_hosts`](#-peadm--upgrade--compiler_hosts)
Expand Down Expand Up @@ -2366,6 +2413,14 @@ for offline usage.

Default value: `'/tmp'`

##### <a name="-peadm--upgrade--node_group_environment"></a>`node_group_environment`

Data type: `String[1]`

environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production

Default value: `peadm::get_node_group_environment($primary_host)`

##### <a name="-peadm--upgrade--primary_host"></a>`primary_host`

Data type: `Peadm::SingleTargetSpec`
Expand Down
31 changes: 31 additions & 0 deletions functions/get_node_group_environment.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# @summary check if a custom PE environment is set in pe.conf
#
# @param primary the FQDN for the primary, here we will read the pe.conf from
#
# @return [String] the desired environment for PE specific node groups
#
# @see https://www.puppet.com/docs/pe/latest/upgrade_pe#update_environment
#
function peadm::get_node_group_environment(Peadm::SingleTargetSpec $primary) {
$peconf = peadm::get_pe_conf(get_target($primary))
# if both are set, they need to be set to the same value
# if they are not set, we assume that the user runs their infra in production
$pe_install = $peconf['pe_install::install::classification::pe_node_group_environment']
$puppet_enterprise = $peconf['puppet_enterprise::master::recover_configuration::pe_environment']

# check if both are equal
# This also evaluates to true if both are undef
if $pe_install == $puppet_enterprise {
# check if the option isn't undef
# ToDo: A proper regex for allowed characters in an environment would be nice
# https://github.com/puppetlabs/puppet-docs/issues/1158
if $pe_install =~ String[1] {
return $pe_install
} else {
return 'production'
}
} else {
fail("pe_install::install::classification::pe_node_group_environment and puppet_enterprise::master::recover_configuration::pe_environment need to be set to the same value, not '${pe_install}' and '${puppet_enterprise}'")
}
}
3 changes: 3 additions & 0 deletions manifests/setup/node_manager.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# A load balancer address directing traffic to any of the "B" pool
# compilers. This is used for DR configuration in large and extra large
# architectures.
# @param node_group_environment the environment that will be assigned to all the PE Infra node groups
#
class peadm::setup::node_manager (
String[1] $primary_host,
Expand All @@ -36,6 +37,7 @@
Optional[String[1]] $compiler_pool_address = undef,
Optional[String[1]] $internal_compiler_a_pool_address = $server_a_host,
Optional[String[1]] $internal_compiler_b_pool_address = $server_b_host,
String[1] $node_group_environment = 'production',
) {
# "Not-configured" placeholder string. This will be used in places where we
# cannot set an explicit null, and need to supply some kind of value.
Expand All @@ -46,6 +48,7 @@
# else.
Node_group {
purge_behavior => none,
environment => $node_group_environment,
}

##################################################
Expand Down
20 changes: 13 additions & 7 deletions plans/add_database.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#
# @param node_group_environment environment for the PEADM specific node groups, if not set it will be gathered from pe.conf or production
#
plan peadm::add_database(
Peadm::SingleTargetSpec $targets,
Peadm::SingleTargetSpec $primary_host,
Expand All @@ -9,6 +12,7 @@
'update-db-settings',
'cleanup-db',
'finalize']] $begin_at_step = undef,
String[1] $node_group_environment = peadm::get_node_group_environment($primary_host),
) {
$primary_target = peadm::get_targets($primary_host, 1)
$postgresql_target = peadm::get_targets($targets, 1)
Expand Down Expand Up @@ -91,7 +95,7 @@
run_plan('peadm::subplans::component_install', $postgresql_target,
primary_host => $primary_target,
avail_group_letter => $avail_group_letter,
role => 'puppet/puppetdb-database'
role => 'puppet/puppetdb-database',
)
}

Expand Down Expand Up @@ -128,15 +132,17 @@
$host = pick($a_host, $b_host)
out::verbose("In transitive state, setting classification to ${host}")
run_plan('peadm::util::update_classification', $primary_target,
postgresql_a_host => $host,
postgresql_b_host => $host,
peadm_config => $peadm_config
postgresql_a_host => $host,
postgresql_b_host => $host,
peadm_config => $peadm_config,
node_group_environment => $node_group_environment,
)
} else {
run_plan('peadm::util::update_classification', $primary_target,
postgresql_a_host => $avail_group_letter ? { 'A' => $postgresql_host, default => undef },
postgresql_b_host => $avail_group_letter ? { 'B' => $postgresql_host, default => undef },
peadm_config => $peadm_config
postgresql_a_host => $avail_group_letter ? { 'A' => $postgresql_host, default => undef },
postgresql_b_host => $avail_group_letter ? { 'B' => $postgresql_host, default => undef },
peadm_config => $peadm_config,
node_group_environment => $node_group_environment,
)
}
}
Expand Down
Loading