Is there something like "role aliases" in cap 3?

48 views
Skip to first unread message

Carlos Peñas

unread,
Sep 12, 2014, 7:34:40 AM9/12/14
to capis...@googlegroups.com
Hi!


Is there a way to say in capistrano

"Role :foo is an alias to role :bar"

So i could use on roles(:bar) do and get te tasks executed for servers matching role :foo

I'm looking for this because sometimes I create extensions which deals with too specific roles. For example if I create an extension to deal with varnish I will write his tasks with"varnish" role but instead of rewrite all the hosts to include :varnish role I need a way to say ":varnish role affects servers with :web role"

Is it possible?

Lee Hambley

unread,
Sep 12, 2014, 9:06:08 AM9/12/14
to capistrano
Sorry, no, but you can copy the list, using the ruby API. Roles returns a simple Ruby list, so you can add host properties and then just create an array type (enumerable) list of any filtered (reduced, collected, etc) list you need. The roles() function does exactly the same, looking in the configuration namespace for any hosts with a properties.roles[] including the argument passed to roles()

I hope that helps.

--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/22d08ce3-b486-4c1b-a43e-80ab575a1d7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carlos Peñas

unread,
Sep 29, 2014, 8:40:23 PM9/29/14
to capis...@googlegroups.com


On Friday, 12 September 2014 15:06:08 UTC+2, Lee Hambley wrote:
Sorry, no, but you can copy the list, using the ruby API. Roles returns a simple Ruby list, so you can add host properties and then just create an array type (enumerable) list of any filtered (reduced, collected, etc) list you need.

Baaad, well I been playing a bit with pry sto(m)ping in the middle of a "cap" and I found that, when servers are defined, I can simply `server.add_role(:my_shiny_new_role)` with each one of the objects that a call to 'roles()' yield, and for then on, that servers will carry the new role with pride. 

Perhaps I could alter the DSL to add a new command that does just that (from now I had only success inside a task) I'll keep trying if life does not come in the way.



I hope that helps.

Thanks anyway
 
Reply all
Reply to author
Forward
0 new messages