cem_acpt 0.10.5 → 0.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc299de4494abd1da48700f76b43223cb05aae1cb8c26235757e31e909bd6c2f
4
- data.tar.gz: 32948e52808bd436695d69cf0c0bf2c5ccd31ada90ed401341c9c73e00653c6b
3
+ metadata.gz: f55a13b7ba6760d6d6b36ca313f7cddf637ae86b76ab48613de5938cb16f4d0e
4
+ data.tar.gz: 63838f21061f45475f880a7e6966664b0a043938b2f74548f79afebaf9801eca
5
5
  SHA512:
6
- metadata.gz: 2a916fec7be6263243deeb60eac717ac097e0c477359b8abe71c374ef68880ab1608ff48859339074d97e8ae4592b9da491b5ff76b61f842a60712a9efcd1f75
7
- data.tar.gz: e4e3b465b224f8f1431867ae19b6bee5161a91248168fd8e0c8c221c6ffa2c6caf3e2bf45a2a54e139e02069e45bc1dc7beacbddbe7fa11c15bf269811c98c54
6
+ metadata.gz: 3679136cf4a7f393254856444f9c9bc922f608c86068f984620f8bcae3b5636bbcd22ce9fb2f72c80ba1e00e44df22ff0d445fb729f7d0f598ad3ce0dbed67e6
7
+ data.tar.gz: a46c919e4d0418377d9d06e9fe4b5c253794d26ae8e5e5f43f9d8e6f72ac6da453fc326e9a86d918daacf35ef554ab19d56565aad4da76055de98b3922fcc536
data/Gemfile.lock CHANGED
@@ -1,144 +1,184 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cem_acpt (0.10.5)
4
+ cem_acpt (0.10.7)
5
5
  async-http (>= 0.60, < 0.70)
6
6
  bcrypt_pbkdf (>= 1.0, < 2.0)
7
7
  deep_merge (>= 1.2, < 2.0)
8
- ed25519 (>= 1.2, < 2.0)
8
+ ed25519 (>= 1.0, < 2.0)
9
9
  puppet-modulebuilder (>= 0.0.1)
10
10
  winrm (>= 2.3, < 3.0)
11
11
 
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- ast (2.4.2)
16
- async (2.5.0)
17
- console (~> 1.10)
18
- io-event (~> 1.1)
19
- timers (~> 4.1)
20
- async-http (0.60.1)
15
+ ast (2.4.3)
16
+ async (2.23.1)
17
+ console (~> 1.29)
18
+ fiber-annotation
19
+ io-event (~> 1.9)
20
+ metrics (~> 0.12)
21
+ traces (~> 0.15)
22
+ async-http (0.69.0)
23
+ async (>= 2.10.2)
24
+ async-pool (~> 0.7)
25
+ io-endpoint (~> 0.11)
26
+ io-stream (~> 0.4)
27
+ protocol-http (~> 0.26)
28
+ protocol-http1 (~> 0.19)
29
+ protocol-http2 (~> 0.18)
30
+ traces (>= 0.10)
31
+ async-pool (0.10.3)
21
32
  async (>= 1.25)
22
- async-io (>= 1.28)
23
- async-pool (>= 0.2)
24
- protocol-http (~> 0.24.0)
25
- protocol-http1 (~> 0.15.0)
26
- protocol-http2 (~> 0.15.0)
27
- traces (>= 0.8.0)
28
- async-io (1.34.3)
29
- async
30
- async-pool (0.4.0)
31
- async (>= 1.25)
32
- bcrypt_pbkdf (1.1.0)
33
- builder (3.2.4)
33
+ base64 (0.2.0)
34
+ bcrypt_pbkdf (1.1.1)
35
+ bcrypt_pbkdf (1.1.1-arm64-darwin)
36
+ bcrypt_pbkdf (1.1.1-x86_64-darwin)
37
+ bigdecimal (3.1.9)
38
+ builder (3.3.0)
34
39
  coderay (1.1.3)
