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 inherited from Base

#instance

Instance Method Summary collapse

Methods inherited from ChefBase

#calculate_path, #cleanup_sandbox, #init_command, #install_command, #instance=

Methods inherited from Base

#[], #cleanup_sandbox, #config_keys, default_config, defaults, #diagnose, #init_command, #initialize, #install_command, #name, super_defaults

Constructor Details

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

Instance Method Details

#create_sandboxObject



33
34
35
36
37
38
39
# File 'lib/kitchen/provisioner/chef_zero.rb', line 33

def create_sandbox
  create_chef_sandbox do
    prepare_chef_client_zero_rb
    prepare_validation_pem
    prepare_client_rb
  end
end

#prepare_commandObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/kitchen/provisioner/chef_zero.rb', line 41

def prepare_command
  return if local_mode_supported?

  ruby_bin = config[:ruby_bindir]

  # use Bourne (/bin/sh) as Bash does not exist on all Unix flavors
  #
  # * we are installing latest chef in order to get chef-zero and
  #   Chef::ChefFS only. The version of Chef that gets run will be
  #   the installed omnibus package. Yep, this is funky :)
  "    sh -c '\n    \#{chef_client_zero_env(:export)}\n    if ! \#{sudo(\"\#{ruby_bin}/gem\")} list chef-zero -i >/dev/null; then\n      echo \">>>>>> Attempting to use chef-zero with old version of Chef\"\n      echo \"-----> Installing chef zero dependencies\"\n      \#{sudo(\"\#{ruby_bin}/gem\")} install chef --no-ri --no-rdoc --conservative\n    fi'\n  PREPARE\nend\n".gsub(/^ {10}/, '')

#run_commandObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/kitchen/provisioner/chef_zero.rb', line 62

def run_command
  args = [
    "--config #{config[:root_path]}/client.rb",
    "--json-attributes #{config[:root_path]}/dna.json",
    "--log_level #{config[:log_level]}"
  ]

  if local_mode_supported?
    ["#{sudo('chef-client')} -z"].concat(args).join(" ")
  else
    [
      chef_client_zero_env,
      sudo("#{config[:ruby_bindir]}/ruby"),
      "#{config[:root_path]}/chef-client-zero.rb"
    ].concat(args).join(" ")
  end
end