Class: Berkshelf::Vagrant::Action::Install

Inherits:
Object
  • Object
show all
Includes:
EnvHelpers
Defined in:
lib/berkshelf/vagrant/action/install.rb

Overview

Author:

Instance Method Summary collapse

Methods included from EnvHelpers

#berkshelf_enabled?, #cache_file, #chef_client?, #chef_solo?, #provision_disabled?, #provisioners

Constructor Details

#initialize(app, env) ⇒ Install

Returns a new instance of Install.



8
9
10
# File 'lib/berkshelf/vagrant/action/install.rb', line 8

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/berkshelf/vagrant/action/install.rb', line 12

def call(env)
  if provision_disabled?(env)
    env[:berkshelf].ui.info "Skipping Berkshelf with --no-provision"

    return @app.call(env)
  end

  unless berkshelf_enabled?(env)
    if File.exist?(env[:global_config].berkshelf.berksfile_path)
      warn_disabled_but_berksfile_exists(env)
    end

    return @app.call(env)
  end

  env[:berkshelf].berksfile = Berkshelf::Berksfile.from_file(env[:global_config].berkshelf.berksfile_path)

  if chef_solo?(env)
    install(env)
  end

  @app.call(env)
rescue Berkshelf::BerkshelfError => e
  raise Berkshelf::VagrantWrapperError.new(e)
end