class Kitchen::Provisioner::LocalShell

LocalShell Provisoner for Kitchen. This provisoner just execute shell command from local. This provisioner is made in reference to Shell-Verifier

@author Masashi Terui (<marcy9114@gmail.com>)

Public Instance Methods

call(state) click to toggle source

(see Base#call)

# File lib/kitchen/provisioner/local_shell.rb, line 41
def call(state)
  debug("[#{name}] Provison on instance=#{instance} with state=#{state}")
  sleep_if_set
  merge_state_to_env(state)
  shellout
  debug("[#{name}] Provison completed.")
end

Private Instance Methods

merge_state_to_env(state) click to toggle source
# File lib/kitchen/provisioner/local_shell.rb, line 73
def merge_state_to_env(state)
  env_state = { :environment => {} }
  env_state[:environment]["KITCHEN_INSTANCE"] = instance.name
  env_state[:environment]["KITCHEN_PLATFORM"] = instance.platform.name
  env_state[:environment]["KITCHEN_SUITE"] = instance.suite.name
  state.each_pair do |key, value|
    env_state[:environment]["KITCHEN_" + key.to_s.upcase] = value
  end
  config[:shellout_opts].merge!(env_state)
end
shellout() click to toggle source
# File lib/kitchen/provisioner/local_shell.rb, line 62
def shellout
  cmd = Mixlib::ShellOut.new(config[:command], config[:shellout_opts])
  cmd.live_stream = config[:live_stream]
  cmd.run_command
  begin
    cmd.error!
  rescue Mixlib::ShellOut::ShellCommandFailed
    raise ActionFailed, "Action #provision failed for #{instance.to_str}."
  end
end
sleep_if_set() click to toggle source

Sleep for a period of time, if a value is set in the config.

@api private

# File lib/kitchen/provisioner/local_shell.rb, line 54
def sleep_if_set
  sleep_sec = config[:sleep].to_i
  if sleep_sec > 0
    info("Sleep #{config[:sleep]} seconds...")
    sleep sleep_sec
  end
end