Advanced Drupal maintenance support plans 8 Configuration Management (CMI) Workflows

After implementing some larger enterprise Drupal maintenance support plans 8 websites, I would like to share some insights, how to solve common issues in the deployment workflow with Drupal maintenance support plans 8 CMI.
Introduction to Drupal maintenance support plans CMI
First of all, you need to understand, how the configuration management in Drupal maintenance support plans 8 works. CMI allows you to export all configurations and its dependencies from the database into yml text files. To make sure, you never end up in an inconsistent state, CMI always exports everything. By default, you cannot exclude certain configurations.
Example:
If you change some configuration on the live database, these configurations will be reverted in the next deployment when you use
drush config-import
This is helpful and will make sure, you have the same configuration on all your systems.
How can I have different configurations on local / stage / live environments?
Sometimes, you want to have different configurations on your environments. For example, we have installed a “devel” module only on our local environment but we want to have it disabled on the live environment.

This can be achieved by using the configuration split module: https://www.drupal.org/project/config_split
What does Configuration Split?
This module slightly modifies the CMI by implementing a Config Filter (https://www.drupal.org/project/config_filter). Importing and exporting works the same way as before, except some configuration is read from and written to different directories. Importing configuration still removes configuration not present in the files. Thus, the robustness and predictability of the configuration management remains. And the best thing is: You still can use the same drush commands if you have at least Drush 8.1.10 installed.
Configuration Split Example / Installation Guide
Install config_split using composer. You need need at least “8.x-1.0-beta4” and > drush 8.1.10 for this guide.
composer require drupal/config_split “^1.0”
Enable config_split and navigate to “admin/config/development/configuration/config-split”
drush en config_split -y
Optional: Installing the chosen module will make the selection of blacklists / greylists way more easier. You can enable chosen only on admin pages.
composer require drupal/chosen “^1.0”
I recommend you to create an “environments” subfolder in your config folder. Inside this folder you will have a separate directory for every environment:

Now you can configure your environments:

The most important thing is, that you set every environment to “Inactive”. We will later activate them according to the environment via settings.php

Here is my example where I enable the devel module on local:

Activate the environments via settings.php
This is the most important part of the whole setup up. Normally, we never commit the settings.php into git. But we have a [environment]-settings.php in git for every environment:
settings.php (not in git)

variables-dev.php (in git and included in the settings.php of dev)
variables-live.php (in git and included in the settings.php of live)
settings.local.php (in git and included locally)
You need to add the following line to the variables-[environment].php. Please change the variable name according to your environment machine name:
// This enables the config_split module
$config[‘config_split.config_split.dev’][‘status’] = TRUE;
If you have done everything correctly and cleared the cache you will see “active (overriden)” in the config_split overview next to the current environment.
Now you can continue using
drush config-import -y
drush config-export -y
and config_split will do the magic.
How can I exclude certain Config Files and prevent them to be overridden / deleted on my live environment?
The most prominent candidates for this workflow are webforms and contact forms. In Drupal maintenance support plans 7, webforms are nodes and you were able to give your CMS administrator the opportunity to create their own forms.
In Drupal maintenance support plans 8 webforms are config entities, which means that they will be deleted while deploying if the yml files are not in git.
After testing a lot of different modules / drush scripts, I finally came up with an easy to use workflow to solve this issue and give CMS administrators the possibility to create webforms without git knowledge:
Set up an “Excluded” environment
First of all, we need an “excluded” environment. I created a subfolder in my config-folder and added a .htaccess file to protect the content. You can copy the .htaccess from an existing environment, if you are lazy. Don’t forget to deploy this folder to your live system before you do the next steps.

Now you can exclude some config files to be excluded / grey-listed on your live environment:
webform.webform.*
contact.form.*

Set the excluded environment to “Inactive”. We will later enable it on the live / dev environment via settings.php.
Enable “excluded” environment and adapt deployment workflow
We enable the “excluded” environment on the live system via variables-live.php (see above):
// This will allow module config per environment and exclude webforms from being overridden
$config[‘config_split.config_split.excluded’][‘status’] = TRUE;
In your deployment workflow / script you need to add the following line before you do a drush config-import:
#execute some drush commands
echo “———————————————————–”
echo “Exporting excluded config”
drush @live config-split-export -y excluded

echo “———————————————————–”
echo “Importing configuration”
drush @live config-import -y
The drush command “drush @live config-split-export -y excluded” will export all webforms and contact forms created by your CMS administrators into the folder “excluded”. The “drush config-import” command will therefore not delete them and your administrators can happily create their custom forms.
Benefit of disable “excluded” on local environment
We usually disable the “excluded” environment on our local environment. This allows us to create complex webforms on our local machine for our clients and deploy them as usual. In the end you can have a mix of customer created webforms and your own webforms which is quite helpful.
Final note
The CMI is a great tool and I would like to thank the maintainers of the config_split module for their great extension. This is a huge step forward making Drupal maintenance support plans 8 a real Enterprise CMS Tool.
If you have any questions, don’t hesitate to post a comment.
 
Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Advanced Drupal maintenance support plans 8 Configuration Management (CMI) Workflows

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.