35
- console (1.16.2)
36
- fiber-local
40
+ console (1.30.2)
41
+ fiber-annotation
42
+ fiber-local (~> 1.1)
43
+ json
37
44
  deep_merge (1.2.2)
38
- diff-lcs (1.5.0)
39
- docile (1.4.0)
45
+ diff-lcs (1.6.1)
46
+ docile (1.4.1)
40
47
  ed25519 (1.3.0)
41
- erubi (1.12.0)
42
- ffi (1.15.5)
43
- fiber-local (1.0.0)
48
+ erubi (1.13.1)
49
+ ffi (1.17.1)
50
+ ffi (1.17.1-aarch64-linux-gnu)
51
+ ffi (1.17.1-aarch64-linux-musl)
52
+ ffi (1.17.1-arm-linux-gnu)
53
+ ffi (1.17.1-arm-linux-musl)
54
+ ffi (1.17.1-arm64-darwin)
55
+ ffi (1.17.1-x86-linux-gnu)
56
+ ffi (1.17.1-x86-linux-musl)
57
+ ffi (1.17.1-x86_64-darwin)
58
+ ffi (1.17.1-x86_64-linux-gnu)
59
+ ffi (1.17.1-x86_64-linux-musl)
60
+ fiber-annotation (0.2.0)
61
+ fiber-local (1.1.0)
62
+ fiber-storage
63
+ fiber-storage (1.0.0)
44
64
  gssapi (1.3.1)
45
65
  ffi (>= 1.0.1)
46
66
  gyoku (1.4.0)
47
67
  builder (>= 2.1.2)
48
68
  rexml (~> 3.0)
49
- httpclient (2.8.3)
50
- io-event (1.1.7)
51
- json (2.6.3)
69
+ httpclient (2.9.0)
70
+ mutex_m
71
+ io-endpoint (0.15.2)
72
+ io-event (1.10.0)
73
+ io-stream (0.6.1)
74
+ json (2.10.2)
75
+ language_server-protocol (3.17.0.4)
76
+ lint_roller (1.1.0)
52
77
  little-plugger (1.1.4)
53
- logging (2.3.1)
78
+ logging (2.4.0)
54
79
  little-plugger (~> 1.1)
55
80
  multi_json (~> 1.14)
56
- method_source (1.0.0)
57
- minitar (0.9)
81
+ method_source (1.1.0)
82
+ metrics (0.12.2)
83
+ minitar (0.12.1)
58
84
  multi_json (1.15.0)
59
- nori (2.6.0)
60
- parallel (1.22.1)
61
- parser (3.2.1.1)
85
+ mutex_m (0.3.0)
86
+ nori (2.7.1)
87
+ bigdecimal
88
+ parallel (1.26.3)
89
+ parser (3.3.7.4)
62
90
  ast (~> 2.4.1)
63
- pathspec (1.1.3)
64
- protocol-hpack (1.4.2)
65
- protocol-http (0.24.1)
66
- protocol-http1 (0.15.0)
91
+ racc
92
+ pathspec (2.1.0)
93
+ prism (1.4.0)
94
+ protocol-hpack (1.5.1)
95
+ protocol-http (0.49.0)
96
+ protocol-http1 (0.34.0)
67
97
  protocol-http (~> 0.22)
68
- protocol-http2 (0.15.1)
98
+ protocol-http2 (0.22.1)
69
99
  protocol-hpack (~> 1.4)
70
- protocol-http (~> 0.18)
71
- pry (0.14.2)
100
+ protocol-http (~> 0.47)
101
+ pry (0.15.2)
72
102
  coderay (~> 1.1)
73
103
  method_source (~> 1.0)
74
- puppet-modulebuilder (0.3.0)
104
+ puppet-modulebuilder (2.0.2)
75
105
  minitar (~> 0.9)
