bin/soloist in soloist-0.0.8 vs bin/soloist in soloist-0.9.0

- old
+ new

@@ -1,41 +1,22 @@ #!/usr/bin/env ruby -require 'rubygems' -require 'soloist' +require File.join(File.dirname(__FILE__), '..', 'lib', 'soloist') -def fileify(contents) - file = Tempfile.new("soloist") - file << contents - file.flush - file -end +include Soloist::Util -def walk_up_and_find_file(filenames) - pwd = FileUtils.pwd - file = nil - path_to_file = "" - while !file && FileUtils.pwd != '/' - file = filenames.detect { |f| Dir.glob("*").include?(f) } - FileUtils.cd("..") - path_to_file << "../" unless file - end - FileUtils.cd(pwd) - file_contents = File.read(path_to_file + file) if file - [file_contents, path_to_file] -end - log_level = ENV['LOG_LEVEL'] || "info" -soloistrc_contents, soloistrc_path = walk_up_and_find_file(["soloistrc"]) -config_generator = ChefConfigGenerator.new(soloistrc_contents, soloistrc_path) +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) -# if ARGV.length >= 1 -# json_config = JSON.parse(File.read(json_file)) -# json_config["recipes"] = ARGV -# json_file = "/tmp/#{File.basename(json_file)}" -# puts "OVERRIDING RECIPES: running [#{json_config["recipes"].join(", ")}]. Temp json config file: #{json_file}" -# File.open(json_file, "w+"){|f| f<<JSON.pretty_generate(json_config) } -# end +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] + raise "requested recipe '#{requested_recipe}' not in soloistrc or soloistrc_local" unless config_generator.recipes.include?(requested_recipe) + config_generator.recipes = [requested_recipe] +end solo_rb = fileify(config_generator.solo_rb) metadata_json = fileify(config_generator.json_file) command = "sudo bash -c '#{config_generator.preserved_environment_variables_string} chef-solo -j #{metadata_json.path} -c #{solo_rb.path} -l #{log_level}'" \ No newline at end of file