class Spiceweasel::Execute

executes the knife commands from parsing manifests

Public Class Methods

new(commands) click to toggle source

run the commands passed in

# File lib/spiceweasel/execute.rb, line 26
def initialize(commands)
  # for now we're shelling out
  commands.each do | cmd |
    Spiceweasel::Log.debug("Command will timeout after #{Spiceweasel::Config[:cmd_timeout]} seconds.")
    knife = Mixlib::ShellOut.new(cmd.command, cmd.shellout_opts.merge(live_stream: STDOUT, timeout: Spiceweasel::Config[:timeout].to_i))
    # check for parallel? and eventually use threads
    knife.run_command
    puts knife.stderr
    Spiceweasel::Log.debug(cmd)
    Spiceweasel::Log.debug(knife.stdout)
    Spiceweasel::Log.fatal(knife.stderr) unless knife.stderr.empty?
    find.error! unless cmd.allow_failure?
  end
end