Skip to content

Instantly share code, notes, and snippets.

@retr0h
Created November 25, 2009 06:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save retr0h/242526 to your computer and use it in GitHub Desktop.
Save retr0h/242526 to your computer and use it in GitHub Desktop.
### 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