Is there a way to refer "not primary" servers in cap v3?

40 views
Skip to first unread message

Carlos Peñas

unread,
Mar 3, 2015, 7:30:05 AM3/3/15
to capis...@googlegroups.com
on capistrano V3 there's:

roles(:role) For all servers
and
primary(:role) for the first server in a role

Is there a way to refer "the servers which aren't primary" in a similar way? Or I am forced to use server properties?

Lee Hambley

unread,
Mar 3, 2015, 8:28:49 AM3/3/15
to Capistrano
try (roles(:role) - primary(:role)), they are Ruby enumerables, so it might work :)

--
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/ae113948-8f27-41f4-a2db-d6f5754af8cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carlos Peñas

unread,
Mar 7, 2015, 3:49:56 PM3/7/15
to capis...@googlegroups.com
Almost!

Seems that primary returns a Capistrano::Configuration::Server and not an enumerable (at least in 3.4.0) so that hack do not work. But it helped me to reach

on (roles(:app) - [primary(:app)]) do

which work as expected

see:

[4] pry(main)> primary(:app)
=> #<Capistrano::Configuration::Server:0x007f2a421d3ee0
 
@hostname="127.0.0.1",
 
@port=nil,
 
@properties=#<Capistrano::Configuration::Server::Properties:0x007f2a421d3a58 @properties={}, @roles=#<Set: {:app}>>,
 
@user="carlos">
[5] pry(main)> roles(:app) - [primary(:app)]

=> [#<Capistrano::Configuration::Server:0x007f2a421d38f0
 
@hostname="127.0.1.1",
 
@port=nil,
 
@properties=#<Capistrano::Configuration::Server::Properties:0x007f2a421d35a8 @properties={}, @roles=#<Set: {:app}>>,
 
@user="carlos">,
 
#<Capistrano::Configuration::Server:0x007f2a421d3440
 
@hostname="127.1.0.1",
 
@port=nil,
 
@properties=#<Capistrano::Configuration::Server::Properties:0x007f2a421d30f8 @properties={}, @roles=#<Set: {:app}>>,
 
@user="carlos">,
 
#<Capistrano::Configuration::Server:0x007f2a421d2f40
 
@hostname="127.1.1.1",
 
@port=nil,
 
@properties=#<Capistrano::Configuration::Server::Properties:0x007f2a421d2bd0 @properties={}, @roles=#<Set: {:app}>>,
 
@user="carlos">]

Reply all
Reply to author
Forward
0 new messages