I am trying to use Capistrano to deploy to two different roles, using Bundler on both, 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With