17.
task :deploy do
transaction do
try_this
then_do_that
end
end
task :try_this do
on_rollback { run quot;do_cleanupquot; }
#...
end
task :then_do_that do
on_rollback { run quot;do_super_cleanupquot; }
#...
end

20.
before :deploy, :run_tests
after quot;deploy:update_codequot;, :link_database_yml
task :run_tests do
system quot;rakequot; or abort quot;tests failedquot;
end
task :link_database_yml do
run quot;ln -s #{release_path}/config/database.yml #{shared_path}/database.ymlquot;
end