Advanced Configuration Management in Drupal 8 — Leveling Up your Config Management Game

May 3, 2019 | Scott Weston
Advanced Configuration Management in Drupal 8 blog image

Off-the-shelf, Drupal configuration management is heavy-handed. Particularly if a website needs different configuration settings between environments. For example, it’s a good idea to have some debugging modules and all error reporting turned on in the development environment. But on production, these should all be turned off for performance and security. How can you manage per-environment configurations in Drupal and still maintain your sanity?

We’ve coined the term Advanced Configuration Management to apply to the purposeful use of Drupal Core Configuration Management, Configuration Split, Configuration Ignore, and Config Overrides in settings.php to achieve a sustainable approach to managing Drupal configuration across a site’s environments.

 

Last year, I wrote a post about configuration management which provides a framework for taming Drupal 8 configuration. Take a moment to read that post first, as this post will expand on that previous post and offer up some recommended tips and tricks!

Level Up Your Drupal 8 Configuration Management – Make Drupal Configuration Work the Way You Do!
By Scott Weston,
Senior Director, Drupal Engineering
· April 24, 2018

Document the Advanced Configuration Management plan

I use a spreadsheet to document what method will be used to manage a grouping of configuration. Using the acronym MISO helps to easily track how to implement these configurations. In the example below, the type/grouping of configuration are noted in the first column with the configuration management approach noted in the following columns for each environment.

Example Advanced Configuration Management per Environment

Item Dev Test Prod
robotstxt settings O O I
Devel Modules S  --  --
Blocks (used as content) I I I
Environment Indicator Colors O O O
DB Logging S S S
Caching  -- S S

*M = Core Config Management. Use core config management on all environments when the config is the same across all. If it’s not noted on the spreadsheet, it’s managed with core config.

*I = Config Ignore. Ignore the configuration on import so that items are not updated or reverted.

*S = Config Split. Modules and settings are enabled in the noted environments.

*O = Config Override. Specific items are hard-coded into the settings.php files $config array.

Use Advanced Config from the Start

Building out the Advanced Configuration Management plan from the beginning of the project will help ensure that it is implemented successfully. Working out any bugs with your plan early on will help when launch day approaches.

If you were to try to configure splits late in the build as launch approaches, you may run into unforeseen problems that dampen your efforts. If you do find yourself in this situation, start with complete splits (turning modules off/on) first, and use Config overrides for differences between environments.

One Split Per Environment

We’ve found the most success with having one split for each environment. This makes it easy to identify what split configurations apply to which environment. While you can have very granular splits, it can become tedious to manage and causes some unnecessary overhead in effort when making changes. 

If you do go the route of having more than one split enabled per environment, give careful consideration to your approach. One possible approach is to group modules and configurations into splits by ‘area’ or ‘concern’. For example, you could group all of your development/debugging modules into one split. Another split could turn on the UI modules. Using this approach, you could turn on groups of modules and configuration as needed.

Use the Chosen module

The Chosen module and jQuery plugin definitely help manage the Config Split configuration form. The form features a few multiple select fields. The options in these fields grow as the list of configurable items on your site grows. Chosen helps reign in these unwieldy form elements.

 

 If you don’t enable the Chosen module, you could experiences some unintended consequences. As web users (and developers), we’ve all see multi-select select form elements that are too long and cumbersome to deal with. If you don’t (or can’t) use chosen, remember to scroll through the select box and double-check that all of the desired items are selected before hitting save. 

The Future of Configuration Management

The Configuration Split module is a Drupal contributed module that is filling a need for many developers at this time. There are active discussions in the Drupal Core issue queue to bring this functionality into core. If or how this functionality will be brought into Core is an area to watch for future developments!

 

There are a number of valid approaches to configuration management on Drupal 8 sites. I offer this approach to Advanced Configuration Management as one way to achieve the needs for your site. 


Scott presented this at DrupalCon2019 as well as MidCamp. View his presentation from DrupalCon Seattle.