#!/usr/bin/env ruby require File.join(File.dirname(__FILE__), '..', 'lib', 'soloist') include Soloist::Util log_level = ENV['LOG_LEVEL'] || "info" soloistrc_contents, soloistrc_path = walk_up_and_find_file(with_or_without_dot("soloistrc")) config_generator = Soloist::ChefConfigGenerator.new(YAML.load(soloistrc_contents), soloistrc_path) soloistrc_contents, soloistrc_path = walk_up_and_find_file(with_or_without_dot("soloistrc_local"), :required => false) config_generator.merge_config(YAML.load(soloistrc_contents), soloistrc_path) if soloistrc_contents if ARGV.length >= 1 requested_recipe = ARGV[0] config_generator.recipes = [requested_recipe] end solo_rb = fileify(config_generator.solo_rb) metadata_json = fileify(config_generator.json_file) system "sudo mkdir -p /var/chef/cache" unless File.directory?("/var/chef/cache") command = "sudo bash -c '#{config_generator.preserved_environment_variables_string} chef-solo -j #{metadata_json.path} -c #{solo_rb.path} -l #{log_level}'" puts "running chef: " + command system(command) || exit(1)