Config Enforce

Simplify production deployments and manage your config like a pro!

Derek Laventure

derek@consensus.enterprises

Land Back!

Guelph and Waterloo are traditional territory:

  • Anishinabewaki ᐊᓂᔑᓈᐯᐗᑭ
  • Haudenosaunee
  • Attiwonderonk
  • Mississaugas of the Credit

I offer respect and gratitude to the people who are past, present and future caretakers of this land.

Where are you? https://native-land.ca/

Who am I?

Derek Laventure (he/they)

Portrait of Derek, white face with broad smile and glasses.
  • White middle-class able-bodied (gender)queer settler
  • BSc Computer Science
    (University of Toronto 2000)
  • 20+ years of Drupal (spiderman@drupal.org)
  • Founding partner of Consensus
  • Tai Chi student and instructor

Consensus Enterprises

We help small teams do big things.

Gratitude

Table of Contents

  1. A brief history of production deployments
  2. Drupal as application framework
  3. CMI 2.0
  4. Config Enforce
  5. Demo
  6. Q&A / Discussion

A brief history of production deployments

pre-Drupal 8

  • Config vs. Content -> all in the DB
  • Large mysqldump files
  • hook_update() functions
  • Pantheon-like workflows: DEV -> TEST -> LIVE
  • Features modules
  • Exportables
  • Clobbered production config values!

Configuration Management

  • drush cim/cex -> config distinct and exportable
  • Large config/sync YAML directories
  • (still) hook_update() functions
  • Config Split
  • Config vs. Content? not a clean line
  • Clobbered production config values!

Drupal as application framework

(a small detour)

  • Sites with complex behaviour
  • Install profiles
  • CI/CD for automated testing
  • Grouping config into logical units

CMI 2.0

Config Enforce

  • What if production config didn’t “drift”?

How it works

  • Register config entities to enforce
  • Disable config forms for those entities
  • Block API-level changes (`drush cset`)
  • In DEV, allow editing, and auto-export changes
  • Push exported updates to PROD
  • Enforce configs (`drush config-enforce:enforce`)

Config Enforce is 2 modules

  • Config Enforce (CE) - install in production
  • Config Enforce Devel (CED) - install in dev
  • Config Enforce disables forms (& blocks API changes)
  • Config Enforce Devel provides a UI to "register" configs to enforce

Config Devel

  • Config Devel enables automatic cim/cex
  • Config Enforce patches Config Devel with hooks
  • CED implements these hooks to tell Config Devel to import/export enforced configs
  • Config Devel does the actual writing to disk

Introspection

We use PHP reflection to invoke protected methods to access eg. getEditableConfigNames() methods.

Enforcement levels are lying!

  • But we’ve gained a really nice development workflow!

Resources

Drupal 11 and beyond

We need a consistent mechanism to identify config entities (to avoid Page manager spelunking)!

Demo

  • Bootstrap project with Drumkit
  • Install and enable Config Enforce (enable patching!)
  • Basic settings & Default target module
  • Generate new target module
  • Enforce simple config (enforced by default!)
  • Enforce Fields, Views config
  • Generate from Active

Discussion / Q&A

Resources