Product: Capistrano - Automate Remote Tasks Via SSH

Update: Deployment with Capistrano by Charles Max Wood. Nice simple step-by-step for using Capistrano for deployment.
From their website:
Simply put, Capistrano is a tool for automating tasks on one or more remote servers. It executes commands in parallel on all targeted machines, and provides a mechanism for rolling back changes across multiple machines. It is ideal for anyone doing any kind of system administration, either professionally or incidentally.
* Great for automating tasks via SSH on remote servers, like software installation, application deployment, configuration management, ad hoc server monitoring, and more.
* Ideal for system administrators, whether professional or incidental.
* Easy to customize. Its configuration files use the Ruby programming language syntax, but you don't need to know Ruby to do most things with Capistrano.
* Easy to extend. Capistrano is written in the Ruby programming language, and may be extended easily by writing additional Ruby modules.
One of the original use cases for Capistrano was for deploying web applications. (This is still by far its most popular use case.) In order to make deploying these applications reliable, Capistrano needed to ensure that if something went wrong during the deployment, changes made to that point on the other servers could be rolled back, leaving each server in its original state.
If you ever need similar functionality in your own recipes, you can introduce a transaction:
task :deploy do
transaction do
update_code
symlink
end
end
task :update_code do
on_rollback { run "rm -rf #{release_path}" }
source.checkout(release_path)
end
task :symlink do
on_rollback { run "rm #{current_path}; ln -s #{previous_release} #{current_path}" }
run "rm #{current_path}; ln -s #{release_path} #{current_path}"
end
The first task, “deploy” wraps a transaction around its invocations of “update_code” and “symlink”. If an error happens within that transaction, the “on_rollback” handlers that have been declared are all executed, in reverse order.
This does mean that transactions aren’t magical. They don’t really automatically track and revert your changes. You need to do that yourself, and register on_rollback handlers appropriately, that take the necessary steps to undo the changes that the task has made. Still, even as lo-fi as Capistrano transactions are, they can be quite powerful when used properly.
From the Ruby on Rail manual:
Ultimately, Capistrano is a utility that can execute commands in parallel on multiple servers. It allows you to define tasks, which can include commands that are executed on the servers. You can also define roles for your servers, and then specify that certain tasks apply only to certain roles.
Capistrano is very configurable. The default configuration includes a set of basic tasks applicable to web deployment. (More on these tasks will be said later.)
Capistrano can do just about anything you can write shell script for. You just run those snippets of shell script on remote servers, possibly interacting with them based on their output. You can also upload files, and Capistrano includes some basic templating to allow you to dynamically create and deploy things like maintenance screens, configuration files, shell scripts, and more.
Related Articles





Reader Comments (2)
We use Capistrano extensively and primarily for the deployment and administration of PHP Applications where I work. It's been a tremendous help and we are able to quickly and consistently deploy complex multi-server sites in just a very few minutes with nothing more than three little words. Life before capistrano was much less fun for everyone and "cap rollback" is priceless for those oh s**t moments that seem to come up from time to time.
Cap 2.2.0 just got put out as well! Check out the new features.
http://groups.google.com/group/capistrano/browse_thread/thread/7ddac41de0592604
We have started to experiment with using capistrano to build our servers as well. I'm confident we'll have server deployments and builds down to a few minutes very soon as well using this excellent tool.
-Kent
Expressed all that info elaborately!
-----
http://underwaterseaplants.awardspace.com">sea plants
http://underwaterseaplants.awardspace.com/seagrapes.htm">sea grapes...http://underwaterseaplants.awardspace.com/plantroots.htm">plant roots