Sha256: f4e4c7906ca16b44b14bf52d264cbe1da1aee4600f7529c6337868f0a696706c

Contents?: true

Size: 1.12 KB

Versions: 28

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require 'bolt/r10k_log_proxy'
require 'bolt/error'

# This class is used to install modules from a Puppetfile to a module directory.
#
module Bolt
  class ModuleInstaller
    class Installer
      def initialize(config = {})
        @config = config
      end

      def install(path, moduledir)
        require 'r10k/cli'

        unless File.exist?(path)
          raise Bolt::FileError.new(
            "Could not find a Puppetfile at #{path}",
            path
          )
        end

        r10k_opts = {
          root:       File.dirname(path),
          puppetfile: path.to_s,
          moduledir:  moduledir.to_s
        }

        settings = R10K::Settings.global_settings.evaluate(@config)
        R10K::Initializers::GlobalInitializer.new(settings).call
        install_action = R10K::Action::Puppetfile::Install.new(r10k_opts, nil)

        # Override the r10k logger with a proxy to our own logger
        R10K::Logging.instance_variable_set(:@outputter, Bolt::R10KLogProxy.new)

        install_action.call
      rescue R10K::Error => e
        raise PuppetfileError, e
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
bolt-3.10.0 lib/bolt/module_installer/installer.rb
bolt-3.9.2 lib/bolt/module_installer/installer.rb
bolt-3.9.1 lib/bolt/module_installer/installer.rb
bolt-3.9.0 lib/bolt/module_installer/installer.rb
bolt-3.8.1 lib/bolt/module_installer/installer.rb
bolt-3.8.0 lib/bolt/module_installer/installer.rb
bolt-3.7.1 lib/bolt/module_installer/installer.rb
bolt-3.7.0 lib/bolt/module_installer/installer.rb
bolt-3.6.1 lib/bolt/module_installer/installer.rb
bolt-3.6.0 lib/bolt/module_installer/installer.rb
bolt-3.5.0 lib/bolt/module_installer/installer.rb
bolt-3.4.0 lib/bolt/module_installer/installer.rb
bolt-3.3.0 lib/bolt/module_installer/installer.rb
bolt-3.1.0 lib/bolt/module_installer/installer.rb
bolt-3.0.1 lib/bolt/module_installer/installer.rb
bolt-3.0.0 lib/bolt/module_installer/installer.rb
bolt-2.44.0 lib/bolt/module_installer/installer.rb
bolt-2.42.0 lib/bolt/module_installer/installer.rb
bolt-2.40.2 lib/bolt/module_installer/installer.rb
bolt-2.40.1 lib/bolt/module_installer/installer.rb