76
- pathspec (>= 0.2.1, < 2.0.0)
106
+ pathspec (>= 0.2.1, < 3.0.0)
107
+ racc (1.8.1)
77
108
  rainbow (3.1.1)
78
- rake (13.0.6)
79
- regexp_parser (2.7.0)
80
- rexml (3.2.5)
81
- rspec (3.12.0)
82
- rspec-core (~> 3.12.0)
83
- rspec-expectations (~> 3.12.0)
84
- rspec-mocks (~> 3.12.0)
85
- rspec-core (3.12.1)
86
- rspec-support (~> 3.12.0)
87
- rspec-expectations (3.12.2)
109
+ rake (13.2.1)
110
+ regexp_parser (2.10.0)
111
+ rexml (3.4.1)
112
+ rspec (3.13.0)
113
+ rspec-core (~> 3.13.0)
114
+ rspec-expectations (~> 3.13.0)
115
+ rspec-mocks (~> 3.13.0)
116
+ rspec-core (3.13.3)
117
+ rspec-support (~> 3.13.0)
118
+ rspec-expectations (3.13.3)
88
119
  diff-lcs (>= 1.2.0, < 2.0)
89
- rspec-support (~> 3.12.0)
90
- rspec-mocks (3.12.4)
120
+ rspec-support (~> 3.13.0)
121
+ rspec-mocks (3.13.2)
91
122
  diff-lcs (>= 1.2.0, < 2.0)
92
- rspec-support (~> 3.12.0)
93
- rspec-support (3.12.0)
94
- rubocop (1.48.1)
123
+ rspec-support (~> 3.13.0)
124
+ rspec-support (3.13.2)
125
+ rubocop (1.75.1)
95
126
  json (~> 2.3)
127
+ language_server-protocol (~> 3.17.0.2)
128
+ lint_roller (~> 1.1.0)
96
129
  parallel (~> 1.10)
97
- parser (>= 3.2.0.0)
130
+ parser (>= 3.3.0.2)
98
131
  rainbow (>= 2.2.2, < 4.0)
99
- regexp_parser (>= 1.8, < 3.0)
100
- rexml (>= 3.2.5, < 4.0)
101
- rubocop-ast (>= 1.26.0, < 2.0)
132
+ regexp_parser (>= 2.9.3, < 3.0)
133
+ rubocop-ast (>= 1.43.0, < 2.0)
102
134
  ruby-progressbar (~> 1.7)
103
- unicode-display_width (>= 2.4.0, < 3.0)
104
- rubocop-ast (1.28.0)
105
- parser (>= 3.2.1.0)
106
- rubocop-capybara (2.18.0)
107
- rubocop (~> 1.41)
108
- rubocop-factory_bot (2.23.1)
109
- rubocop (~> 1.33)
110
- rubocop-performance (1.19.0)
111
- rubocop (>= 1.7.0, < 2.0)
112
- rubocop-ast (>= 0.4.0)
113
- rubocop-rspec (2.23.2)
114
- rubocop (~> 1.33)
115
- rubocop-capybara (~> 2.17)
116
- rubocop-factory_bot (~> 2.22)
135
+ unicode-display_width (>= 2.4.0, < 4.0)
136
+ rubocop-ast (1.43.0)
137
+ parser (>= 3.3.7.2)
138
+ prism (~> 1.4)
139
+ rubocop-performance (1.24.0)
140
+ lint_roller (~> 1.1)
141
+ rubocop (>= 1.72.1, < 2.0)
142
+ rubocop-ast (>= 1.38.0, < 2.0)
143
+ rubocop-rspec (3.5.0)
144
+ lint_roller (~> 1.1)
145
+ rubocop (~> 1.72, >= 1.72.1)
117
146
  ruby-progressbar (1.13.0)
