cem_acpt 0.7.1 → 0.7.2

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: b51e308bc7002bf4732a8f9aba7f8a43f2a62c5af67d1f6fffc6d524da9d683f
4
- data.tar.gz: 53de22ef68903167653ac98136ed657c6c34a88adc308d4191fdfec94860b294
3
+ metadata.gz: 4f33bff59cae8ea713a55134ce914c83aa3583e16e56cd0d5aca4bc7106df092
4
+ data.tar.gz: e1f8f76188ad32473da89fc389eead2b9d63af2bc8856cf3b30863b6454f89d2
5
5
  SHA512:
6
- metadata.gz: aa5189d13239222956bf6480ae2fa82513d241b88757e8dd3ef81d89bbbc576b71e1c5af3fbe01c3edf5a9ff3dc36506538be9572c3d647acf6536da8c3023c2
7
- data.tar.gz: be23f52aa2291ba5a82e60654b2aa07de3bdc262e4795447ac54b0f38ba780a669a9984fdd64cc9dd3fcaf94932f283c598af1f8e74d67a4a44ce322490b2fdd
6
+ metadata.gz: 8a54dfbf7dcf40684b3d00bec253822943cacd7388d3dabaaf6d6ed260811c5862d694544ea07f2cd135274cd9227aaa16e00e0dcc712e41c906bfffaa8fef17
7
+ data.tar.gz: '06678cf120f230d981d5247c39b688e8ca96ed13225e0595595579041232e17c3220044b4f51091ab6900e10b8b4f2aedd0115da901a9619025e7576aa7ceec2'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cem_acpt (0.7.1)
4
+ cem_acpt (0.7.2)
5
5
  async-http (>= 0.60, < 0.70)
6
6
  bcrypt_pbkdf (>= 1.0, < 2.0)
7
7
  deep_merge (>= 1.2, < 2.0)
data/lib/cem_acpt/cli.rb CHANGED
@@ -36,15 +36,23 @@ module CemAcpt
36
36
  options[:tests] = t.split(',')
37
37
  end
38
38
  when :cem_acpt_image
39
- opts.on('-U', '--no-linux', 'Do not build Linux images') do
39
+ opts.on('--dry-run', 'Logs the information for the images that would be created. Does not create images.') do
40
+ options[:dry_run] = true
41
+ end
42
+
43
+ opts.on('--no-linux', 'Do not build Linux images') do
40
44
  options[:cem_acpt_image] ||= {}
41
45
  options[:cem_acpt_image][:no_linux] = true
42
46
  end
43
47
 
44
- opts.on('-W', '--no-windows', 'Do not build Windows images') do
48
+ opts.on('--no-windows', 'Do not build Windows images') do
45
49
  options[:cem_acpt_image] ||= {}
46
50
  options[:cem_acpt_image][:no_windows] = true
47
51
  end
52
+
53
+ opts.on('-F', '--filter FILTER', 'Filter images to build by name with regex. Example: -F "(alma|rhel)-8"') do |f|
54
+ options[:image_name_filter] = Regexp.new(f)
55
+ end
48
56
  end
49
57
 
50
58
  opts.on('-D', '--debug', 'Enable debug logging') do
@@ -7,9 +7,12 @@ module CemAcpt
7
7
  # Holds the configuration for cem_acpt_image
8
8
  class CemAcptImage < Base
9
9
  VALID_KEYS = %i[
10
+ cem_acpt_image
10
11
  ci_mode
11
12
  config_file
13
+ dry_run
12
14
  images
15
+ image_name_filter
13
16
  log_level
14
17
  log_file
15
18
  log_format
@@ -34,9 +37,15 @@ module CemAcpt
34
37
  # The default configuration
35
38
  def defaults
36
39
  {
40
+ cem_acpt_image: {
41
+ no_linux: false,
42
+ no_windows: false,
43
+ },
37
44
  ci_mode: false,
38
45
  config_file: nil,
46
+ dry_run: false,
39
47
  images: {},
48
+ image_name_filter: Regexp.new('.*'),
40
49
  log_level: 'info',
41
50
  log_file: nil,
42
51
  log_format: 'text',
@@ -80,6 +80,7 @@ module CemAcpt
80
80
  'centos' => 'EnterpriseLinuxFamily',
81
81
  'rhel' => 'EnterpriseLinuxFamily',
82
82
  'alma' => 'EnterpriseLinuxFamily',
83
+ 'oel' => 'EnterpriseLinuxFamily',
83
84
  'windows' => 'WindowsFamily',
84
85
  }.freeze
85
86
 
@@ -44,17 +44,19 @@ module CemAcpt
44
44
  def run
45
45
  @start_time = Time.now
46
46
  logger.with_ci_group("CemAcptImage v#{CemAcpt::VERSION} run started at #{@start_time}") do
47
- logger.info('CemAcptImage') { "Using working directory: #{@working_dir}..." }
48
- keep_terminal_alive
49
47
  @all_tfvars = new_tfvars(@config)
50
- @working_dir = new_working_dir
51
48
  @linux_tfvars, @windows_tfvars = divide_tfvars_by_os(@all_tfvars)
52
- save_vars_to_file!('linux', @linux_tfvars)
53
- save_vars_to_file!('windows', @windows_tfvars)
54
- terraform_init
55
49
  image_types = []
56
50
  image_types << [@linux_tfvars, 'linux'] unless no_linux?
57
51
  image_types << [@windows_tfvars, 'windows'] unless no_windows?
52
+ return dry_run(image_types) if @config.get('dry_run')
53
+
54
+ @working_dir = new_working_dir
55
+ logger.info('CemAcptImage') { "Using working directory: #{@working_dir}..." }
56
+ keep_terminal_alive
57
+ save_vars_to_file!('linux', @linux_tfvars)
58
+ save_vars_to_file!('windows', @windows_tfvars)
59
+ terraform_init
58
60
  image_types.each do |tfvars, os_str|
59
61
  terraform_plan(os_str, tfvars, DEFAULT_PLAN_NAME)
60
62
  begin
@@ -107,6 +109,14 @@ module CemAcpt
107
109
  @linux_tfvars[:node_data].empty? || @config.get('cem_acpt_image.no_linux')
108
110
  end
109
111
 
112
+ def dry_run(image_types)
113
+ logger.info('CemAcptImage') { 'Dry run mode enabled. No images will be built.' }
114
+ image_types.each do |tfvars, os_str|
115
+ logger.info('CemAcptImage') { "Dry run for #{os_str}..." }
116
+ logger.info('CemAcptImage') { "Terraform vars:\n#{JSON.pretty_generate(tfvars)}" }
117
+ end
118
+ end
119
+
110
120
  def terraform
111
121
  return @terraform if defined?(@terraform)
112
122
 
@@ -233,6 +243,8 @@ module CemAcpt
233
243
  tfvars[:private_key] = private_key if private_key
234
244
  tfvars[:public_key] = public_key if public_key
235
245
  config.get('images').each do |image_name, image|
246
+ next if config.get('image_name_filter')&.respond_to?(:match?) && !config.get('image_name_filter').match?(image_name)
247
+
236
248
  platform = new_platform(config, **tfvars)
237
249
  tfvars.merge!(platform.platform_data)
238
250
  provision_commands = CemAcpt::ImageBuilder::ProvisionCommands.provision_commands(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CemAcpt
4
- VERSION = '0.7.1'
4
+ VERSION = '0.7.2'
5
5
  end
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.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - puppetlabs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-17 00:00:00.000000000 Z
11
+ date: 2023-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http