Skip to content

Commit

Permalink
Added boolean to trigger legacy support
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-robertson committed Jun 9, 2023
1 parent 474f957 commit c3065b1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.

**Features**

- Added support for older Puppet enterprise versions which still use 'master' instead of 'primary server'.
- Added support for older Puppet enterprise versions which still use 'master' instead of 'primary server'. (must set the support_legacy_pe parameter to true to enable this support)

**Bugfixes**

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ Puppet Nodes
- Windows 2019
- RHEL 8

To support legacy version of Puppet Enterprise (Before changing naming standard to Primary server from master.) You must set the support_legacy_pe parameter to true.

## Development

If you find any issues with this module, please log them in the issues register of the GitHub project. [Issues][1]
Expand Down
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ The following parameters are available in the `update_trusted_facts::update_trus
* [`preserve_existing_facts`](#preserve_existing_facts)
* [`ignore_infra_status_error`](#ignore_infra_status_error)
* [`noop`](#noop)
* [`support_legacy_pe`](#support_legacy_pe)
* [`pp_role`](#pp_role)
* [`pp_uuid`](#pp_uuid)
* [`pp_environment`](#pp_environment)
Expand Down Expand Up @@ -160,6 +161,14 @@ Run the plan in noop. csr_attributes.yaml will still generated, however certific

Default value: ``false``

##### <a name="support_legacy_pe"></a>`support_legacy_pe`

Data type: `Boolean`

Attempt to support legacy PE. Default: false

Default value: ``false``

##### <a name="pp_role"></a>`pp_role`

Data type: `Optional[String]`
Expand Down
15 changes: 11 additions & 4 deletions plans/update_trusted_facts.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# @param preserve_existing_facts Whether to preserve existing facts from the nodes. If set to false all existing facts will be wiped and replaced with those set in the plan. Default: true
# @param ignore_infra_status_error Ignore errors from 'puppet infrastructure status' command. This is used to verify the primary server. Can be used to allow the plan the run when some PE components are unavaliable. Default: false
# @param noop Run the plan in noop. csr_attributes.yaml will still generated, however certificates will not be resigned. Default: false
# @param support_legacy_pe Attempt to support legacy PE. Default: false
# @param pp_role Set the pp_role trusted fact. Default: undef
# @param pp_uuid Set the pp_uuid trusted fact. Default: undef
# @param pp_environment Set the pp_environment trusted fact. Default: undef
Expand Down Expand Up @@ -47,6 +48,7 @@
Boolean $preserve_existing_facts = true,
Boolean $ignore_infra_status_error = false,
Boolean $noop = false,
Boolean $support_legacy_pe = false,
Optional[String] $pp_role = undef,
Optional[String] $pp_uuid = undef,
Optional[String] $pp_environment = undef,
Expand Down Expand Up @@ -115,12 +117,17 @@
if length("${confirm_pe_primary_server_results.ok_set}") <= 2 {
fail_plan("Primary server provided not the primary server for this Puppet Enterprise installation: ${pe_server_target.name} ")
}
if $confirm_pe_primary_server_results[0].message =~ /^Master server/ {
$am_i_primary = 'master'
out::message("Detected ${am_i_primary}, using ${am_i_primary} for agent_cert_regen plan")
# Check if we are attempting to support legacy PE.
if $support_legacy_pe {
if $confirm_pe_primary_server_results[0].message =~ /^Master server/ {
$am_i_primary = 'master'
out::message("Detected ${am_i_primary}, using ${am_i_primary} for agent_cert_regen plan")
} else {
$am_i_primary = 'primary'
out::message("Detected ${am_i_primary}, using ${am_i_primary} for agent_cert_regen plan")
}
} else {
$am_i_primary = 'primary'
out::message("Detected ${am_i_primary}, using ${am_i_primary} for agent_cert_regen plan")
}

# Create hash with trusted facts
Expand Down

0 comments on commit c3065b1

Please sign in to comment.