Principles of Configuration Management

Today

  1. Configuration system overview
  2. Problem areas
  3. Recommended approaches
  4. Configuration validation

Matthew Tift, PhD

  • Lead Engineer, Lullabot
  • 15+ years in Drupal
  • CMI, Olivero, Config maintainer
  • Starshot, Dashboard track lead
  • Volunteer, Twin Cities Drupal
  • Yoga teacher

Slides

talks.matthewtift.com/govcon-config

1. Configuration System Overview

What is
Configuration Management?

Configuration:

Types of Things

Configuration

  • Views
  • Content Types
  • Image Styles
  • Forms
  • Settings
  • User Roles

Content:

Things

Content:

  • Article
  • Basic Page
  • Menu Item
  • User
  • Taxonomy Term

Configuration

Site Builder (e.g., me)


Content

Site Editor (e.g., my wife)

2 kinds of configuration

1. Simple Configuration

2. Configuration Entities

Simple Configuration

Exactly one copy or version

Configuration Entity:

Creates zero or more items

config content

Credit: Gábor Hojtsy

Configuration Management

Quality

Coordination

Metadata

Repeatability

Verification

Consistency

Documentation

Control

Process

for establishing and maintaining consistency

configuration management

DEV ➞ PROD

JPEG Quality

Drupal Core

Configuration Life Cycle

filesdatabasefiles

config/install

Only read at install time

core/modules/system/config/install/system.image.gd.yml

JPEG Quality

admin/config/media/image-toolkit

admin/config/development/configuration

Configuration Life Cycle

databasefilesdatabase

Config Schema

system.schema.yml

2015-11-19

Drupal 8.0.0 released 🎉

Everyone is happy 🤓

DEV ➞ PROD


2. Problem areas

DEV ➞ PROD

WTF?

Complex requirements

  • Dev modules, but not on prod
  • Config on one site, not another
  • Multi-site

And yet …

Configuration System is robust

Agile Manifesto

1st value:
“Individuals and interactions over processes and tools”

My principles of configuration management

  • Kindness (non-harming)
  • Truthfulness
  • Non-stealing
  • Discipline
  • Contentment

Problem

You are the only developer of a site and the configuration system is annoying

DEV ➞ PROD

Not Necessary

  • Low-traffic sites
  • Single-developer sites
  • Sites without dev/stage

‼️ Back-up your database

Export configuration anytime

Contentment

Requirement

Enable different modules in different environments

Drupal Planet

Articles recommend config split

Question

Have you used the
config_split module?

Question

Have you experienced problems with the config_split module?

Reliability

A truly reliable config_split needs infrastructure that doesn’t exist

Architectural Decision Records

architecture.lullabot.com

Architectural Decision Records

Recommendations for ALL sites

Architectural Decision Record

Use settings, not splits

config_exclude_modules will be used for enabling modules on development sites.”

settings.local.php

$settings['config_exclude_modules'] = ['devel', 'stage_file_proxy'];

Problem

Deployed configuration does not match local environments

Root cause?

Config was edited by hand

Fingers were pointed 👉

Manual Edits

  • Field settings (break content)
  • Permissions (security risks)
  • Block settings (broken pages)
  • Taxonomy (orphaned content)
  • Cache settings (performance)

Solution

Always use the configuration system (UI or drush) to export configuration

Problem

You exported with Drush,
but import still doesn’t work

Solution

Important config twice

Lullabot ADR

Define the order of steps when building a Drupal site

Core Issue

Config import sometimes needs be run several times to fully sync

Problem

People make mistakes

Solution

“Remind” folks

Architectural Decision Record

Confirm Drupal site configuration is always in a default state

Confirm site is always in a default state

if [[ $(./vendor/bin/drush config:status --format=json --state=Different) != '[]' ]]; then
  echo "Config export does not match database."
  ./vendor/bin/drush config:status
  exit 1;
fi

Let’s Review

  1. Export locally
  2. Avoid splits
  3. Import twice in CI
  4. Run tests in CI

Problem

Configuration is not valid

4. Configuration validation

Configuration is now fully validatable!!

Who cares?

Form validation

'#config_target'

Other constraints

  • ConfigExists
  • Length
  • NotBlank
  • Range
  • Regex

#config_target

  1. Simpler forms
  2. Validation
  3. Better UX

Config Validation

Automatic Updates

Automatic Updates

Currently only targeting Drupal core

Automatic Updates

Updates to configuration in contrib modules are unreliable without config validation

Config Validation

Recipes

Recipes

🔥 the new hotness!

Recipes

Without validation, Recipes can fail when multiple recipes are combined

Recipes

Because of config validation,
Recipes can roll back

Config Validation

Write configuration via
JSON:API, GraphQL, etc.

Config Validation

Decoupled admin UI

Drupal 11 Content

more “API-First” than Drupal 8

Drupal 11 Config

still has a way to go

JS Admin UI was limited by a lack of configuration validation

Config Validation

Reliable config_split?

project.pages.drupalcode.org/config_inspector

Would ♥️ help

[meta] Add constraints to all simple configuration
[meta] Add constraints to all config entity types

DrupalCon Portland 2024 talk

Wim Leers: Drupal’s next leap: configuration validation — it’s here!

Config Validation

… in your next project

Config Validation

Solve all of the world’s problems

Connect

matthewtift.com

mastodon.social/@mtift

Slides

talks.matthewtift.com/govcon-config