Skip to content

Commit 0080405

Browse files
author
jordanbreen28
committed
feat: add puppetcore agent installation support
This commit adds support for installing puppetcore agents through the `litmus:install_agent` rake task. To do this, you must supply a puppetcore collection to the rake task, and have exported your PUPPET_FORGE_TOKEN in the ENV.
1 parent d9864f2 commit 0080405

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ Install Litmus as a gem by running `gem install puppet_litmus`.
2929

3030
- Note if you choose to override the `litmus_inventory.yaml` location, please ensure that the directory structure you define exists.
3131

32-
## Install a specific puppet agent version
32+
## Agent installs
33+
34+
### Install a specific puppet agent version
3335

3436
To install a specific version of the puppet agent, you can export the `PUPPET_VERSION` env var, like below:
3537
```
@@ -38,6 +40,13 @@ export PUPPET_VERSION=8.8.1
3840

3941
When set, the `litmus:install_agent` rake task will install the specified version. The default is `latest`.
4042

43+
## Installing puppetcore agents
44+
45+
To install a puppetcore puppet agent through the `litmus:install_agent` rake task, you need to export your Forge API key as an env var, like below:
46+
```
47+
export PUPPET_FORGE_TOKEN='<your_forge_api_key>'
48+
```
49+
4150
## matrix_from_metadata_v3
4251

4352
matrix_from_metadata_v3 tool generates a github action matrix from the supported operating systems listed in the module's metadata.json.

lib/puppet_litmus/rake_helper.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require 'puppet_litmus/version'
55

66
# helper methods for the litmus rake tasks
7-
module PuppetLitmus::RakeHelper
7+
module PuppetLitmus::RakeHelper # rubocop:disable Metrics/ModuleLength
88
# DEFAULT_CONFIG_DATA should be frozen for our safety, but it needs to work around https://github.com/puppetlabs/bolt/pull/1696
99
DEFAULT_CONFIG_DATA = { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') } # .freeze # rubocop:disable Style/MutableConstant
1010
SUPPORTED_PROVISIONERS = %w[abs docker docker_exp lxd provision_service vagrant vmpooler].freeze
@@ -130,13 +130,18 @@ def tear_down(node_name, inventory_hash)
130130
def install_agent(collection, targets, inventory_hash)
131131
include ::BoltSpec::Run
132132
puppet_version = ENV.fetch('PUPPET_VERSION', nil)
133+
forge_token = ENV.fetch('PUPPET_FORGE_TOKEN', nil)
133134
params = {}
135+
params['password'] = forge_token if forge_token
134136
params['collection'] = collection if collection
135137
params['version'] = puppet_version if puppet_version
136138

137139
raise "puppet_agent was not found in #{DEFAULT_CONFIG_DATA['modulepath']}, please amend the .fixtures.yml file" \
138140
unless File.directory?(File.join(DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent'))
139141

142+
raise 'puppetcore agent installs require a valid PUPPET_FORGE_TOKEN set in the env.' \
143+
if collection =~ /\Apuppetcore.*/ && !forge_token
144+
140145
# using boltspec, when the runner is called it changes the inventory_hash dropping the version field. The clone works around this
141146
bolt_result = run_task('puppet_agent::install', targets, params, config: DEFAULT_CONFIG_DATA, inventory: inventory_hash.clone)
142147
targets.each do |target|

0 commit comments

Comments
 (0)