Class: R10K::Action::Puppetfile::Install

Inherits:
Base
  • Object
show all
Defined in:
lib/r10k/action/puppetfile/install.rb

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS, Logging::SYSLOG_LEVELS_MAP

Instance Attribute Summary

Attributes inherited from Base

#settings

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Logging

add_outputters, debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level

Constructor Details

This class inherits a constructor from R10K::Action::Base

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/r10k/action/puppetfile/install.rb', line 12

def call
  begin
    options = { basedir: @root, overrides: { force: @force || false } }
    options[:overrides][:modules] = { default_ref: @settings.dig(:git, :default_ref) }
    options[:moduledir]  = @moduledir  if @moduledir
    options[:puppetfile] = @puppetfile if @puppetfile
    options[:module_exclude_regex] = @module_exclude_regex if @module_exclude_regex

    loader = R10K::ModuleLoader::Puppetfile.new(**options)
    loaded_content = loader.load!

    pool_size = @settings[:pool_size] || 4
    modules   = loaded_content[:modules]
    if pool_size > 1
      R10K::ContentSynchronizer.concurrent_sync(modules, pool_size, logger)
    else
      R10K::ContentSynchronizer.serial_sync(modules, logger)
    end

    R10K::Util::Cleaner.new(loaded_content[:managed_directories],
                            loaded_content[:desired_contents],
                            loaded_content[:purge_exclusions]).purge!

    true
  rescue => e
    logger.error R10K::Errors::Formatting.format_exception(e, @trace)
    false
  end
end