Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
### Rakefile
task :template do
require 'yaml'
require 'erb'
base = File.join(File.dirname(__FILE__), 'config')
source = File.join(base, 'dna.json.erb')
target = File.join(base, 'dna.json')
recipes = ENV['recipe'] || %w(packages users gems)
@to_run = recipes.collect {|r| %Q("#{r}")}.join(',')
t = ERB.new(File.read(source)).result(binding)
File.open(target, 'w') {|f| f.write(t)}
end
desc "Run chef-solo cookbook(s)."
task :solo => :template do
sh("chef-solo -l debug -c config/solo.rb -j config/dna.json")
end
### dna.json
{
"user":"root",
"packages":[],
"gems":[],
"users":[],
"recipes":[<%= @to_run %>]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment