Class: Kitchen::Provisioner::ChefZeroCapture

Inherits:
ChefZero
  • Object
show all
Defined in:
lib/kitchen/provisioner/chef_zero_capture.rb

Overview

chef-zero provisioner intended for use with ‘chef capture`.

This provisioner does not do any cookbook dependency resolution and will not pull in external cookbooks. All cookbooks or cookbook artifacts + policy data as captured from the live node and are expected to be available for chef-zero to provide to the client.

Instance Method Summary collapse

Instance Method Details

#create_sandboxObject



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/kitchen/provisioner/chef_zero_capture.rb', line 59

def create_sandbox
  # We have to invoke the the true Base create_sandbox because it does setup that
  # we want. However, we do not want to invoke the create_sandbox inherited from
  # ChefZero/ChefBase - those will create and populate a ChefCommonSandbox instead
  # of a ChefZeroCaptureSandbox.
  m = Base.instance_method(:create_sandbox).bind(self)
  m.call

  # These behaviors from super we _do_ want, so we need to copy them here.
  prepare_validation_pem
  prepare_config_rb
  ChefZeroCaptureSandbox.new(config, sandbox_path, instance).populate
end

#default_config_rbObject

Overriding the private ProviderChefZero#default_config_rb so that we can add additional configuration required for chef-zero to be able to locate our policies/, policy groups, and cookbook artifacts at run-time.



77
78
79
80
81
82
83
84
85
# File 'lib/kitchen/provisioner/chef_zero_capture.rb', line 77

def default_config_rb
  cfg = super
  # Need to tell chef-zero about our additional config.
  root = config[:root_path].gsub("$env:TEMP", "\#{ENV['TEMP']\}")
  cfg[:policies_path] = remote_path_join(root, config[:policies_path])
  cfg[:policy_groups_path] = remote_path_join(root, config[:policy_groups_path])
  cfg[:cookbook_artifacts_path] = remote_path_join(root, config[:cookbook_artifacts_path])
  cfg
end

#load_needed_dependencies!Object

This will load policyfile/berkshelf. We don’t want either - the client resolves all dependencies from chef-zero, exactly as prepped in the captured repository.



57
# File 'lib/kitchen/provisioner/chef_zero_capture.rb', line 57

def load_needed_dependencies!; end