cem_acpt 0.10.4 → 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: 3f6d280d4ac5c56cd722e9a2a906647996cc18a5db7babc1f950b74a44306fc3
4
- data.tar.gz: f62af838277ee9e25b2af58093d1183460bc9022a175399c5830d38e49d01620
3
+ metadata.gz: f55a13b7ba6760d6d6b36ca313f7cddf637ae86b76ab48613de5938cb16f4d0e
4
+ data.tar.gz: 63838f21061f45475f880a7e6966664b0a043938b2f74548f79afebaf9801eca
5
5
  SHA512:
6
- metadata.gz: 0d573fb143effd9425d6b38f6e764c8bafb44acb583bf95b9f2a600ca787e975875e2004edcaedc78876c303342663376334fde8fff37c5fef1bed3b131c9442
7
- data.tar.gz: a4e164fd64921e3bdde69e664f846ebe3fc307e1d919fff61df40634ac34794124d5e15539c3c657f874c6e9403228e3dca2593c4fe54358b0c588ba92e5e698
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.4)
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
@@ -127,6 +127,7 @@ module CemAcpt
127
127
  end
128
128
  ensure
129
129
  @items = (@cmd_output['items'] || []).map { |item| OutputItem.new(item) }
130
+ @error_obj ||= @items.find(&:error?)&.error
130
131
  if @items.empty? && @error_obj.nil? && @strict
131
132
  err = RuntimeError.new("Cannot set results, no error or items found for cmd_output:\n#{cmd_output}")
132
133
  @error_obj = err
@@ -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,
@@ -158,11 +158,11 @@ module CemAcpt
158
158
  end
159
159
 
160
160
  def error?
161
- @command_result.is_a?(CemAcpt::Bolt::BoltActionError)
161
+ @command_result.error?
162
162
  end
163
163
 
164
164
  def error
165
- @command_result if error?
165
+ @command_result.error if error?
166
166
  end
167
167
 
168
168
  def to_h
@@ -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
@@ -378,7 +382,7 @@ module CemAcpt
378
382
  def load_test_data(run_data)
379
383
  run_data[:test_data].each_with_object({}) do |tdata, h|
380
384
  test_name = tdata[:test_name]
381
- next if h.key?(test_name) || tdata[:bolt_test].nil?
385
+ next if h.key?(test_name)
382
386
 
383
387
  logger.debug('CemAcpt::Bolt::Tests') { "Loading test data for test #{test_name}" }
384
388
  begin
@@ -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)
@@ -53,6 +53,8 @@ module CemAcpt
53
53
  return false unless File.exist?(path)
54
54
 
55
55
  disk_contents = CemAcpt::Utils::Files.read(path, log_prefix: self.class.to_s)
56
+ return false unless disk_contents.is_a?(Hash)
57
+
56
58
  @hash.sort.to_h == disk_contents.sort.to_h
57
59
  end
58
60
 
@@ -60,6 +62,8 @@ module CemAcpt
60
62
  return false unless File.exist?(path)
61
63
 
62
64
  disk_contents = CemAcpt::Utils::Files.read(path, log_prefix: self.class.to_s)
65
+ return false unless disk_contents.is_a?(Hash)
66
+
63
67
  @hash.sort.to_h >= disk_contents.sort.to_h
64
68
  end
65
69
 
@@ -67,6 +71,8 @@ module CemAcpt
67
71
  return false unless File.exist?(path)
68
72
 
69
73
  disk_contents = CemAcpt::Utils::Files.read(path, log_prefix: self.class.to_s)
74
+ return false unless disk_contents.is_a?(Hash)
75
+
70
76
  @hash.sort.to_h <= disk_contents.sort.to_h
71
77
  end
72
78
  end
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
@@ -26,25 +26,7 @@ module CemAcpt
26
26
  super(response)
27
27
  log_subject.each_with_object([]) do |res, ary|
28
28
  res.results.each do |r|
29
- header = [
30
- "#{success_str(r.success?).capitalize}: #{r.name}",
31
- "action: #{r.action}",
32
- "target: #{name_from_ip(r.target)}",
33
- "object: #{r.object}",
34
- "status: #{r.status}",
35
- ]
36
- parts = [
37
- header.join(', '),
38
- "validation results:\n#{JSON.pretty_generate(r.failed_validation_results)}",
39
- ]
40
- if CemAcpt::Logging.verbose?
41
- parts << "command result:\n#{JSON.pretty_generate(r.command_result.to_h)}"
42
- end
43
- parts << r.error if r.error?
44
- if r.respond_to?(:details) && !r.details&.empty?
45
- parts << "details:\n#{JSON.pretty_generate(r.details)}\n"
46
- end
47
- ary << parts.join("\n")
29
+ ary << (r.error? ? format_error_result(r) : format_result(r))
48
30
  end
49
31
  end
50
32
  end
@@ -58,6 +40,41 @@ module CemAcpt
58
40
  super(response)
59
41
  'Bolt tests'
60
42
  end
43
+
44
+ private
45
+
46
+ def result_header(r)
47
+ [
48
+ "#{success_str(r.success?).capitalize}: #{r.name}",
49
+ "action: #{r.action}",
50
+ "target: #{name_from_ip(r.target)}",
51
+ "object: #{r.object}",
52
+ "status: #{r.status}",
53
+ ].join(', ')
54
+ end
55
+
56
+ def format_result(r)
57
+ parts = [
58
+ result_header(r),
59
+ "validation results:\n#{JSON.pretty_generate(r.failed_validation_results)}",
60
+ ]
61
+ if CemAcpt::Logging.verbose?
62
+ parts << "command result:\n#{JSON.pretty_generate(r.command_result.to_h)}"
63
+ end
64
+ if r.respond_to?(:details) && !r.details&.empty?
65
+ parts << "details:\n#{JSON.pretty_generate(r.details)}\n"
66
+ end
67
+ parts.join("\n")
68
+ end
69
+
70
+ def format_error_result(r)
71
+ [
72
+ result_header(r),
73
+ "error: #{r.error.kind}",
74
+ "issue code: #{r.error.issue_code}",
75
+ r.error.msg,
76
+ ].join("\n")
77
+ end
61
78
  end
62
79
  end
63
80
  end
@@ -186,7 +186,7 @@ module CemAcpt
186
186
  @run_data[:nodes] = new_node_data
187
187
  logger.verbose('CemAcpt::TestRunner') { "Initial run data:\n#{@run_data}" }
188
188
  logger.info('CemAcpt::TestRunner') { 'Created initial run data...' }
189
- setup_bolt if CemAcpt::Actions.config.action_names.include?('bolt')
189
+ setup_bolt if CemAcpt::Actions.config.action_names.include?(:bolt)
190
190
  end
191
191
 
192
192
  def setup_bolt
@@ -197,12 +197,12 @@ module CemAcpt
197
197
  rescue CemAcpt::ShellCommandNotFoundError => e
198
198
  logger.warning('CemAcpt::TestRunner') { e.message }
199
199
  logger.warning('CemAcpt::TestRunner') { 'Adding Bolt action to ignore list...' }
200
- CemAcpt::Actions.config.ignore << 'bolt'
200
+ CemAcpt::Actions.config.ignore << :bolt
201
201
  return
202
202
  end
203
203
  return unless @bolt_test_runner.tests.to_a.empty?
204
204
 
205
- if !CemAcpt::Actions.config.only.empty? && CemAcpt::Actions.config.only.include?('bolt')
205
+ if !CemAcpt::Actions.config.only.empty? && CemAcpt::Actions.config.only.include?(:bolt)
206
206
  raise 'No Bolt tests to run and only bolt action was specified'
207
207
  end
208
208
 
@@ -348,6 +348,8 @@ module CemAcpt
348
348
  logger.info { r }
349
349
  else
350
350
  logger.error { r }
351
+ next unless result.respond_to?(:metadata) && result.metadata.key?(:run_logs)
352
+
351
353
  logs = if config.debug? && !config.get('puppet.no_debug')
352
354
  result.metadata[:run_logs]&.dup
353
355
  else
@@ -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.4'
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.4
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-09-27 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