Sha256: d2888e50f08dc9bfdef45719942e43224213f7dbefd99f5425b83cbd1a3d4940

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 KB

Contents

require 'r10k/action/base'
require 'r10k/content_synchronizer'
require 'r10k/errors/formatting'
require 'r10k/module_loader/puppetfile'
require 'r10k/util/cleaner'

module R10K
  module Action
    module Puppetfile
      class Install < R10K::Action::Base

        def call
          begin
            options = { basedir: @root, overrides: { force: @force || false } }
            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

        private

        def allowed_initialize_opts
          super.merge(root: :self, puppetfile: :self, moduledir: :self, :'module-exclude-regex' => :self, force: :self )
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
r10k-3.16.0 lib/r10k/action/puppetfile/install.rb
r10k-3.15.4 lib/r10k/action/puppetfile/install.rb
r10k-3.15.3 lib/r10k/action/puppetfile/install.rb
r10k-3.15.2 lib/r10k/action/puppetfile/install.rb