tasks do not cascade inheritance, so your shared_task will run on all
servers since that task isn't restricted to a role.

you can however define shared_task as a method instead of a task, and then
it will use the calling tasks scope.

ie:

def shared_task
  run "hostname"
end

and keep the rest the same.


On Fri, Nov 11, 2011 at 6:06 AM, hiroysato <hiroys...@gmail.com> wrote:

> Dear members.
>
> Is it possible to share one task from multiple roles??
>
> If I execute ``cap login_server'',
> I would like to execute shared_task on role of servers.
>
> But the folowing Capfile is executed login_server task on server and
> client.
>
> Sincerely.
>
>
> --------------------------------------------------------------------------------
> role :servers, "foo"
> role :clients, "bar"
>
> #
> # for server task
> #
> task :login_server, :roles => :servers do
>  set :variable_prameters, "for_server"
>  shared_task
> end
>
> #
> # for client task
> #
> task :login_client, :roles => :clients do
>  set :variable_prameters, "for_client"
>  shrared_task
> end
>
> #
> # shared_task
> #
> task :shared_task do
>    run "hostname"
> end
>
> --------------------------------------------------------------------------------
>
> --
> Hiroyuki Sato
>
> --
> * You received this message because you are subscribed to the Google
> Groups "Capistrano" group.
> * To post to this group, send email to capistrano@googlegroups.com
> * To unsubscribe from this group, send email to
> capistrano+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/capistrano?hl=en

-- 
* You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
* To post to this group, send email to capistrano@googlegroups.com
* To unsubscribe from this group, send email to 
capistrano+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/capistrano?hl=en

Reply via email to