The run() command does not return success/failure. If it succeeds, it
returns. If it fails, it raises an exception.
To get the result of a command, you can use the capture() method:
http://wiki.capify.org/article/Capture
Note, though, that it runs the command only on a single host, so if you
want the output of multiple hosts, you'll need to use run() and give it
a block, so you can process the output yourself:
http://wiki.capify.org/article/Run
To answer your question about one-command-per-task, you can definitely
put as many commands in as you want. As for conditionally running
commands, you can do that in a few ways.
First, if you have really complex conditional logic, it might be best to
put the entire task in a shell and run the script from capistrano, a la:
task :do_something_hard do
run "my_script"
end
And my_script could either be shell script, or ruby, whichever floats
your boat.
Alternatively, for simpler needs, you can use shell if conditions
directly in capistrano:
run "if [ some_command ]; then other_command; else last_command; fi"
However, it's really not feasible to test the run() command itself (via
exception rescuing, etc.) because just because the command fails on one
server, doesn't mean it failed on all servers. Consider:
begin
run "something that might fail"
rescue Exception
run "something assuming the first failed"
end
If you run this task against more than one server, then it could be that
one server fails while the others succeed. In that event, an exception
would still be raised, resulting in the second run() being executed
against ALL SERVERS, not just the one(s) that failed.
Hope that makes sense,
Jamis