Class: VagrantPlugins::Berkshelf::Action::Base

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/vagrant-berkshelf/action/base.rb

Direct Known Subclasses

Check, Clean, Install, Load, Save, Share, Upload

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#berks, #berks_bin, #berkshelf_enabled?, #chef_client?, #chef_solo?, #chef_zero?, #datafile_path, #provision_enabled?, #provisioners, #with_clean_env

Constructor Details

#initialize(app, env) ⇒ Base

Returns a new instance of Base.



40
41
42
43
44
45
# File 'lib/vagrant-berkshelf/action/base.rb', line 40

def initialize(app, env)
  @app = app

  klass = self.class.name.downcase.split('::').last
  @logger = Log4r::Logger.new("vagrant::berkshelf::#{klass}")
end

Class Method Details

.cleanObject

Cleanup any shared folders before destroying the VM.



10
11
12
13
14
15
# File 'lib/vagrant-berkshelf/action/base.rb', line 10

def self.clean
  Vagrant::Action::Builder.new.tap do |b|
    b.use setup
    b.use Action::Clean
  end
end

.provisionObject

Provision the VM, calling setup, install, and upload.



18
19
20
21
22
23
24
# File 'lib/vagrant-berkshelf/action/base.rb', line 18

def self.provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use Action::Save
    b.use Action::Install
    b.use Action::Upload
  end
end

.setupObject

Setup all the required middlemare, including checking for the presence of Berkshelf, checking for the proper version of Berkshelf, and loading the datafile from disk.



29
30
31
32
33
34
35
36
# File 'lib/vagrant-berkshelf/action/base.rb', line 29

def self.setup
  Vagrant::Action::Builder.new.tap do |b|
    b.use Action::Check
    b.use Vagrant::Action::Builtin::EnvSet, berkshelf: Env.new
    b.use Action::Load
    b.use Action::Share
  end
end