Class: Kitchen::Provisioner::Puppet::R10K

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/kitchen/provisioner/puppet/r10k.rb

Overview

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(puppetfile, path, logger = Kitchen.logger) ⇒ R10K

Returns a new instance of R10K.



32
33
34
35
36
# File 'lib/kitchen/provisioner/puppet/r10k.rb', line 32

def initialize(puppetfile, path, logger = Kitchen.logger)
  @puppetfile = puppetfile
  @path = path
  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



55
56
57
# File 'lib/kitchen/provisioner/puppet/r10k.rb', line 55

def logger
  @logger
end

#pathObject (readonly)

Returns the value of attribute path.



55
56
57
# File 'lib/kitchen/provisioner/puppet/r10k.rb', line 55

def path
  @path
end

#puppetfileObject (readonly)

Returns the value of attribute puppetfile.



55
56
57
# File 'lib/kitchen/provisioner/puppet/r10k.rb', line 55

def puppetfile
  @puppetfile
end

Class Method Details

.load!(logger = Kitchen.logger) ⇒ Object



38
39
40
# File 'lib/kitchen/provisioner/puppet/r10k.rb', line 38

def self.load!(logger = Kitchen.logger)
  load_r10k!(logger)
end

.load_r10k!(logger) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/kitchen/provisioner/puppet/r10k.rb', line 57

def self.load_r10k!(logger)
  require 'r10k/puppetfile'

  version = ::R10K::VERSION
  logger.debug("R10K #{version} library loaded")
rescue LoadError => e
  logger.fatal("The `r10k' gem is missing and must be installed" \
    ' or cannot be properly activated. Run' \
    ' `gem install r10k` or add the following to your' \
    " Gemfile if you are using Bundler: `gem 'r10k'`.")
  raise UserError,
        "Could not load or activate R10K (#{e.message})"
end

Instance Method Details

#resolveObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/kitchen/provisioner/puppet/r10k.rb', line 42

def resolve
  version = ::R10K::VERSION
  info("Resolving module dependencies with R10K-Puppet #{version}...")
  debug("Using Puppetfile from #{puppetfile}")

  ::R10K::Git::Cache.settings[:cache_root] = '.r10k/git'
  ::R10K::Forge::ModuleRelease.settings[:cache_root] = '.r10k/cache'

  pf = ::R10K::Puppetfile.new(nil, path, puppetfile)
  pf.load
  pf.modules.map(&:sync)
end