2

I have a Drupal site that I build locally and pull to the staging and production servers using git. Normally, my workflow is to run drush cex to export the configs from local, and drush deploy to deploy my changes on the staging and production servers.

So far, my module config has been the same across all environments and this has been working great, however I am now using the SAML Auth module which will not have the same configuration in the staging and production environment. For example, the entity id, key, and cert change, as well as a few other minor details. The problem is when I run drush cex locally, the local config is later deployed to staging & production, overwriting this module.

Is there a way to tell Drush to ignore this module when exporting and importing configs, or to maintain separate configs for certain modules depending on which environment the site is on?

2 Answers 2

4

If these are only minor details you can do this without additional modules by overriding config values in settings.php directly.

This example changes the number of items displayed on the front page if, hypothetically, locally it should be different than in production:

Local settings.php:

$config['views.view.frontpage']['display']['default']['display_options']['pager']['options']['items_per_page'] = 10;

You can override almost any config value you see in the exported config. The overrides don't get deployed. In this example, you still see the original value when editing the View and you can save a different value for deployment. The same would be the case for the contrib module you've mentioned. You manage the production config in UI and override the local auth parameters in settings.php.

3

The Configuration Split module was created for exactly the scenario you describe:

This module allows to define sets of configuration that will get exported to separate directories when exporting, and get merged together when importing. It is possible to define in settings.php which of these sets should be active and considered for the export and import.

All you need to do is set up the relevant splits, then add code to settings.php which enables/disables those splits in the appropriate environments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.