Class: Kitchen::Provisioner::Puppet::Librarian
- Inherits:
-
Object
- Object
- Kitchen::Provisioner::Puppet::Librarian
- Includes:
- Logging
- Defined in:
- lib/kitchen/provisioner/puppet/librarian.rb
Overview
Puppet module resolver that uses Librarian-Puppet and a Puppetfile to calculate # dependencies.
Defined Under Namespace
Classes: LoggerUI
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#puppetfile ⇒ Object
readonly
Returns the value of attribute puppetfile.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(puppetfile, path, logger = Kitchen.logger) ⇒ Librarian
constructor
A new instance of Librarian.
- #resolve ⇒ Object
Constructor Details
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
86 87 88 |
# File 'lib/kitchen/provisioner/puppet/librarian.rb', line 86 def logger @logger end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
86 87 88 |
# File 'lib/kitchen/provisioner/puppet/librarian.rb', line 86 def path @path end |
#puppetfile ⇒ Object (readonly)
Returns the value of attribute puppetfile.
86 87 88 |
# File 'lib/kitchen/provisioner/puppet/librarian.rb', line 86 def puppetfile @puppetfile end |
Class Method Details
.load!(logger = Kitchen.logger) ⇒ Object
67 68 69 |
# File 'lib/kitchen/provisioner/puppet/librarian.rb', line 67 def self.load!(logger = Kitchen.logger) load_librarian!(logger) end |
.load_librarian!(logger) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/kitchen/provisioner/puppet/librarian.rb', line 88 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.})" end |
Instance Method Details
#resolve ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/kitchen/provisioner/puppet/librarian.rb', line 71 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.(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 |