Sha256: f5246a32aa1ad9e6ca3f626980f3935e2be095e9e8df94a8bd0242b2a778562c

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'soloist'

def fileify(contents)
  file = Tempfile.new("soloist")
  file << contents
  file.flush
  file
end

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)

# 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

solo_rb = fileify(config_generator.solo_rb)
metadata_json = fileify(config_generator.json_file)

env_vars = ["PATH=#{ENV['PATH']}"]
%w{BUNDLE_PATH GEM_HOME GEM_PATH RAILS_ENV RACK_ENV}.each do |v|
  env_vars << "#{v}=#{ENV[v]}" unless ENV[v].nil?
end

command = "sudo bash -c '#{env_vars.join(' ')} chef-solo -j #{metadata_json.path} -c #{solo_rb.path} -l #{log_level}'"

puts "running chef: " + command
system(command) || exit(1)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
soloist-0.0.6 bin/soloist
soloist-0.0.5 bin/soloist