From c975c2e89df9ccac0d2195a0c446be5006ad7ba5 Mon Sep 17 00:00:00 2001
From: benjamin-robertson
<72488257+benjamin-robertson@users.noreply.github.com>
Date: Mon, 28 Oct 2024 14:16:46 +1100
Subject: [PATCH] Feature uplift puppet8 (#2)
* Update module, bump pdk version
* Fix origin pe primary variable
* added optional to origin_pe_primary_server
* Fix variable line 175
* Update fail_plan pe_primary target.
* Update change log
---
.github/workflows/lint.yaml | 71 +++++++++++++++++++++++++++++
.github/workflows/unit_tests.yml | 71 +++++++++++++++++++++++++++++
.gitignore | 7 +++
.pdkignore | 8 ++++
.rubocop.yml | 7 +++
.vscode/extensions.json | 2 +-
CHANGELOG.md | 8 ++++
Gemfile | 23 ++++++----
README.md | 5 +-
REFERENCE.MD | 50 ++++++++++----------
Rakefile | 78 --------------------------------
metadata.json | 16 ++++---
plans/migrate_node.pp | 35 +++++++++-----
spec/default_facts.yml | 7 +--
spec/spec_helper.rb | 5 +-
test_matrix.json | 12 +++++
16 files changed, 268 insertions(+), 137 deletions(-)
create mode 100644 .github/workflows/lint.yaml
create mode 100644 .github/workflows/unit_tests.yml
create mode 100644 test_matrix.json
diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml
new file mode 100644
index 0000000..c2f88dc
--- /dev/null
+++ b/.github/workflows/lint.yaml
@@ -0,0 +1,71 @@
+---
+name: "Lint testing"
+
+on:
+ pull_request:
+ branches:
+ - "main"
+
+jobs:
+ setup_matrix:
+ name: "Setup Test Matrix"
+ runs-on: ubuntu-22.04
+ outputs:
+ matrix: ${{ steps.get-matrix.outputs.matrix }}
+
+ steps:
+ - name: Checkout Source
+ uses: actions/checkout@v3
+
+ - name: Activate Ruby 3.2
+ uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: "3.2.3"
+ bundler-cache: true
+
+ - name: Print bundle environment
+ run: |
+ echo ::group::bundler environment
+ bundle env
+ echo ::endgroup::
+
+ - name: Setup Integration Test Matrix
+ id: get-matrix
+ run: |
+ echo "matrix=$(cat test_matrix.json | tr -s '\n' ' ')" >> $GITHUB_OUTPUT
+ cat $GITHUB_OUTPUT
+
+ lint:
+ name: "Lint tests (${{matrix.collection.agent_version}})"
+ needs:
+ - setup_matrix
+ if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
+
+ runs-on: ubuntu-22.04
+ strategy:
+ fail-fast: false
+ matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
+
+ env:
+ PUPPET_GEM_VERSION: ${{matrix.collection.gem_version}}
+ FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' # why is this set?
+
+ steps:
+ - name: Checkout Source
+ uses: actions/checkout@v3
+
+ - name: Activate Ruby 3.2
+ uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: "3.2.3"
+ bundler-cache: true
+
+ - name: Print bundle environment
+ run: |
+ echo ::group::bundler environment
+ bundle env
+ echo ::endgroup::
+
+ - name: "Run tests"
+ run: |
+ bundle exec rake validate
\ No newline at end of file
diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml
new file mode 100644
index 0000000..2e3fea2
--- /dev/null
+++ b/.github/workflows/unit_tests.yml
@@ -0,0 +1,71 @@
+---
+name: "Unit Testing"
+
+on:
+ pull_request:
+ branches:
+ - "main"
+
+jobs:
+ setup_matrix:
+ name: "Setup Test Matrix"
+ runs-on: ubuntu-22.04
+ outputs:
+ matrix: ${{ steps.get-matrix.outputs.matrix }}
+
+ steps:
+ - name: Checkout Source
+ uses: actions/checkout@v3
+
+ - name: Activate Ruby 3.2
+ uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: "3.2.3"
+ bundler-cache: true
+
+ - name: Print bundle environment
+ run: |
+ echo ::group::bundler environment
+ bundle env
+ echo ::endgroup::
+
+ - name: Setup Integration Test Matrix
+ id: get-matrix
+ run: |
+ echo "matrix=$(cat test_matrix.json | tr -s '\n' ' ')" >> $GITHUB_OUTPUT
+ cat $GITHUB_OUTPUT
+
+ Unit:
+ name: "Unit tests (${{matrix.collection.agent_version}})"
+ needs:
+ - setup_matrix
+ if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
+
+ runs-on: ubuntu-22.04
+ strategy:
+ fail-fast: false
+ matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
+
+ env:
+ PUPPET_GEM_VERSION: ${{matrix.collection.gem_version}}
+ FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' # why is this set?
+
+ steps:
+ - name: Checkout Source
+ uses: actions/checkout@v3
+
+ - name: Activate Ruby 3.2
+ uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: "3.2.3"
+ bundler-cache: true
+
+ - name: Print bundle environment
+ run: |
+ echo ::group::bundler environment
+ bundle env
+ echo ::endgroup::
+
+ - name: "Run tests"
+ run: |
+ bundle exec rake parallel_spec
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 3f15512..2803e56 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,7 @@
/spec/fixtures/modules/*
/tmp/
/vendor/
+/.vendor/
/convert_report.txt
/update_report.txt
.DS_Store
@@ -26,3 +27,9 @@
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
+.resource_types
+.modules
+.task_cache.json
+.plan_cache.json
+.rerun.json
+bolt-debug.log
diff --git a/.pdkignore b/.pdkignore
index 584438f..84684be 100644
--- a/.pdkignore
+++ b/.pdkignore
@@ -19,6 +19,7 @@
/spec/fixtures/modules/*
/tmp/
/vendor/
+/.vendor/
/convert_report.txt
/update_report.txt
.DS_Store
@@ -26,9 +27,16 @@
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
+.resource_types
+.modules
+.task_cache.json
+.plan_cache.json
+.rerun.json
+bolt-debug.log
/.fixtures.yml
/Gemfile
/.gitattributes
+/.github/
/.gitignore
/.pdkignore
/.puppet-lint.rc
diff --git a/.rubocop.yml b/.rubocop.yml
index 3766a93..5b93e03 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -3,6 +3,7 @@ require:
- rubocop-performance
- rubocop-rspec
AllCops:
+ NewCops: enable
DisplayCopNames: true
TargetRubyVersion: '2.6'
Include:
@@ -527,6 +528,8 @@ Lint/DuplicateBranch:
Enabled: false
Lint/DuplicateMagicComment:
Enabled: false
+Lint/DuplicateMatchPattern:
+ Enabled: false
Lint/DuplicateRegexpCharacterClassElement:
Enabled: false
Lint/EmptyBlock:
@@ -643,6 +646,8 @@ Style/ComparableClamp:
Enabled: false
Style/ConcatArrayLiterals:
Enabled: false
+Style/DataInheritance:
+ Enabled: false
Style/DirEmpty:
Enabled: false
Style/DocumentDynamicEvalDefinition:
@@ -711,6 +716,8 @@ Style/RedundantHeredocDelimiterQuotes:
Enabled: false
Style/RedundantInitialize:
Enabled: false
+Style/RedundantLineContinuation:
+ Enabled: false
Style/RedundantSelfAssignmentBranch:
Enabled: false
Style/RedundantStringEscape:
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 2f1e4f7..6da8d47 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -1,6 +1,6 @@
{
"recommendations": [
"puppet.puppet-vscode",
- "rebornix.Ruby"
+ "Shopify.ruby-lsp"
]
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b955f0c..2ae0e23 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,14 @@
All notable changes to this project will be documented in this file.
+## Release 1.0.0
+
+**Features**
+
+- Added support Puppet 8.
+- Migrate_node plan will now automatically locate the origin primary server.
+- Added lint test to github actions.
+
## Release 0.1.0
**Features**
diff --git a/Gemfile b/Gemfile
index add1873..8e9f845 100644
--- a/Gemfile
+++ b/Gemfile
@@ -20,25 +20,30 @@ group :development do
gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
+ gem "deep_merge", '~> 1.2.2', require: false
gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
- gem "facterdb", '~> 1.18', require: false
- gem "metadata-json-lint", '~> 3.0', require: false
- gem "puppetlabs_spec_helper", '~> 6.0', require: false
- gem "rspec-puppet-facts", '~> 2.0', require: false
- gem "codecov", '~> 0.2', require: false
+ gem "facterdb", '~> 2.1', require: false
+ gem "metadata-json-lint", '~> 4.0', require: false
+ gem "rspec-puppet-facts", '~> 4.0', require: false
gem "dependency_checker", '~> 1.0.0', require: false
gem "parallel_tests", '= 3.12.1', require: false
gem "pry", '~> 0.10', require: false
- gem "simplecov-console", '~> 0.5', require: false
+ gem "simplecov-console", '~> 0.9', require: false
gem "puppet-debugger", '~> 1.0', require: false
- gem "rubocop", '= 1.48.1', require: false
+ gem "rubocop", '~> 1.50.0', require: false
gem "rubocop-performance", '= 1.16.0', require: false
gem "rubocop-rspec", '= 2.19.0', require: false
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
+ gem "rexml", '>= 3.0.0', '< 3.2.7', require: false
+end
+group :development, :release_prep do
+ gem "puppet-strings", '~> 4.0', require: false
+ gem "puppetlabs_spec_helper", '~> 7.0', require: false
end
group :system_tests do
- gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw]
- gem "serverspec", '~> 2.41', require: false
+ gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw]
+ gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw]
+ gem "serverspec", '~> 2.41', require: false
end
puppet_version = ENV['PUPPET_GEM_VERSION']
diff --git a/README.md b/README.md
index 8d4d842..baaf28d 100644
--- a/README.md
+++ b/README.md
@@ -42,11 +42,11 @@ Include the module within your Puppetfile.
Run the plan **migrate_nodes::migrate_node** from the Puppet Enterprise console.
**Required parameters**
-- origin_pe_primary_server (String - Puppet Primary server the node is being migrated from. Must match Primary server FQDN(Certname))
- target_pe_address (Array/Sting - either compiler address or FQDN of Primary server. Use array to specify multiple compilers.)
**Optional parameters**
- targets (TargetSpec - [see here](https://www.puppet.com/docs/bolt/latest/bolt_types_reference.html#targetspec))
+- origin_pe_primary_server (String - Puppet Primary server the node is being migrated from. Must match Primary server FQDN(Certname))
- fact_name (String)
- fact_value (String)
- ignore_infra_status_error (Boolean - Ignore errors from puppet infrastructure status command. May allow the plan to operate if some Puppet infrastructure components are failing)
@@ -64,10 +64,13 @@ Verified with the following OS\Primary combinations.
Puppet Enterprise
* 2021.7.6
+* 2021.7.9
+* 2023.8.0
Puppet Nodes
* Windows 2019
+* Windows 2022
* RHEL 8
* RHEL 9
diff --git a/REFERENCE.MD b/REFERENCE.MD
index 7d7ceb5..f63ee9e 100644
--- a/REFERENCE.MD
+++ b/REFERENCE.MD
@@ -14,7 +14,7 @@
### Plans
-* [`migrate_nodes::migrate_node`](#migrate_nodesmigrate_node): PE plan to migrate nodes to another PE server
+* [`migrate_nodes::migrate_node`](#migrate_nodes--migrate_node): PE plan to migrate nodes to another PE server
## Tasks
@@ -100,7 +100,7 @@ Enable long path support on Windows 2016 or later
## Plans
-### `migrate_nodes::migrate_node`
+### `migrate_nodes::migrate_node`
lint:ignore:140chars
@@ -108,74 +108,76 @@ lint:ignore:140chars
The following parameters are available in the `migrate_nodes::migrate_node` plan:
-* [`origin_pe_primary_server`](#origin_pe_primary_server)
-* [`target_pe_address`](#target_pe_address)
-* [`targets`](#targets)
-* [`fact_name`](#fact_name)
-* [`fact_value`](#fact_value)
-* [`noop`](#noop)
-* [`bypass_connectivity_check`](#bypass_connectivity_check)
-* [`ignore_infra_status_error`](#ignore_infra_status_error)
+* [`origin_pe_primary_server`](#-migrate_nodes--migrate_node--origin_pe_primary_server)
+* [`target_pe_address`](#-migrate_nodes--migrate_node--target_pe_address)
+* [`targets`](#-migrate_nodes--migrate_node--targets)
+* [`fact_name`](#-migrate_nodes--migrate_node--fact_name)
+* [`fact_value`](#-migrate_nodes--migrate_node--fact_value)
+* [`noop`](#-migrate_nodes--migrate_node--noop)
+* [`bypass_connectivity_check`](#-migrate_nodes--migrate_node--bypass_connectivity_check)
+* [`ignore_infra_status_error`](#-migrate_nodes--migrate_node--ignore_infra_status_error)
-##### `origin_pe_primary_server`
+##### `origin_pe_primary_server`
Data type: `String`
Puppet Primary server the node is being migrated from. Must match Primary server FQDN(Certname). Use to purge migrated nodes.
-##### `target_pe_address`
+Default value: `undef`
+
+##### `target_pe_address`
Data type: `Variant[String,Array]`
Target Puppet server, either compiler address or FQDN of Primary server. Use array to specific multiple compilers.
-##### `targets`
+##### `targets`
Data type: `Optional[TargetSpec]`
The targets to run on (note this must match the certnames used by Puppet / shown in PE console).
NOTE: you may ONLY specify target or fact_value. Specifying both will cause the plan to fail.
-Default value: ``undef``
+Default value: `undef`
-##### `fact_name`
+##### `fact_name`
Data type: `Optional[String]`
Fact name to match nodes by.
-Default value: ``undef``
+Default value: `undef`
-##### `fact_value`
+##### `fact_value`
Data type: `Optional[String]`
Fact value the fact must match.
NOTE: you may ONLY specify target or fact_value. Specifying both will cause the plan to fail.
-Default value: ``undef``
+Default value: `undef`
-##### `noop`
+##### `noop`
Data type: `Boolean`
Run the plan in noop mode. Make no changes.
-Default value: ``false``
+Default value: `false`
-##### `bypass_connectivity_check`
+##### `bypass_connectivity_check`
Data type: `Boolean`
Do not check for connectivity to target PE server.
-Default value: ``false``
+Default value: `false`
-##### `ignore_infra_status_error`
+##### `ignore_infra_status_error`
Data type: `Boolean`
-Default value: ``false``
+Default value: `false`
diff --git a/Rakefile b/Rakefile
index 74415a9..caa4e30 100644
--- a/Rakefile
+++ b/Rakefile
@@ -4,85 +4,7 @@ require 'bundler'
require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus'
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-syntax/tasks/puppet-syntax'
-require 'github_changelog_generator/task' if Gem.loaded_specs.key? 'github_changelog_generator'
require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings'
-def changelog_user
- return unless Rake.application.top_level_tasks.include? "changelog"
- returnVal = nil || JSON.load(File.read('metadata.json'))['author']
- raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
- puts "GitHubChangelogGenerator user:#{returnVal}"
- returnVal
-end
-
-def changelog_project
- return unless Rake.application.top_level_tasks.include? "changelog"
-
- returnVal = nil
- returnVal ||= begin
- metadata_source = JSON.load(File.read('metadata.json'))['source']
- metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z})
-
- metadata_source_match && metadata_source_match[1]
- end
-
- raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil?
-
- puts "GitHubChangelogGenerator project:#{returnVal}"
- returnVal
-end
-
-def changelog_future_release
- return unless Rake.application.top_level_tasks.include? "changelog"
- returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version']
- raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
- puts "GitHubChangelogGenerator future_release:#{returnVal}"
- returnVal
-end
-
PuppetLint.configuration.send('disable_relative')
-
-if Gem.loaded_specs.key? 'github_changelog_generator'
- GitHubChangelogGenerator::RakeTask.new :changelog do |config|
- raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
- config.user = "#{changelog_user}"
- config.project = "#{changelog_project}"
- config.future_release = "#{changelog_future_release}"
- config.exclude_labels = ['maintenance']
- config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
- config.add_pr_wo_labels = true
- config.issues = false
- config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB"
- config.configure_sections = {
- "Changed" => {
- "prefix" => "### Changed",
- "labels" => ["backwards-incompatible"],
- },
- "Added" => {
- "prefix" => "### Added",
- "labels" => ["enhancement", "feature"],
- },
- "Fixed" => {
- "prefix" => "### Fixed",
- "labels" => ["bug", "documentation", "bugfix"],
- },
- }
- end
-else
- desc 'Generate a Changelog from GitHub'
- task :changelog do
- raise < 1.15'
- condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')"
-EOM
- end
-end
-
diff --git a/metadata.json b/metadata.json
index e05ec57..d0dbcab 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,6 +1,6 @@
{
"name": "benjaminrobertson-migrate_nodes",
- "version": "0.1.0",
+ "version": "1.0.0",
"author": "benjaminrobertson",
"summary": "PE plan to migrate nodes to another PE primary server",
"license": "Apache-2.0",
@@ -55,7 +55,8 @@
"operatingsystemrelease": [
"18.04",
"20.04",
- "22.04"
+ "22.04",
+ "24.04"
]
},
{
@@ -64,17 +65,18 @@
"2016",
"2019",
"2022",
- "10"
+ "10",
+ "11"
]
}
],
"requirements": [
{
"name": "puppet",
- "version_requirement": ">= 6.21.0 < 8.0.0"
+ "version_requirement": ">= 7.0.0 < 9.0.0"
}
],
- "pdk-version": "3.0.0",
- "template-url": "pdk-default#3.0.0",
- "template-ref": "tags/3.0.0-0-g056e50d"
+ "pdk-version": "3.3.0",
+ "template-url": "pdk-default#3.3.0",
+ "template-ref": "tags/3.3.0-0-g5d17ec1"
}
diff --git a/plans/migrate_node.pp b/plans/migrate_node.pp
index 203fe2e..70ee9db 100644
--- a/plans/migrate_node.pp
+++ b/plans/migrate_node.pp
@@ -1,20 +1,20 @@
-# @summary PE plan to migrate nodes to another PE server
+# @summary PE plan to migrate nodes to another PE server.
#
# lint:ignore:140chars
#
-# @param origin_pe_primary_server Puppet Primary server the node is being migrated from. Must match Primary server FQDN(Certname). Use to purge migrated nodes.
+# @param origin_pe_primary_server Puppet Primary server the node is being migrated from. Must match Primary server FQDN(Certname). Use to purge migrated nodes.
# @param target_pe_address Target Puppet server, either compiler address or FQDN of Primary server. Use array to specific multiple compilers.
-# @param targets The targets to run on (note this must match the certnames used by Puppet / shown in PE console).
+# @param targets The targets to run on (note this must match the certnames used by Puppet / shown in PE console).
# NOTE: you may ONLY specify target or fact_value. Specifying both will cause the plan to fail.
# @param fact_name Fact name to match nodes by.
-# @param fact_value Fact value the fact must match.
+# @param fact_value Fact value the fact must match.
# NOTE: you may ONLY specify target or fact_value. Specifying both will cause the plan to fail.
-# @param noop Run the plan in noop mode. Make no changes.
+# @param noop Run the plan in noop mode. Make no changes.
# @param bypass_connectivity_check Do not check for connectivity to target PE server.
#
plan migrate_nodes::migrate_node (
- String $origin_pe_primary_server,
Variant[String,Array] $target_pe_address,
+ Optional[String] $origin_pe_primary_server = undef,
Optional[TargetSpec] $targets = undef,
Optional[String] $fact_name = undef,
Optional[String] $fact_value = undef,
@@ -42,9 +42,8 @@
unless $full_list.empty {
# Check connection to hosts. run_plan does not exit cleanly if there is a host which doesnt exist or isnt connected, We use this task
- # to check if hosts are valid and have a valid connection to PE. This can be switched to a faster running task to speed up plan
- # execution as we do not actually use the results from this task.
- $factresults = run_task(facts, $full_list, _catch_errors => true)
+ # to check if hosts are valid and have a valid connection to PE.
+ $factresults = run_task(enterprise_tasks::test_connect, $full_list, _catch_errors => true)
$full_list_failed = $factresults.error_set.names
$full_list_success = $factresults.ok_set.names
@@ -65,7 +64,19 @@
out::message("Supported targets are ${remove_any_pe_targets}")
- $origin_pe_primary_target = get_target($origin_pe_primary_server)
+ # Get primary server
+ if $origin_pe_primary_server == undef {
+ $pe_status_results = puppetdb_query('inventory[certname] { facts.pe_status_check_role = "primary" }')
+ if $pe_status_results.length != 1 {
+ fail("Could not identify the primary server. Confirm pe_status_check_role fact is working correctly. Alternatively the priamry server can be set via the pe_primary_server parameter. Results: ${pe_role_results}")
+ } else {
+ # We found a single primary server :)
+ $pe_target_certname = $pe_status_results.map | Hash $node | { $node['certname'] }
+ $origin_pe_primary_target = get_target($pe_target_certname)
+ }
+ } else {
+ $origin_pe_primary_target = get_target($origin_pe_primary_server)
+ }
$windows_hosts = get_targets($remove_any_pe_targets).filter | $target | {
$target.facts['os']['name'] == 'windows'
@@ -83,7 +94,7 @@
'_catch_errors' => true )
$ok_set_length = length("${confirm_pe_primary_server_results.ok_set}")
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} ")
+ fail_plan("Primary server provided not the primary server for this Puppet Enterprise installation: ${origin_pe_primary_target.name} ")
}
# Check if target pe address is an array. If so we test the first address only.
@@ -161,7 +172,7 @@
$failed_clear_ssl_cert = $clear_ssl_cert_results.error_set.names
# Purge nodes on PE master
- $origin_pe_target = get_targets($origin_pe_primary_server)
+ $origin_pe_target = get_targets($origin_pe_primary_target)
$node_to_purge = $successful_clear_ssl_cert.reduce | String $orig, String $node | { "${orig} ${node} " }
out::message("Nodes to purge are: ${node_to_purge}")
if $node_to_purge != undef {
diff --git a/spec/default_facts.yml b/spec/default_facts.yml
index f777abf..3346c39 100644
--- a/spec/default_facts.yml
+++ b/spec/default_facts.yml
@@ -2,7 +2,8 @@
#
# Facts specified here will override the values provided by rspec-puppet-facts.
---
-ipaddress: "172.16.254.254"
-ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA"
+networking:
+ ip: "172.16.254.254"
+ ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA"
+ mac: "AA:AA:AA:AA:AA:AA"
is_pe: false
-macaddress: "AA:AA:AA:AA:AA:AA"
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 6820ceb..ae7c1f6 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -25,7 +25,8 @@
next unless File.exist?(f) && File.readable?(f) && File.size?(f)
begin
- default_facts.merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true))
+ require 'deep_merge'
+ default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true))
rescue StandardError => e
RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
end
@@ -33,7 +34,7 @@
# read default_facts and merge them over what is provided by facterdb
default_facts.each do |fact, value|
- add_custom_fact fact, value
+ add_custom_fact fact, value, merge_facts: true
end
RSpec.configure do |c|
diff --git a/test_matrix.json b/test_matrix.json
new file mode 100644
index 0000000..3df0627
--- /dev/null
+++ b/test_matrix.json
@@ -0,0 +1,12 @@
+{
+ "collection": [
+ {
+ "agent_version": "puppet7",
+ "gem_version": "~> 7.31"
+ },
+ {
+ "agent_version": "puppet8",
+ "gem_version": "~> 8.7"
+ }
+ ]
+}