class Kitchen::Provisioner::Puppet::Librarian

Puppet module resolver that uses Librarian-Puppet and a Puppetfile to calculate # dependencies.

Attributes

logger[R]
path[R]
puppetfile[R]

Public Class Methods

load!(logger = Kitchen.logger) click to toggle source
# File lib/kitchen/provisioner/puppet/librarian.rb, line 66
def self.load!(logger = Kitchen.logger)
  load_librarian!(logger)
end
load_librarian!(logger) click to toggle source
# File lib/kitchen/provisioner/puppet/librarian.rb, line 87
def self.load_librarian!(logger)
  first_load = require 'librarian/puppet'
  require 'librarian/puppet/environment'
  require 'librarian/action/resolve'
  require 'librarian/action/install'

  version = ::Librarian::Puppet::VERSION
  if first_load
    logger.debug("Librarian-Puppet #{version} library loaded")
  else
    logger.debug("Librarian-Puppet #{version} previously loaded")
  end
rescue LoadError => e
  logger.fatal("The `librarian-puppet' gem is missing and must be installed" \
    ' or cannot be properly activated. Run' \
    ' `gem install librarian-puppet` or add the following to your' \
    " Gemfile if you are using Bundler: `gem 'librarian-puppet'`.")
  raise UserError,
        "Could not load or activate Librarian-Puppet (#{e.message})"
end
new(puppetfile, path, logger = Kitchen.logger) click to toggle source
# File lib/kitchen/provisioner/puppet/librarian.rb, line 60
def initialize(puppetfile, path, logger = Kitchen.logger)
  @puppetfile = puppetfile
  @path = path
  @logger = logger
end

Public Instance Methods

resolve() click to toggle source
# File lib/kitchen/provisioner/puppet/librarian.rb, line 70
def resolve
  version = ::Librarian::Puppet::VERSION
  info("Resolving module dependencies with Librarian-Puppet #{version}...")
  debug("Using Puppetfile from #{puppetfile}")

  env = ::Librarian::Puppet::Environment.new(
    project_path: File.expand_path(File.dirname(puppetfile))
  )
  env.ui = LoggerUI.new(@logger)

  env.config_db.local['path'] = path
  ::Librarian::Action::Resolve.new(env).run
  ::Librarian::Action::Install.new(env).run
end