Class: Kitchen::Provisioner::ChefZero

Inherits:
ChefBase show all
Defined in:
lib/kitchen/provisioner/chef_zero.rb

Overview

Chef Zero provisioner.

Author:

Instance Attribute Summary

Attributes included from Configurable

#instance

Instance Method Summary collapse

Methods inherited from ChefBase

#doctor, #init_command, #initialize, #install_command

Methods inherited from Base

#call, #cleanup_sandbox, #doctor, #init_command, #initialize, #install_command, kitchen_provisioner_api_version, #sandbox_path

Methods included from Logging

#banner, #debug, #error, #fatal, #info, #warn

Methods included from Configurable

#[], #bourne_shell?, #calculate_path, #config_keys, #diagnose, #diagnose_plugin, #finalize_config!, included, #name, #powershell_shell?, #remote_path_join, #unix_os?, #verify_dependencies, #windows_os?

Constructor Details

This class inherits a constructor from Kitchen::Provisioner::ChefBase

Instance Method Details

#create_sandboxObject

Creates a temporary directory on the local workstation into which provisioner related files and directories can be copied or created. The contents of this directory will be copied over to the instance before invoking the provisioner's run command. After this method completes, it is expected that the contents of the sandbox is complete and ready for copy to the remote instance.

Note: any subclasses would be well advised to call super first when overriding this method, for example:

Examples:

overriding #create_sandbox


class MyProvisioner < Kitchen::Provisioner::Base
  def create_sandbox
    super
    # any further file copies, preparations, etc.
  end
end


49
50
51
52
53
54
# File 'lib/kitchen/provisioner/chef_zero.rb', line 49

def create_sandbox
  super
  prepare_chef_client_zero_rb
  prepare_validation_pem
  prepare_config_rb
end

#prepare_commandString

Generates a command string which will perform any commands or configuration required just before the main provisioner run command but after the sandbox has been transferred to the instance. If no work is required, then nil will be returned.

Returns:

  • (String)

    a command string



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/kitchen/provisioner/chef_zero.rb', line 57

def prepare_command
  return if modern?

  gem_bin = remote_path_join(config[:ruby_bindir], "gem")
            .tap { |path| path.concat(".bat") if windows_os? }
  vars = [
    chef_client_zero_env,
    shell_var("gem", sudo(gem_bin)),
  ].join("\n").concat("\n")

  prefix_command(shell_code_from_file(vars, "chef_zero_prepare_command_legacy"))
end

#run_commandString

Generates a command string which will invoke the main provisioner command on the prepared instance. If no work is required, then nil will be returned.

Returns:

  • (String)

    a command string



71
72
73
74
75
# File 'lib/kitchen/provisioner/chef_zero.rb', line 71

def run_command
  cmd = modern? ? local_mode_command : shim_command

  chef_cmd(cmd)
end