Capistrano: Configure environment specific array attributes

Posted . Visible to the public.

Using Capistrano, we usually have some array configurations in the config/deploy.rb file, like set :linked_files, %w[config/database.yml], so in this case we don't have to manage the database configuration individually on every server.

In a specific case, one of our projects supports sign in by SAML, but not every deploy target has this feature activated. Here comes a nice handy Capistrano feature Show archive.org snapshot , which lets us modify the default configuration for individual environments, instead of copying the whole config and modify relevant parts:

# config/deploy.rb

# SAML is activated by default and disabled for specific environments, so we expect to have the SAML config as default.
set :linked_files, %w[config/database.yml config/saml.config.xml]
# config/deploy/custom_environment.rb

# Here we can opt out of the SAML feature by removing only the unwanted config file
remove :linked_files, 'config/saml_config.xml'
# It would also be possible to add options for individual environments
append :linked_files, 'config/custom_file.txt'
Last edit
Deleted user #7094
License
Source code in this card is licensed under the MIT License.
Posted to makandra dev (2024-07-12 06:52)