Ben, It sounds like you want the :on_error => :continue option for the task:
task :add_user, :on_error => :continue do
# ...
end
With that option set, connection errors and runtime errors will be
dutifully logged, but capistrano will not abort.
- Jamis On May 20, 2008, at 5:18 AM, Ben Lavender wrote:
Hi all,
I'm looking into using Capistrano for system administration as opposed
to deployment. I'm having some trouble handling errors.
As an example, I'm trying to write an add_user task. Easy enough:
task :add_user do
run "useradd #{username}"
end
The problem is in handling error conditions. For example, right now
I'm trying to add an administrator to a number of machines, but one of
them is currently offline for maintenance. When I run my task, I get:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh/service/forward/driver.rb:
126:in `direct_channel': could not open direct channel for
65530:1425-6:22 (2, No route to host) (Net::SSH::Exception)
The other machines work fine, and if I use a subset of roles that does
not include the affected machine, it's all fine. However, I'd like to
be able to specify that this task continue if one of a subset of
machines is unavailable (since I can run it again, harmlessly,
later). Ideally, I'd like to be able to specify the action to be
taken for a given kind of exception raised for a task. For this one,
for example, I might send an email to my trouble ticket system that
useradd failed on a given machine, reminding me to do it later.
I dug around in cli/execute, and it seems like error handling is done
rather statically, by handle_error. Is there an accepted way to do
this before I start overwriting that method?
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---
smime.p7s
Description: S/MIME cryptographic signature
