Class: Kitchen::Provisioner::Itamae

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/provisioner/itamae.rb

Instance Method Summary collapse

Instance Method Details

#create_sandboxObject



30
31
32
33
# File 'lib/kitchen/provisioner/itamae.rb', line 30

def create_sandbox
  super
  FileUtils.cp_r(Dir.glob("#{config[:itamae_root]}/*"), sandbox_path)
end

#init_commandObject



36
37
38
39
40
41
# File 'lib/kitchen/provisioner/itamae.rb', line 36

def init_command
  cmd = []
  cmd << "#{sudo("rm")} -rf #{config[:root_path]} ; mkdir -p #{config[:root_path]}"
  debug("Cleanup Kitchen Root")
  Util.wrap_command(cmd.join("\n"))
end

#install_commandObject



78
79
80
81
82
# File 'lib/kitchen/provisioner/itamae.rb', line 78

def install_command
  return unless config[:parasite_chef_omnibus]
  lines = [Util.shell_helpers, download_helpers, chef_helpers, chef_install_function, itamae_install_function]
  Util.wrap_command(lines.join("\n"))
end

#prepare_commandObject



44
45
46
47
48
49
50
51
52
# File 'lib/kitchen/provisioner/itamae.rb', line 44

def prepare_command
  return nil unless config[:use_bundler]
  debug("Prepare Bundler")
  cmd = ["cd #{config[:root_path]};"]
  cmd << "if [ -f Gemfile ] ;then"
  cmd << "#{sudo("/opt/chef/embedded/bin/bundle")} install --binstubs"
  cmd << "fi"
  Util.wrap_command(cmd.join("\n"))
end

#run_commandObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/kitchen/provisioner/itamae.rb', line 55

def run_command
  debug(JSON.pretty_generate(config))
  lines = config[:run_list].map do |recipe|
    cmd = ["cd #{config[:root_path]} ;"]
    if config[:use_bundler]
      cmd << sudo(File.join(config[:chef_omnibus_bin_dir], 'ruby'))
      cmd << './bin/itamae'
    else
      cmd << sudo('/opt/chef/bin/itamae')
    end
    cmd << 'local'
    cmd << '--ohai' if config[:with_ohai]
    cmd << config[:itamae_option]
    cmd << "-j #{config[:node_json]}" if config[:node_json]
    cmd << recipe
    cmd.join(" ")
  end
  debug(lines.join("\n"))
  Util.wrap_command(lines.join("\n"))
end