Class: Chef::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/monkey_patches/chef/client.rb

Instance Method Summary collapse

Instance Method Details

#run_berksObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/monkey_patches/chef/client.rb', line 39

def run_berks
  berksfile = Berkshelf::Berksfile.from_file(Chef::Config[:berksfile])
  opts= {path:Chef::Config[:cookbook_path].first}
  berksfile.install(opts)
  Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, Chef::Config[:cookbook_path]) }
  cl = Chef::CookbookLoader.new(Chef::Config[:cookbook_path])
  cl.load_cookbooks
  cookbook_collection = Chef::CookbookCollection.new(cl)
  cookbook_collection
end

#setup_run_contextObject



11
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
37
# File 'lib/monkey_patches/chef/client.rb', line 11

def setup_run_context
  if Chef::Config[:solo]
    if Chef::Config[:use_berkshelf]
      cookbook_collection = run_berks
    else
      Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, Chef::Config[:cookbook_path]) }
      cl = Chef::CookbookLoader.new(Chef::Config[:cookbook_path])
      cl.load_cookbooks
      cookbook_collection = Chef::CookbookCollection.new(cl)
    end
    run_context = Chef::RunContext.new(node, cookbook_collection, @events)
  else
    if Chef::Config[:use_berkshelf]
      cookbook_collection = run_berks
    else
      Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::RemoteFileVendor.new(manifest, rest) }
      cookbook_hash = sync_cookbooks
      cookbook_collection = Chef::CookbookCollection.new(cookbook_hash)
    end  
    run_context = Chef::RunContext.new(node, cookbook_collection, @events)
  end
  run_status.run_context = run_context

  run_context.load(@run_list_expansion)
  assert_cookbook_path_not_empty(run_context)
  run_context
end