Class: VagrantPlugins::LibrarianPuppet::Action::Install

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-librarian-puppet-plugin/action/librarian_puppet.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Install

Returns a new instance of Install.



8
9
10
11
12
13
# File 'lib/vagrant-librarian-puppet-plugin/action/librarian_puppet.rb', line 8

def initialize(app, env)
  @app = app
  @env = env
  # Config#finalize! SHOULD be called automatically
  env[:global_config].librarian_puppet.finalize!
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vagrant-librarian-puppet-plugin/action/librarian_puppet.rb', line 15

def call(env)
  config = env[:global_config].librarian_puppet
  if
    provisioned? and
    File.exist? File.join(env[:root_path], config.puppetfile_path)

    env[:ui].info "Installing Puppet modules with Librarian-Puppet..."

    # NB: Librarian::Puppet::Environment calls `which puppet` so we
    # need to make sure VAGRANT_HOME/gems/bin has been added to the
    # path.
    original_path = ENV['PATH']
    bin_path = env[:gems_path].join('bin')
    ENV['PATH'] = "#{bin_path}#{::File::PATH_SEPARATOR}#{ENV['PATH']}"

    environment = Librarian::Puppet::Environment.new({
      :project_path => File.join(env[:root_path], config.puppetfile_dir)
    })
    Librarian::Action::Ensure.new(environment).run
    Librarian::Action::Resolve.new(environment).run
    Librarian::Action::Install.new(environment).run

    # Restore the original path
    ENV['PATH'] = original_path
  end
  @app.call(env)
end

#provisioned?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/vagrant-librarian-puppet-plugin/action/librarian_puppet.rb', line 43

def provisioned?
  @env[:provision_enabled].nil? ? true : @env[:provision_enabled]
end