Got it, thanks!
On Jan 21, 10:12 am, Jamis Buck <[email protected]> wrote:
> Yes, an array should work:
>
> :roles => defer { [:app,:web] }
>
> However, if you're prompting for the roles, then you'll need to parse
> the response string. Capistrano needs a Ruby array back. If it gets a
> string back (which is what ui.ask returns) it'll treat it as a single
> role name.
>
> Probably the simplest way to parse the input is to assume that whoever
> is entering the roles knows to enter Ruby syntax:
>
> :roles => defer { eval(Capistrano::CLI.ui.ask("...")) }
>
> It's not the most secure option, though, so only use it if you can
> always trust the operator.
>
> - Jamis
>
> On 1/21/09 10:08 AM, pete wrote:
>
> > Jamis,
>
> > Should you be able to specify multiple roles?
>
> > For example, when prompted, I'd like to give a list, like: m1,m2, or
> > [m1,m2], but none of these seem to work?
>
> > Thanks!
>
> > On Jan 17, 8:18 am, David Masover <[email protected]> wrote:
> >> Nicer than Proc.new, but I'm not sure it's better than, say, proc or
> >> lambda.
> >> That, and I seem to remember "defer" being used somewhere, for something
> >> else, though not in Cap.
>
> >> On Fri, Jan 16, 2009 at 4:58 PM, Jamis Buck <[email protected]> wrote:
>
> >>> Sorry I wasn't clear. The defer() method is an alias for Proc.new. So
> >>> you'd just do:
> >>> :roles => defer { Capistrano::CLI.ui.ask(...) }
> >>> Or, if you prefer:
> >>> :roles => Proc.new { Capistrano::CLI.ui.ask(...) }
> >>> Some might say that adding defer() was dumb on my part, but I think it
> >>> reads much nicer than Proc.new. So, choose your poison. :)
> >>> - Jamis
> >>> On 1/16/09 3:45 PM, pete wrote:
> >>>> Ok, I know it's possible, but I seem to be messing this up...
> >>>> Would it be like this?
> >>>> task :test_task, :roles => defer { Proc.new { Capistrano::CLI.ui.ask
> >>>> ("Please specify ENV: " )} } do
> >>>> run "echo hi"
> >>>> end
> >>>> On Jan 16, 2:38 pm, Jamis Buck <[email protected]> wrote:
> >>>>> Pete, yes you can pass a Proc object as the value of the :roles option,
> >>>>> and it will get evaluated when the task is considered for execution. The
> >>>>> proc should return an array of role names.
> >>>>> Capistrano provides a defer() helper to make declaring the procs a bit
> >>>>> easier to read:
> >>>>> task :generic_task, :roles => defer { compute_role_names_here } do
> >>>>> # ...
> >>>>> end
> >>>>> - Jamis
> >>>>> On 1/16/09 1:48 PM, pete wrote:
> >>>>>> Hello-
> >>>>>> Is it possible to dynamically set roles for a specific task?
> >>>>>> For example, I want to create some generic tasks, along with groups of
> >>>>>> servers I use, and I wan tto be able to execute these commands on
> >>>>>> different groups, without having to duplicate code.
> >>>>>> role :group1, m1, m2, m3
> >>>>>> role :group2, m4, m5, m6
> >>>>>> task :generic_task, :roles => [some passed in variable] do
> >>>>>> run "echo hi"
> >>>>>> end
> >>>>>> Is something like this possible? I have tried a couple options, none
> >>>>>> of which worked.
> >>>>>> Thanks!
>
>
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---