Created
November 23, 2010 18:48
-
-
Save thbar/712277 to your computer and use it in GitHub Desktop.
Authored by someone else (don't have the name) and tweaked by me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REMOTE_CHEF_PATH = "/etc/chef" | |
SSH_PORT = XXX | |
desc "Test your cookbooks and config files for syntax errors" | |
task :test do | |
Dir[ File.join(File.dirname(__FILE__), "**", "*.rb") ].each do |recipe| | |
sh %{ruby -c #{recipe}} do |ok, res| | |
raise "Syntax error in #{recipe}" if not ok | |
end | |
end | |
end | |
desc "Upload the latest copy of your cookbooks to remote server" | |
#task :upload => [:test] do | |
task :upload do | |
if !ENV["server"] | |
puts "You need to specify a server rake upload server=whatever.com" | |
exit 1 | |
end | |
puts "* Upload your cookbooks *" | |
sh "rsync -e 'ssh -p #{SSH_PORT}' -qrlP --delete --exclude '.*' #{File.dirname(__FILE__)}/ #{ENV['server']}:#{REMOTE_CHEF_PATH}" | |
end | |
desc "Run chef solo on the server" | |
task :cook => [:upload] do | |
if !ENV["server"] | |
puts "You need to specify a server 'rake cook server=whatever.com'" | |
exit 1 | |
end | |
puts "* Running chef solo on remote server *" | |
sh "ssh -p #{SSH_PORT} -t #{ENV['server']} \"cd #{REMOTE_CHEF_PATH}; sudo chef-solo -l info -c config/solo.rb -j config/chef.json \"" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment