Module: Hibachi::ChefRunner

Included in:
Hibachi
Defined in:
lib/hibachi/chef_runner.rb

Instance Method Summary collapse

Instance Method Details

#run_chef(recipe, options = {}) ⇒ Object

Runs the local Chef::Solo client for the given recipe. Loads the configuration specified at ‘Hibachi.config.chef_json_path` as Chef JSON, running only the given recipe name as specified in the method call. Used by the model backend to run Chef when they are updated, so configuration stays up to date with the JSON configuration.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hibachi/chef_runner.rb', line 11

def run_chef recipe, options={}
  return true unless config.run_chef

  if options[:background]
    run_chef_in_bg(recipe) and return true
  else
    run "touch #{config.log_path}" and
    log "Running Chef for '#{recipe}' at '#{Time.now}'..." and
    chef "-r '#{recipe_name(recipe)}' -J #{config.chef_json_path}"
  end
end