Class: Bolt::Config

Inherits:
Object
  • Object
show all
Includes:
Options
Defined in:
lib/bolt/config.rb,
lib/bolt/config/options.rb,
lib/bolt/config/modulepath.rb,
lib/bolt/config/transport/ssh.rb,
lib/bolt/config/transport/base.rb,
lib/bolt/config/transport/orch.rb,
lib/bolt/config/transport/local.rb,
lib/bolt/config/transport/winrm.rb,
lib/bolt/config/transport/docker.rb,
lib/bolt/config/transport/remote.rb,
lib/bolt/config/transport/options.rb

Defined Under Namespace

Modules: Options, Transport Classes: Modulepath

Constant Summary collapse

BOLT_CONFIG_NAME =
'bolt.yaml'
BOLT_DEFAULTS_NAME =
'bolt-defaults.yaml'
DEFAULT_DEFAULT_CONCURRENCY =

The default concurrency value that is used when the ulimit is not low (i.e. < 700)

100

Constants included from Options

Options::BOLT_DEFAULTS_OPTIONS, Options::BOLT_OPTIONS, Options::BOLT_PROJECT_OPTIONS, Options::INVENTORY_OPTIONS, Options::OPTIONS, Options::PLUGIN, Options::TRANSPORT_CONFIG

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, config_data, overrides = {}) ⇒ Config



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/bolt/config.rb', line 264

def initialize(project, config_data, overrides = {})
  unless config_data.is_a?(Array)
    config_data = [{ filepath: project.config_file, data: config_data }]
  end

  @logger       = Bolt::Logger.logger(self)
  @project      = project
  @transports   = {}
  @config_files = []

  default_data = {
    'apply-settings'      => {},
    'apply_settings'      => {},
    'color'               => true,
    'compile-concurrency' => Etc.nprocessors,
    'concurrency'         => default_concurrency,
    'disable-warnings'    => [],
    'format'              => 'human',
    'log'                 => { 'console' => {} },
    'module-install'      => {},
    'plugin-hooks'        => {},
    'plugin_hooks'        => {},
    'plugins'             => {},
    'puppetdb'            => {},
    'puppetfile'          => {},
    'save-rerun'          => true,
    'spinner'             => true,
    'transport'           => 'ssh'
  }

  if project.path.directory?
    default_data['log']['bolt-debug.log'] = {
      'level' => 'debug',
      'append' => false
    }
  end

  loaded_data = config_data.each_with_object([]) do |data, acc|
    if data[:data].any?
      @config_files.push(data[:filepath])
      acc.push(data[:data])
    end
  end

  override_data = normalize_overrides(overrides)

  # If we need to lower concurrency and concurrency is not configured
  ld_concurrency = loaded_data.map(&:keys).flatten.include?('concurrency')
  @modified_concurrency = default_concurrency != DEFAULT_DEFAULT_CONCURRENCY &&
                          !ld_concurrency &&
                          !override_data.key?('concurrency')

  @data = merge_config_layers(default_data, *loaded_data, override_data)

  TRANSPORT_CONFIG.each do |transport, config|
    @transports[transport] = config.new(@data.delete(transport), @project.path)
  end

  finalize_data
  validate
end

Instance Attribute Details

#config_filesObject (readonly)

Returns the value of attribute config_files.



23
24
25
# File 'lib/bolt/config.rb', line 23

def config_files
  @config_files
end

#dataObject (readonly)

Returns the value of attribute data.



23
24
25
# File 'lib/bolt/config.rb', line 23

def data
  @data
end

#modified_concurrencyObject (readonly)

Returns the value of attribute modified_concurrency.



23
24
25
# File 'lib/bolt/config.rb', line 23

def modified_concurrency
  @modified_concurrency
end

#projectObject (readonly)

Returns the value of attribute project.



23
24
25
# File 'lib/bolt/config.rb', line 23

def project
  @project
end

#transportsObject (readonly)

Returns the value of attribute transports.



23
24
25
# File 'lib/bolt/config.rb', line 23

def transports
  @transports
end

Class Method Details

.bolt_schemaObject

Builds the schema for bolt.yaml used by the validator.



