I am trying to use Capistrano to deploy to two different roles, using Bundler on both,开发者_如何学Python however the Bundler command and flags will be different. Is it possible to set variables that are specific to a role? Either something like:
set :bundle_flags, "--deployment --quiet", :role => "web"
or:
role :web do
set :bundler_cmd, "--deployment --quiet"
end
Neither of those two options work, of course. Is there a way to accomplish this, or something like it?
There is no way to have custom variable values per role.
You can instead use the multistage extension from capistrano-ext to have different stages for your two different roles.
If different stages doesn't make sense for your deployment, you could write your own bundle:install task and run different commands based on roles
run "bundle --deployment --quiet", :roles => :web
run "bundle --deployment", :roles => :app
As noted in the comment below, this approach, however, will raise errors if the role does not have a server defined. It will also run each command serially. To work around both those issues, use the parallel helper.
parallel do |session|
session.when 'in?(:web)', "bundle --deployment --quiet"
session.when 'in?(:app)', "bundle --deployment"
end
精彩评论