Closed masa-ekohe closed 4 years ago
Hi, good question.
In Capistrano, set
is global, so calling it will affect Capistrano regardless of the role context where it is called. To my knowledge there is no way to accomplish per-host or per-role settings in Capistrano.
So the short answer is that Capistrano wasn't really designed to do what you are asking.
Your best bet might be to rewrite the bundler:install
task to get the behavior you want.
Alternatively, you could set :bundle_without
to nil
and manage it via bundle config
instead. In other words, on role A run a task that does bundle config without ...
, and on role B run a different task that runs bundle config without ...
. That way you are configuring each role with a different set of Bundler config. When you later run bundle install
, it should respect that config.
Here are the Bundler docs on bundle config
: https://bundler.io/v2.0/man/bundle-config.1.html
Hope that helps!
@mattbrictson
Thank you. This is very helpful. I made it work by overriding bundler:install
as you suggested.
Alternatively, you could set :bundle_without to nil and manage it via bundle config instead. In other words, on role A run a task that does bundle config without ..., and on role B run a different task that runs bundle config without .... That way you are configuring each role with a different set of Bundler config. When you later run bundle install, it should respect that config.
I never thought about it. This is smart.
I don't want to install a certain gem in the specific hosts. How could I achieve that?
versions: Ruby 2.5.3 Capistrano 3.7.1 Capistrano-bundler 1.2.0
I tried the code below to specify
without
option based on role but it seems to be specified for the other hosts too.Gemfile.rb
deploy.rb
results(bundle --without development test foo is executed for the other host too)