118
- rubyntlm (0.6.3)
119
- simplecov (0.21.2)
147
+ rubyntlm (0.6.5)
148
+ base64
149
+ simplecov (0.22.0)
120
150
  docile (~> 1.1)
121
151
  simplecov-html (~> 0.11)
122
152
  simplecov_json_formatter (~> 0.1)
123
- simplecov-html (0.12.3)
153
+ simplecov-html (0.13.1)
124
154
  simplecov_json_formatter (0.1.4)
125
- timers (4.3.5)
126
- traces (0.9.1)
127
- unicode-display_width (2.4.2)
128
- winrm (2.3.6)
155
+ traces (0.15.2)
156
+ unicode-display_width (3.1.4)
157
+ unicode-emoji (~> 4.0, >= 4.0.4)
158
+ unicode-emoji (4.0.4)
159
+ winrm (2.3.9)
129
160
  builder (>= 2.1.2)
130
161
  erubi (~> 1.8)
131
162
  gssapi (~> 1.2)
132
163
  gyoku (~> 1.0)
133
164
  httpclient (~> 2.2, >= 2.2.0.2)
134
165
  logging (>= 1.6.1, < 3.0)
135
- nori (~> 2.0)
166
+ nori (~> 2.0, >= 2.7.1)
167
+ rexml (~> 3.0)
136
168
  rubyntlm (~> 0.6.0, >= 0.6.3)
137
169
 
138
170
  PLATFORMS
139
- arm64-darwin-22
140
- x86_64-darwin-20
141
- x86_64-linux
171
+ aarch64-linux-gnu
172
+ aarch64-linux-musl
173
+ arm-linux-gnu
174
+ arm-linux-musl
175
+ arm64-darwin
176
+ ruby
177
+ x86-linux-gnu
178
+ x86-linux-musl
179
+ x86_64-darwin
180
+ x86_64-linux-gnu
181
+ x86_64-linux-musl
142
182
 
143
183
  DEPENDENCIES
144
184
  cem_acpt!
@@ -151,4 +191,4 @@ DEPENDENCIES
151
191
  simplecov
152
192
 
153
193
  BUNDLED WITH
154
- 2.4.19
194
+ 2.5.22
data/cem_acpt.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_runtime_dependency 'async-http', '>= 0.60', '< 0.70'
31
31
  spec.add_runtime_dependency 'bcrypt_pbkdf', '>= 1.0', '< 2.0'
32
32
  spec.add_runtime_dependency 'deep_merge', '>= 1.2', '< 2.0'
33
- spec.add_runtime_dependency 'ed25519', '>= 1.2', '< 2.0'
33
+ spec.add_runtime_dependency 'ed25519', '>= 1.0', '< 2.0'
34
34
  spec.add_runtime_dependency 'puppet-modulebuilder', '>= 0.0.1'
35
35
  spec.add_runtime_dependency 'winrm', '>= 2.3', '< 3.0'
36
36
  spec.add_development_dependency 'pry'
@@ -107,7 +107,7 @@ module CemAcpt
107
107
  logger.debug('CemAcpt::Bolt') { "Running Bolt command: #{cmd}" }
108
108
  logger.debug('CemAcpt::Bolt') { "Bolt command environment: #{cmd_env}" }
109
109
  begin
110
- out = CemAcpt::Utils::Shell.run_cmd(cmd, cmd_env, output: nil, raise_on_fail: false)
110
+ out = CemAcpt::Utils::Shell.run_cmd(cmd, cmd_env, output: nil, raise_on_fail: false, combine_out_err: false)
111
111
  logger.debug('CemAcpt::Bolt') { "Bolt command raw output:\n#{out}" }
112
112
  CemAcpt::Bolt::Cmd::Output.new(out, strict: strict, **(@item_defaults || {}))
113
113
  rescue StandardError => e
