Thinking about this a little bit more, it would work, but certainly wouldn't make for the DRYest code.
For example, I'd often like to use deploy:update, but have it restricted to certain roles. Seems like I'd have to define a new function which duplicates the standard cap deploy:update code... :( I could imagine something else like: roles :foo, :bar do deploy.update end ...which would override any roles defined at the task definition level and run it only on :foo, :bar. Thoughts? Ian On Sat, Jun 28, 2008 at 8:14 AM, Ian Sefferman <[EMAIL PROTECTED]> wrote: > Ah, makes sense. Neat workaround. Thanks, Jamis! > > Ian > > On Sat, Jun 28, 2008 at 7:25 AM, Jamis Buck <[EMAIL PROTECTED]> wrote: >> >> If you declare it as a function, rather than a task, it'll use the >> caller's scope, instead of its own scope. E.g.: >> >> def echo_bar >> run "echo bar" >> end >> >> task :foo, :roles => :foo do >> run "echo foo" >> echo_bar >> end >> >> task :bar do >> echo_bar >> end >> >> Note that you can't do "cap echo_bar", because echo_bar is not a task, >> so I've kept the :bar task and had it just call the method. That lets >> you call "cap bar", just as before, and have it work as it did before. >> >> - Jamis >> >> On Jun 28, 2008, at 12:12 AM, Ian Sefferman wrote: >> >>> >>> Hi, >>> I've noticed the following behavior: >>> >>> role :foo, "foo" >>> role :bar, "bar" >>> namespace :my_service do >>> task :foo, :roles => :foo do >>> run "echo \"foo\n\"" >>> bar >>> end >>> >>> task :bar do >>> run "echo \"bar\n\"" >>> end >>> end >>> >>> If I run foo, bar will be ran for both the :foo and :bar role, which I >>> wouldn't expect. I would expect that the task which is calling another >>> task will be restricting the other task. >>> >>> I ask because one thing I'd like to do is have a few roles and have >>> some, but not all, of the roles update their code (deploy.update), but >>> currently this would always update it for all roles. >>> >>> Is there any workaround for this? Am I missing something obvious? >>> >>> Thanks, >>> Ian >>> >>> >>> -- >>> Ian Sefferman >>> http://www.openomy.com | http://www.iseff.com >>> >>> > >> >> >> >> >> > > > > -- > Ian Sefferman > http://www.openomy.com | http://www.iseff.com > -- Ian Sefferman http://www.openomy.com | http://www.iseff.com --~--~---------~--~----~------------~-------~--~----~ To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/capistrano -~----------~----~----~----~------~----~------~--~---