116
117
118
119
120
121
122
# File 'lib/bolt/config.rb', line 116

def self.bolt_schema
  {
    type:        Hash,
    properties:  (BOLT_OPTIONS + INVENTORY_OPTIONS.keys).map { |opt| [opt, _ref: opt] }.to_h,
    definitions: OPTIONS.merge(transport_definitions)
  }
end

.defaultObject



31
32
33
# File 'lib/bolt/config.rb', line 31

def self.default
  new(Bolt::Project.default_project, {})
end

.defaults_schemaObject

Builds the schema for bolt-defaults.yaml used by the validator.



102
103
104
105
106
107
108
109
110
111
112
# File 'lib/bolt/config.rb', line 102

def self.defaults_schema
  schema = {
    type:        Hash,
    properties:  BOLT_DEFAULTS_OPTIONS.map { |opt| [opt, _ref: opt] }.to_h,
    definitions: OPTIONS.merge(transport_definitions)
  }

  schema[:definitions]['inventory-config'][:properties] = transport_definitions

  schema
end

.from_file(configfile, overrides = {}) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/bolt/config.rb', line 63

def self.from_file(configfile, overrides = {})
  project = Bolt::Project.create_project(Pathname.new(configfile).expand_path.dirname)

  conf = if project.project_file == project.config_file
           project.data
         else
           c = Bolt::Util.read_yaml_hash(configfile, 'config')

           # Validate the config against the schema. This will raise a single error
           # with all validation errors.
           Bolt::Validator.new.tap do |validator|
             validator.validate(c, bolt_schema, project.config_file.to_s)
             validator.warnings.each { |warning| Bolt::Logger.warn(warning[:id], warning[:msg]) }
             validator.deprecations.each { |dep| Bolt::Logger.deprecate(dep[:id], dep[:msg]) }
           end

           Bolt::Logger.debug("Loaded configuration from #{configfile}")

           c
         end

  data = load_defaults(project).push(
    filepath: configfile,
    data: conf
  )

  new(project, data, overrides)
end

