Class: VagrantPlugins::Berkshelf::Action::Share

Inherits:
Base
  • Object
show all
Defined in:
lib/vagrant-berkshelf/action/share.rb

Instance Method Summary collapse

Methods inherited from Base

clean, #initialize, provision, setup

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

This class inherits a constructor from VagrantPlugins::Berkshelf::Action::Base

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vagrant-berkshelf/action/share.rb', line 7

def call(env)
  if !berkshelf_enabled?(env)
    @logger.info "Berkshelf disabled, skipping"
    return @app.call(env)
  end

  if !chef_solo?(env) && !chef_zero?(env)
    @logger.info "Provisioner does not need a share"
    return @app.call(env)
  end

  env[:machine].ui.info "Sharing cookbooks with VM"

  list = provisioners(:chef_solo, env) + provisioners(:chef_zero, env)
  list.each do |chef|
    value = chef.config.send(:prepare_folders_config, env[:berkshelf].shelf)

    @logger.debug "Setting cookbooks_path = #{value.inspect}"
    chef.config.cookbooks_path = value + Array(chef.config.cookbooks_path)
  end

  @app.call(env)
end