From acd7b136726a555539137c8f7e3ffa5ccc969cb9 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 24 Oct 2023 11:17:08 +0200 Subject: [PATCH] Add env var for puppet package name This is useful for two setups: * someone has their own package and wants to test with that * someone has beaker instances with the puppet-agent preinstalled --- README.md | 1 + lib/voxpupuli/acceptance/spec_helper_acceptance.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0906b0b..89ce115 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Other common environment variables: * `BEAKER_PROVISION` can be set to `no` to reuse a box. Note that the box must exist already. See `BEAKER_DESTROY` * `BEAKER_SETFILE` is used to point to a setfile containing definitions. To avoid storing large YAML files in all repositories, [beaker-hostgenerator](https://github.com/voxpupuli/beaker-hostgenerator) is used to generate them on the fly when the file is not present. * `BEAKER_PUPPET_COLLECTION` defines the puppet collection that will be configured, defaults to `puppet`. When set to `none`, no repository will be configured and distro package naming is assumed. When set to `preinstalled`, it assumes the OS is already set up with a collection but it still ensures `puppet-agent` is installed. +* `BEAKER_PUPPET_PACKAGE_NAME` optional env var to set the puppet agent package name. If not set, the package name will be searched in [puppet_metadata](https://github.com/voxpupuli/puppet_metadata#puppet_metadata). Since it's still plain [RSpec](https://rspec.info/), it is also possible to call an individual test file: diff --git a/lib/voxpupuli/acceptance/spec_helper_acceptance.rb b/lib/voxpupuli/acceptance/spec_helper_acceptance.rb index 06b6c82..f1e78e0 100644 --- a/lib/voxpupuli/acceptance/spec_helper_acceptance.rb +++ b/lib/voxpupuli/acceptance/spec_helper_acceptance.rb @@ -18,7 +18,7 @@ def configure_beaker(modules: :metadata, &block) unless %w[none preinstalled].include?(collection) BeakerPuppetHelpers::InstallUtils.install_puppet_release_repo_on(host, collection) end - package_name = BeakerPuppetHelpers::InstallUtils.puppet_package_name(host, prefer_aio: collection != 'none') + package_name = ENV.fetch('BEAKER_PUPPET_PACKAGE_NAME', BeakerPuppetHelpers::InstallUtils.puppet_package_name(host, prefer_aio: collection != 'none')) host.install_package(package_name) # by default, puppet-agent creates /etc/profile.d/puppet-agent.sh which adds /opt/puppetlabs/bin to PATH