.from_project(project, overrides = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/bolt/config.rb', line 35

def self.from_project(project, overrides = {})
  conf = if project.project_file == project.config_file
           project.data
         else
           c = Bolt::Util.read_optional_yaml_hash(project.config_file, 'config')

           # Validate the config against the schema. This will raise a single error
           # with all validation errors.
           Bolt::Validator.new.tap do |validator|
             validator.validate(c, bolt_schema, project.config_file.to_s)
             validator.warnings.each { |warning| Bolt::Logger.warn(warning[:id], warning[:msg]) }
             validator.deprecations.each { |dep| Bolt::Logger.deprecate(dep[:id], dep[:msg]) }
           end

           if File.exist?(project.config_file)
             Bolt::Logger.debug("Loaded configuration from #{project.config_file}")
           end
           c
         end

  data = load_defaults(project).push(
    filepath: project.config_file,
    data: conf
  )

  new(project, data, overrides)
end

.load_bolt_defaults_yaml(dir) ⇒ Object

Loads a ‘bolt-defaults.yaml’ file, which contains default configuration that applies to all projects. This file does not allow project-specific configuration such as ‘hiera-config’ and ‘inventoryfile’, and nests all default inventory configuration under an ‘inventory-config’ key.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/bolt/config.rb', line 141

def self.load_bolt_defaults_yaml(dir)
  filepath     = dir + BOLT_DEFAULTS_NAME
  data         = Bolt::Util.read_yaml_hash(filepath, 'config')

  Bolt::Logger.debug("Loaded configuration from #{filepath}")

  # Warn if 'bolt.yaml' detected in same directory.
  if File.exist?(bolt_yaml = dir + BOLT_CONFIG_NAME)
    Bolt::Logger.warn(
      "multiple_config_files",
      "Detected multiple configuration files: ['#{bolt_yaml}', '#{filepath}']. '#{bolt_yaml}' "\
      "will be ignored."
    )
  end

  # Validate the config against the schema. This will raise a single error
  # with all validation errors.
  Bolt::Validator.new.tap do |validator|
    validator.validate(data, defaults_schema, filepath)
    validator.warnings.each { |warning| Bolt::Logger.warn(warning[:id], warning[:msg]) }
    validator.deprecations.each { |dep| Bolt::Logger.deprecate(dep[:id], dep[:msg]) }
  end

  # Remove project-specific config such as hiera-config, etc.
  project_config = data.slice(*(BOLT_PROJECT_OPTIONS - BOLT_DEFAULTS_OPTIONS))

  if project_config.any?
    data.reject! { |key, _| project_config.include?(key) }

    Bolt::Logger.warn(
      "unsupported_project_config",
      "Unsupported project configuration detected in '#{filepath}': #{project_config.keys}. "\
      "Project configuration should be set in 'bolt-project.yaml'."
    )
  end

  # Remove top-level transport config such as transport, ssh, etc.
  transport_config = data.slice(*INVENTORY_OPTIONS.keys)

  if transport_config.any?
    data.reject! { |key, _| transport_config.include?(key) }

    Bolt::Logger.warn(
      "unsupported_inventory_config",
      "Unsupported inventory configuration detected in '#{filepath}': #{transport_config.keys}. "\
      "Transport configuration should be set under the 'inventory-config' option or "\
      "in 'inventory.yaml'."
    )
  end

  # Move data under inventory-config to top-level so it can be easily merged with
  # config from other sources. Error early if inventory-config is not a hash or
  # has a plugin reference.
  if data.key?('inventory-config')
    unless data['inventory-config'].is_a?(Hash)
      raise Bolt::ValidationError,
            "Option 'inventory-config' must be of type Hash, received #{data['inventory-config']} "\
            "#{data['inventory-config']} (file: #{filepath})"
    end

    if data['inventory-config'].key?('_plugin')
      raise Bolt::ValidationError,
            "Found unsupported key '_plugin' for option 'inventory-config'; supported keys are "\
            "'#{INVENTORY_OPTIONS.keys.join("', '")}' (file: #{filepath})"
    end

    data = data.merge(data.delete('inventory-config'))
  end

  { filepath: filepath, data: data }
end

.load_bolt_yaml(dir) ⇒ Object

Loads a ‘bolt.yaml’ file, the legacy configuration file. There’s no special munging needed here since Bolt::Config will just ignore any invalid keys.



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/bolt/config.rb', line 215

def self.load_bolt_yaml(dir)
  filepath     = dir + BOLT_CONFIG_NAME
  data         = Bolt::Util.read_yaml_hash(filepath, 'config')

  Bolt::Logger.debug("Loaded configuration from #{filepath}")

  Bolt::Logger.deprecate(
    "bolt_yaml",
    "Configuration file #{filepath} is deprecated and will be removed in Bolt 3.0. "\
    "See https://pup.pt/update-bolt-config for how to update to the latest Bolt practices."
  )

  # Validate the config against the schema. This will raise a single error
  # with all validation errors.
  Bolt::Validator.new.tap do |validator|
    validator.validate(data, bolt_schema, filepath)
    validator.warnings.each { |warning| Bolt::Logger.warn(warning[:id], warning[:msg]) }
    validator.deprecations.each { |dep| Bolt::Logger.deprecate(dep[:id], dep[:msg]) }
  end

  { filepath: filepath, data: data }
end

.load_defaults(project) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/bolt/config.rb', line 238

def self.load_defaults(project)
  confs = []

  # Load system-level config. Prefer a 'bolt-defaults.yaml' file, but fall back to the
  # legacy 'bolt.yaml' file. If the project-level config file is also the system-level
  # config file, don't load it a second time.
  if File.exist?(system_path + BOLT_DEFAULTS_NAME)
    confs << load_bolt_defaults_yaml(system_path)
  elsif File.exist?(system_path + BOLT_CONFIG_NAME) &&
        (system_path + BOLT_CONFIG_NAME) != project.config_file
    confs << load_bolt_yaml(system_path)
  end

  # Load user-level config if there is a homedir. Prefer a 'bolt-defaults.yaml' file, but
  # fall back to the legacy 'bolt.yaml' file.
  if user_path
    if File.exist?(user_path + BOLT_DEFAULTS_NAME)
      confs << load_bolt_defaults_yaml(user_path)
    elsif File.exist?(user_path + BOLT_CONFIG_NAME)
      confs << load_bolt_yaml(user_path)
    end
  end

  confs
end

.system_pathObject



124
125
126
127
128
129
130
# File 'lib/bolt/config.rb', line 124

def self.system_path
  if Bolt::Util.windows?
    Pathname.new(File.join(ENV['ALLUSERSPROFILE'], 'PuppetLabs', 'bolt', 'etc'))
  else
    Pathname.new(File.join('/etc', 'puppetlabs', 'bolt'))
  end
end

.transport_definitionsObject

Builds a hash of definitions for transport configuration.



94
95
96
97
98
# File 'lib/bolt/config.rb', line 94

def self.transport_definitions
  INVENTORY_OPTIONS.each_with_object({}) do |(option, definition), acc|
    acc[option] = TRANSPORT_CONFIG.key?(option) ? definition.merge(TRANSPORT_CONFIG[option].schema) : definition
  end
end

.user_pathObject



132
133
134
135
136
# File 'lib/bolt/config.rb', line 132

def self.user_path
  Pathname.new(File.expand_path(File.join('~', '.puppetlabs', 'etc', 'bolt')))
rescue StandardError
  nil
end

Instance Method Details

#apply_settingsObject



610
611
612
613
614
615
616
617
618
619
620
621
622
623
# File 'lib/bolt/config.rb', line 610

def apply_settings
  if @data['apply-settings'].any? && @data['apply_settings'].any?
    Bolt::Logger.warn_once(
      "apply_settings_conflict",
      "Detected configuration for 'apply-settings' and 'apply_settings'. Bolt will ignore 'apply_settings'."
    )

    @data['apply-settings']
  elsif @data['apply-settings'].any?
    @data['apply-settings']
  else
    @data['apply_settings']
  end
end

#check_path_case(type, paths) ⇒ Object

Check if there is a case-insensitive match to the path



638
639
640
641
642
643
644
645
646
647
# File 'lib/bolt/config.rb', line 638

def check_path_case(type, paths)
  return if paths.nil?
  matches = matching_paths(paths)

  if matches.any?
    msg = "WARNING: Bolt is case sensitive when specifying a #{type}. Did you mean:\n"
    matches.each { |path| msg += "         #{path}\n" }
    Bolt::Logger.warn("path_case", msg)
  end
end

#colorObject



563
564
565
# File 'lib/bolt/config.rb', line 563

def color
  @data['color']
end

#compile_concurrencyObject



579
580
581
# File 'lib/bolt/config.rb', line 579

def compile_concurrency
  @data['compile-concurrency']
end

#concurrencyObject



539
540
541
# File 'lib/bolt/config.rb', line 539

def concurrency
  @data['concurrency']
end

#deep_cloneObject



383
384
385
# File 'lib/bolt/config.rb', line 383

def deep_clone
  Bolt::Util.deep_clone(self)
end

#default_concurrencyObject



665
666
667
668
669
670
671
# File 'lib/bolt/config.rb', line 665

def default_concurrency
  @default_concurrency ||= if !sc_open_max_available? || Etc.sysconf(Etc::SC_OPEN_MAX) >= 300
                             DEFAULT_DEFAULT_CONCURRENCY
                           else
                             Etc.sysconf(Etc::SC_OPEN_MAX) / 7
                           end
end

#default_inventoryfileObject



505
506
507
# File 'lib/bolt/config.rb', line 505

def default_inventoryfile
  @project.inventory_file
end

#disable_warningsObject



633
634
635
# File 'lib/bolt/config.rb', line 633

def disable_warnings
  Set.new(@project.disable_warnings + @data['disable-warnings'])
end

#formatObject



543
544
545
# File 'lib/bolt/config.rb', line 543

def format
  @data['format']
end

#format=(value) ⇒ Object



547
548
549
# File 'lib/bolt/config.rb', line 547

def format=(value)
  @data['format'] = value
end

#hiera_configObject



513
514
515
# File 'lib/bolt/config.rb', line 513

def hiera_config
  @data['hiera-config'] || @project.hiera_config
end

#inventoryfileObject



575
576
577
# File 'lib/bolt/config.rb', line 575

def inventoryfile
  @data['inventoryfile']
end

#logObject



555
556
557
# File 'lib/bolt/config.rb', line 555

def log
  @data['log']
end

#matching_paths(paths) ⇒ Object



649
650
651
# File 'lib/bolt/config.rb', line 649

def matching_paths(paths)
  Array(paths).map { |p| Dir.glob([p, casefold(p)]) }.flatten.uniq.reject { |p| Array(paths).include?(p) }
end

#merge_config_layers(*config_data) ⇒ Object

Merge configuration from all sources into a single hash. Precedence from lowest to highest: defaults, system-wide, user-level, project-level, CLI overrides



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/bolt/config.rb', line 359

def merge_config_layers(*config_data)
  config_data.inject({}) do |acc, config|
    acc.merge(config) do |key, val1, val2|
      case key
      # Plugin config is shallow merged for each plugin
      when 'plugins'
        val1.merge(val2) { |_, v1, v2| v1.merge(v2) }
      # Transports are deep merged
      when *TRANSPORT_CONFIG.keys
        Bolt::Util.deep_merge(val1, val2)
      # Hash values are shallow merged
      when 'puppetdb', 'plugin-hooks', 'plugin_hooks', 'apply-settings', 'apply_settings', 'log'
        val1.merge(val2)
      # Disabled warnings are concatenated
      when 'disable-warnings'
        val1.concat(val2)
      # All other values are overwritten
      else
        val2
      end
    end
  end
end

#module_installObject



629
630
631
# File 'lib/bolt/config.rb', line 629

def module_install
  @project.module_install || @data['module-install']
end

#modulepathObject



521
522
523
524
525
526
527
528
529
# File 'lib/bolt/config.rb', line 521

def modulepath
  path = @data['modulepath'] || @project.modulepath

  if @project.modules
    path + [@project.managed_moduledir.to_s]
  else
    path
  end
end

#modulepath=(value) ⇒ Object



531
532
533
# File 'lib/bolt/config.rb', line 531

def modulepath=(value)
  @data['modulepath'] = value
end

#normalize_overrides(options) ⇒ Object

Transforms CLI options into a config hash that can be merged with default and loaded config.



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/bolt/config.rb', line 328

def normalize_overrides(options)
  opts = options.transform_keys(&:to_s)

  # Pull out config options. We need to add 'transport' as it's not part of the
  # OPTIONS hash but is a valid option that can be set with the --transport CLI option
  overrides = opts.slice(*OPTIONS.keys, 'transport')

  # Pull out transport config options
  TRANSPORT_CONFIG.each do |transport, config|
    overrides[transport] = opts.slice(*config.options)
  end

  # Set console log to debug if in debug mode
  if options[:debug]
    overrides['log'] = { 'console' => { 'level' => 'debug' } }
  end

  if options[:puppetfile_path]
    @puppetfile = options[:puppetfile_path]
  end

  overrides['trace'] = opts['trace'] if opts.key?('trace')

  # Validate the overrides
  Bolt::Validator.new.validate(overrides, self.class.bolt_schema, 'command line')

  overrides
end

#plugin_cacheObject



535
536
537
# File 'lib/bolt/config.rb', line 535

def plugin_cache
  @project.plugin_cache || @data['plugin-cache'] || {}
end

#plugin_hooksObject



591
592
593
594
595
596
597
598
599
600
601
602
603
604
# File 'lib/bolt/config.rb', line 591

def plugin_hooks
  if @data['plugin-hooks'].any? && @data['plugin_hooks'].any?
    Bolt::Logger.warn_once(
      "plugin_hooks_conflict",
      "Detected configuration for 'plugin-hooks' and 'plugin_hooks'. Bolt will ignore 'plugin_hooks'."
    )

    @data['plugin-hooks']
  elsif @data['plugin-hooks'].any?
    @data['plugin-hooks']
  else
    @data['plugin_hooks']
  end
end

#pluginsObject



587
588
589
# File 'lib/bolt/config.rb', line 587

def plugins
  @data['plugins']
end

#puppetdbObject



559
560
561
# File 'lib/bolt/config.rb', line 559

def puppetdb
  @data['puppetdb']
end

#puppetfileObject



517
518
519
# File 'lib/bolt/config.rb', line 517

def puppetfile
  @puppetfile || @project.puppetfile
end

#puppetfile_configObject



583
584
585
# File 'lib/bolt/config.rb', line 583

def puppetfile_config
  @data['puppetfile']
end

#rerunfileObject



509
510
511
# File 'lib/bolt/config.rb', line 509

def rerunfile
  @project.rerunfile
end

#save_rerunObject



567
568
569
# File 'lib/bolt/config.rb', line 567

def save_rerun
  @data['save-rerun']
end

#sc_open_max_available?Boolean

Etc::SC_OPEN_MAX is meaningless on windows, not defined in PE Jruby and not available on some platforms. This method holds the logic to decide whether or not to even consider it.



661
662
663
# File 'lib/bolt/config.rb', line 661

def sc_open_max_available?
  !Bolt::Util.windows? && defined?(Etc::SC_OPEN_MAX) && Etc.sysconf(Etc::SC_OPEN_MAX)
end

#spinnerObject



571
572
573
# File 'lib/bolt/config.rb', line 571

def spinner
  @data['spinner']
end

#traceObject



551
552
553
# File 'lib/bolt/config.rb', line 551

def trace
  @data['trace']
end

#transportObject



625
626
627
# File 'lib/bolt/config.rb', line 625

def transport
  @data['transport']
end

#trusted_externalObject



606
607
608
# File 'lib/bolt/config.rb', line 606

def trusted_external
  @data['trusted-external-command']
end

#validateObject



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/bolt/config.rb', line 446

def validate
  if @data['future']
    Bolt::Logger.warn(
      "future_option",
      "Configuration option 'future' no longer exposes future behavior."
    )
  end

  if @project.modules && @data['modulepath']&.include?(@project.managed_moduledir.to_s)
    raise Bolt::ValidationError,
          "Found invalid path in modulepath: #{@project.managed_moduledir}. This path "\
          "is automatically appended to the modulepath and cannot be configured."
  end

  compile_limit = 2 * Etc.nprocessors
  unless compile_concurrency < compile_limit
    raise Bolt::ValidationError, "Compilation is CPU-intensive, set concurrency less than #{compile_limit}"
  end

  %w[hiera-config trusted-external-command inventoryfile].each do |opt|
    Bolt::Util.validate_file(opt, @data[opt]) if @data[opt]
  end

  if File.exist?(default_inventoryfile)
    Bolt::Util.validate_file('inventory file', default_inventoryfile)
  end

  # Warn the user how they should be using the 'puppetfile' or
  # 'module-install' config options. We don't error here since these
  # settings can be set at the user or system level.
  if @project.modules && puppetfile_config.any? && module_install.empty?
    command = Bolt::Util.powershell? ? 'Update-BoltProject' : 'bolt project migrate'
    Bolt::Logger.warn(
      "module_install_config",
      "Detected configuration for 'puppetfile'. This setting is not "\
      "used when 'modules' is configured. Use 'module-install' instead. "\
      "To automatically update your project configuration, run '#{command}'."
    )
  elsif @project.modules.nil? && puppetfile_config.empty? && module_install.any?
    Bolt::Logger.warn(
      "module_install_config",
      "Detected configuration for 'module-install'. This setting is not "\
      "used when 'modules' is not configured. Use 'puppetfile' instead."
    )
  elsif @project.modules && puppetfile_config.any? && module_install.any?
    Bolt::Logger.warn(
      "module_install_config",
      "Detected configuration for 'puppetfile' and 'module-install'. Using "\
      "configuration for 'module-install' because 'modules' is also configured."
    )
  elsif @project.modules.nil? && puppetfile_config.any? && module_install.any?
    Bolt::Logger.warn(
      "module_install_config",
      "Detected configuration for 'puppetfile' and 'module-install'. Using "\
      "configuration for 'puppetfile' because 'modules' is not configured."
    )
  end
end