|
4 | 4 | require 'puppet_litmus/version'
|
5 | 5 |
|
6 | 6 | # helper methods for the litmus rake tasks
|
7 |
| -module PuppetLitmus::RakeHelper |
| 7 | +module PuppetLitmus::RakeHelper # rubocop:disable Metrics/ModuleLength |
8 | 8 | # DEFAULT_CONFIG_DATA should be frozen for our safety, but it needs to work around https://github.com/puppetlabs/bolt/pull/1696
|
9 | 9 | DEFAULT_CONFIG_DATA = { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') } # .freeze # rubocop:disable Style/MutableConstant
|
10 | 10 | SUPPORTED_PROVISIONERS = %w[abs docker docker_exp lxd provision_service vagrant vmpooler].freeze
|
@@ -130,13 +130,18 @@ def tear_down(node_name, inventory_hash)
|
130 | 130 | def install_agent(collection, targets, inventory_hash)
|
131 | 131 | include ::BoltSpec::Run
|
132 | 132 | puppet_version = ENV.fetch('PUPPET_VERSION', nil)
|
| 133 | + forge_token = ENV.fetch('PUPPET_FORGE_TOKEN', nil) |
133 | 134 | params = {}
|
| 135 | + params['password'] = forge_token if forge_token |
134 | 136 | params['collection'] = collection if collection
|
135 | 137 | params['version'] = puppet_version if puppet_version
|
136 | 138 |
|
137 | 139 | raise "puppet_agent was not found in #{DEFAULT_CONFIG_DATA['modulepath']}, please amend the .fixtures.yml file" \
|
138 | 140 | unless File.directory?(File.join(DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent'))
|
139 | 141 |
|
| 142 | + raise 'puppetcore agent installs require a valid PUPPET_FORGE_TOKEN set in the env.' \ |
| 143 | + if collection =~ /\Apuppetcore.*/ && !forge_token |
| 144 | + |
140 | 145 | # using boltspec, when the runner is called it changes the inventory_hash dropping the version field. The clone works around this
|
141 | 146 | bolt_result = run_task('puppet_agent::install', targets, params, config: DEFAULT_CONFIG_DATA, inventory: inventory_hash.clone)
|
142 | 147 | targets.each do |target|
|
|
0 commit comments