@@ -43,6 +43,7 @@ module CemAcpt
43
43
  'config' => {
44
44
  'transport' => 'ssh',
45
45
  'ssh' => {
46
+ 'native-ssh' => true,
46
47
  'connect-timeout' => 60,
47
48
  'disconnect-timeout' => 60,
48
49
  'host-key-check' => false,
@@ -316,7 +316,11 @@ module CemAcpt
316
316
  @inventory = inventory
317
317
  @project = project
318
318
  @test_data = nil
319
+ @tasks_only = @config&.get('bolt.tasks.only') || []
320
+ @tasks_ignore = @config&.get('bolt.tasks.ignore') || []
319
321
  @tasks = []
322
+ @tests_only = @config&.get('boly.tests.only') || []
323
+ @tests_ignore = @config&.get('bolt.tests.ignore') || []
320
324
  @tests = []
321
325
  @loaded = false
322
326
  @setup = false
@@ -391,12 +395,35 @@ module CemAcpt
391
395
  end
392
396
  end
393
397
 
398
+ def run_task?(task_name)
399
+ (@tasks_only.empty? || @tasks_only.include?(task_name)) &&
400
+ (@tasks_ignore.empty? || !@tasks_ignore.include?(task_name))
401
+ end
402
+
403
+ def run_test?(test_group)
404
+ (@tests_only.empty? || @tests_only.include?(test_group)) &&
405
+ (@tests_ignore.empty? || !@tests_ignore.include?(test_group)) &&
406
+ @config.get('tests').include?(test_group)
407
+ end
408
+
394
409
  def new_test_array(tasks, test_data)
395
410
  tw_created = {}
396
411
  logger.debug('CemAcpt::Bolt::Tests') { 'Creating tests for Bolt tasks' }
397
412
  tasks.each do |task|
413
+ if run_task?(task.full_name)
414
+ logger.verbose('CemAcpt::Bolt::Tests') { "Running tests for task #{task.full_name}" }
415
+ else
416
+ logger.debug('CemAcpt::Bolt::Tests') { "Skipping tests for task #{task.full_name}" }
417
+ next
418
+ end
419
+
398
420
  test_data.each do |group, tdata|
399
- next unless @config.get('tests').include?(group)
421
+ if run_test?(group)
422
+ logger.verbose('CemAcpt::Bolt::Tests') { "Running tests for group #{group}" }
423
+ else
424
+ logger.debug('CemAcpt::Bolt::Tests') { "Skipping tests for group #{group}" }
425
+ next
426
+ end
400
427
 
401
428
  if tw_created.key?(task.full_name)
402
429
  tw_created[task.full_name].add_group(group)
data/lib/cem_acpt/bolt.rb CHANGED
@@ -55,8 +55,8 @@ module CemAcpt
55
55
 
56
56
  def teardown!
57
57
  logger.debug('CemAcpt::Bolt') { 'Tearing down Bolt project...' }
58
- @inventory.delete!
59
- @project.delete!
58
+ @inventory.delete! unless @config.get('bolt.keep_inventory')
59
+ @project.delete! unless @config.get('bolt.keep_project')
60
60
  end
61
61
 
62
62
  def hosts=(hosts)
data/lib/cem_acpt/cli.rb CHANGED
@@ -41,6 +41,16 @@ module CemAcpt
41
41
  options[:bolt][:tests] ||= {}
42
42
  options[:bolt][:tests][:enabled] = false
43
43
  end
44
+
45
+ opts.on('--bolt-keep-inventory', 'Keep the Bolt inventory after tests') do
46
+ options[:bolt] ||= {}
47
+ options[:bolt][:keep_inventory] = true
48
+ end
49
+
50
+ opts.on('--bolt-keep-project', 'Keep the Bolt project after tests') do
51
+ options[:bolt] ||= {}
52
+ options[:bolt][:keep_project] = true
53
+ end
44
54
  when :cem_acpt_image
45
55
  opts.on('--dry-run', 'Logs the information for the images that would be created. Does not create images.') do
46
56
  options[:dry_run] = true
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'digest'
4
+ require 'deep_merge'
4
5
  require 'fileutils'
5
6
  require 'json'
6
7
  require 'yaml'
@@ -40,6 +41,11 @@ module CemAcpt
40
41
  verbose
41
42
  ].freeze
42
43
 
44
+ DEEP_MERGE_OPTS = {
45
+ overwrite_arrays: true,
46
+ merge_nil_values: true,
47
+ }.freeze
48
+
43
49
  attr_reader :config, :env_vars
44
50
 
45
51
  def initialize(opts: {}, config_file: nil, load_user_config: true)
@@ -84,9 +90,9 @@ module CemAcpt
84
90
  create_config_dirs!
85
91
  init_config!(opts: opts, config_file: config_file)
86
92
  add_env_vars!(@config)
87
- @config.merge!(user_config) if user_config && @load_user_config
88
- @config.merge!(config_from_file) if config_from_file
89
- @config.merge!(@options) if @options
93
+ @config.deep_merge!(user_config, **DEEP_MERGE_OPTS) if user_config && @load_user_config
94
+ @config.deep_merge!(config_from_file, **DEEP_MERGE_OPTS) if config_from_file
95
+ @config.deep_merge!(@options, **DEEP_MERGE_OPTS) if @options
90
96
  add_static_options!(@config)
91
97
  @config.format! # Symbolize keys of all hashes
92
98
  validate_config!
@@ -217,9 +223,8 @@ module CemAcpt
217
223
  config.dset('log_level', 'debug')
218
224
  config.dset('verbose', true)
219
225
  end
220
- if ENV['GITHUB_ACTIONS'] == 'true' || ENV['CI'] == 'true'
221
- config.dset('ci_mode', true)
222
- end
226
+ return unless ENV['GITHUB_ACTIONS'] == 'true' || ENV['CI'] == 'true'
227
+ config.dset('ci_mode', true)
223
228
  end
224
229
 
225
230
  # Used to source the config during loading of config files.
@@ -269,10 +274,10 @@ module CemAcpt
269
274
  return @user_config unless @user_config.nil? || @user_config.empty?
270
275
 
271
276
  @user_config = if user_config_file && File.exist?(user_config_file)
272
- load_config_file(user_config_file)
273
- else
274
- {}
275
- end
277
+ load_config_file(user_config_file)
278
+ else
279
+ {}
280
+ end
276
281
 
277
282
  @user_config
278
283
  end
@@ -14,7 +14,7 @@ module CemAcpt
14
14
  end
15
15
 
16
16
  def default_provision_commands
17
- [enable_puppet_repository_command, install_puppet_agent_command]
17
+ [enable_puppet_repository_command, set_repo_username_and_password, upgrade_packages_command, install_puppet_agent_command].flatten
18
18
  end
19
19
 
20
20
  def provision_commands
@@ -41,8 +41,24 @@ module CemAcpt
41
41
  "sudo #{package_manager} install -y #{package_manager_utils}"
42
42
  end
43
43
 
44
+ # Update to the new private Puppet platform repository URL
44
45
  def puppet_platform_repository_url
45
- "https://yum.puppet.com/puppet#{@puppet_version}-release-el-#{@os_major_version}.noarch.rpm"
46
+ "https://yum-puppetcore.puppet.com/public/puppet#{@puppet_version}-release-el-#{@os_major_version}.noarch.rpm"
47
+ end
48
+
49
+ def set_repo_username_and_password
50
+ commands = []
51
+ # Replace the commented out username and password lines with the actual username and password
52
+ # This is necessary to access the private Puppet platform repository
53
+ #
54
+ # Updating the username first
55
+ commands.push("sudo sed -i 's/^.*#username=.*$/username=forge-key/' /etc/yum.repos.d/puppet#{@puppet_version}-release.repo")
56
+
57
+ # Updating the password next
58
+ # The password is from the environment variable PUPPET_AUTH_TOKEN
59
+ # "sudo sed -i 's/#password=/password=#{ENV['PUPPET_AUTH_TOKEN']}/' /etc/yum.repos.d/puppet#{@puppet_version}-release.repo"
60
+ commands.push("sudo sed -i 's/^.*#password=.*$/password=$PUPPET_AUTH_TOKEN/' /etc/yum.repos.d/puppet#{@puppet_version}-release.repo")
61
+ commands
46
62
  end
47
63
 
48
64
  def enable_puppet_repository_command
@@ -84,7 +100,7 @@ module CemAcpt
84
100
  end
85
101
 
86
102
  def default_provision_commands
87
- [install_curl_command, enable_puppet_repository_command, upgrade_packages_command, install_puppet_agent_command]
103
+ [install_curl_command, enable_puppet_repository_command, set_repo_username_and_password, upgrade_packages_command, install_puppet_agent_command].flatten
88
104
  end
89
105
 
90
106
  def provision_commands
@@ -104,12 +120,27 @@ module CemAcpt
104
120
  end
105
121
  end
106
122
 
123
+ def set_repo_username_and_password
124
+ commands = []
125
+ # This is necessary to access the private Puppet platform repository
126
+ # Modifying the conf file at /et/apt/auth.conf.d/puppetcore.conf by adding the username and password
127
+
128
+ # Adding the server URL
129
+ commands.push("sudo echo machine apt-puppetcore.puppet.com | sudo tee /etc/apt/auth.conf.d/apt-puppetcore-puppet.conf > /dev/null")
130
+ # Adding the username
131
+ commands.push("sudo echo login forge-key | sudo tee -a /etc/apt/auth.conf.d/apt-puppetcore-puppet.conf > /dev/null")
132
+ # Adding the password
133
+ commands.push("sudo echo password $PUPPET_AUTH_TOKEN | sudo tee -a /etc/apt/auth.conf.d/apt-puppetcore-puppet.conf > /dev/null")
134
+ commands
135
+ end
136
+
137
+ # Update to the new private Puppet platform repository URL for apt
107
138
  def puppet_platform_repository_url
108
- "https://apt.puppet.com/puppet#{@puppet_version}-release-focal.deb"
139
+ "https://apt-puppetcore.puppet.com/public/puppet#{@puppet_version}-release-focal.deb"
109
140
  end
110
141
 
111
142
  def enable_puppet_repository_command
112
- "wget #{puppet_platform_repository_url} && sudo dpkg -i puppet#{@puppet_version}-release-focal.deb"
143
+ "wget --content-disposition #{puppet_platform_repository_url} && sudo dpkg -i puppet#{@puppet_version}-release-focal.deb"
113
144
  end
114
145
 
115
146
  def install_puppet_agent_command
@@ -19,28 +19,38 @@ module CemAcpt
19
19
  # command to in real time. Typically this is a Logger object. Defaults to $stdout.
20
20
  # If the object responds to #:debug, the command will be logged at the debug level.
21
21
  # @param raise_on_fail [Boolean] Whether to raise an error if the command fails
22
- # @return [String] The string output of the command
23
- def self.run_cmd(cmd, env = {}, output: $stdout, raise_on_fail: true)
24
- io_outerr = StringIO.new
22
+ # @param combine_out_err [Boolean] Whether to combine the output and error streams into the output.
23
+ # If false, the stderr stream will not be written to the output stream or returned with
24
+ # the output string.
25
+ # @return [String] The string output of the command, and the error output of the command
26
+ def self.run_cmd(cmd, env = {}, output: $stdout, raise_on_fail: true, combine_out_err: true)
27
+ io_out = StringIO.new
25
28
  if output.respond_to?(:debug)
26
29
  output.debug('CemAcpt::Utils::Shell') { "Running command:\n\t#{cmd}\nWith environment:\n\t#{env}" }
27
30
  elsif output
28
31
  output << "Running command:\n\t#{cmd}\nWith environment:\n\t#{env}\n"
29
32
  end
30
- val = Open3.popen2e(env, cmd) do |stdin, outerr, wait_thr|
31
- stdin.close
32
- outerr.sync = true
33
+ val = Open3.popen3(env, cmd) do |i, o, e, t|
34
+ i.close
35
+ o.sync = true
36
+ e.sync = true
33
37
  output_thread = Thread.new do
34
- while (line = outerr.gets("\n"))
38
+ while (line = o.gets("\n"))
35
39
  output << line if output
36
- io_outerr.write(line) unless line.chomp.empty?
40
+ io_out.write(line) unless line.chomp.empty?
41
+ end
42
+ if combine_out_err
43
+ while (line = e.gets("\n"))
44
+ output << line if output && combine_out_err
45
+ io_out.write(line) unless line.chomp.empty?
46
+ end
37
47
  end
38
48
  end
39
- wait_thr.join
49
+ t.join
40
50
  output_thread.exit
41
- wait_thr.value
51
+ t.value
42
52
  end
43
- io_string = io_outerr.string
53
+ io_string = io_out.string
44
54
  raise CemAcpt::ShellCommandError, "Error running command: #{cmd}\n#{io_string}" if raise_on_fail && !val.success?
45
55
 
46
56
  io_string
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CemAcpt
4
- VERSION = '0.10.5'
4
+ VERSION = '0.10.7'
5
5
  end
@@ -40,6 +40,19 @@ variable "public_key" {
40
40
  type = string
41
41
  }
42
42
 
43
+ # TF_VAR_PUPPET_AUTH_TOKEN must be defined as an environment variable on the running host (i.e the GitHub action runner node, or your local machine)
44
+ # for this variable to be initialized correctly
45
+ variable "PUPPET_AUTH_TOKEN" {
46
+ description = "Puppet Forge Auth Token"
47
+ type = string
48
+
49
+ validation {
50
+ condition = length(var.PUPPET_AUTH_TOKEN) > 0
51
+ error_message = "TF_VAR_PUPPET_AUTH_TOKEN must be defined as a local environment variable to proceed"
52
+ }
53
+ }
54
+
55
+
43
56
  variable "node_data" {
44
57
  type = map(object({
45
58
  image_family = string
@@ -88,8 +101,10 @@ resource "google_compute_instance" "acpt-test-node" {
88
101
  port = 22
89
102
  private_key = "${file(var.private_key)}"
90
103
  agent = false
104
+ script_path = "/home/${var.username}/terraform_%RAND%.sh"
91
105
  }
92
- inline = each.value.provision_commands
106
+ # Appending the command to export the PUPPET_AUTH_TOKEN to the existing provision_commands list
107
+ inline = concat(["export PUPPET_AUTH_TOKEN=${var.PUPPET_AUTH_TOKEN}"], each.value.provision_commands)
93
108
  }
94
109
 
95
110
  metadata = {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cem_acpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.5
4
+ version: 0.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - puppetlabs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-01 00:00:00.000000000 Z
11
+ date: 2025-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http
@@ -76,7 +76,7 @@ dependencies:
76
76
  requirements:
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: '1.2'
79
+ version: '1.0'
80
80
  - - "<"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.0'
@@ -86,7 +86,7 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '1.2'
89
+ version: '1.0'
90
90
  - - "<"
91
91
  - !ruby/object:Gem::Version
92
92
  version: '2.0'
@@ -314,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
314
314
  - !ruby/object:Gem::Version
315
315
  version: '0'
316
316
  requirements: []
317
- rubygems_version: 3.5.18
317
+ rubygems_version: 3.5.22
318
318
  signing_key:
319
319
  specification_version: 4
320
320
  summary: CEM Acceptance Tests