Configuration as Dependency: Managing Drupal 8 Configuration with git and Composer

  • Published on

  • View

  • Download


1. CONFIGURATION AS DEPENDENCY Managing Drupal 8 Conguration with Git and Composer 2. ERICH BEYRENT Senior Drupal Developer at BioRAFT Working with Drupal since 2004 Drupal: Twitter: https:/ Github: 3. Moshe Weitzman Justin Ludwig Justin works for BioRAFT as a Development Engineer and am responsible for anything that gets thrown my way. He thrives in areas related to user management including SSO & permissions templates as well as adding some whizz-bang to sites with jQuery. Drupal has been his tool of choice since 2007. Moshe has been a consistent contributor to Drupal core and Contrib since November 2001. As such, he has pretty much touched the whole core code. He maintains the user.module, the bootstrap code, and the web site. 4. AGENDA Overview of Drupal 8 conguration management 5. AGENDA Overview of Drupal 8 conguration management Managing your Git repository 6. AGENDA Overview of Drupal 8 conguration management Managing your Git repository Using Composer and Drupal Console 7. AGENDA Overview of Drupal 8 conguration management Managing your Git repository Using Composer and Drupal Console Multisite considerations 8. 9. BACKGROUND Pre-Drupal 8 Challenges Conguration cannot easily be represented in code Conguration changes performed by clients and/or client services cannot be represented in code without going through patch/release with developers 10. BACKGROUND Drupal 8 Goals Allow non-developers to change conguration safely Clients can safely change congurations to the extent that they are allowed Provide an audit trail of all conguration changes made Easily and automatically create new instances of sites with default congurations 11. Two Types of Configuration in Drupal 8 12. DRUPAL 8 CONFIGURATION SYSTEM Standardizes conguration export into YAML les Used for both simple cong and cong entities (elds, views, workows, roles, etc) 13. Sites own their conguration, not modules. - Alex Pott 14. 15. DRUPAL 8 CONFIGURATION SYSTEM Contrib/custom modules have the same tools for enabling default congurations Default YAML les are stored with the module Once a module is installed, the site now owns the cong and those YAML les are copied to the site-wide cong directory 16. DRUPAL 8 CONFIGURATION SYSTEM Robust system for managing hard and soft/optional dependencies Nested module dependencies are automatically added to the conguration (when exported) 17. USEFUL CONFIGURATION MODULES Conguration Update Conguration Tools Conguration Synchronizer Conguration Development Conguration Log 18. WANT MORE INFORMATION? Watch Moshe Weitzmans DrupalNights presentation about Drupal 8s configuration management system! 19. There is no recommended workow. -Matthew Tift 20. GIT REPO STRATEGY Create two repositories: Code Configuration 21. 22. YES, THERES TWO OF THEM Use git to manage individual site dierences and conict resolution Default congurations for all sites can be managed on the master branch of the conguration repository Each client site has its own branch of the Cong Repo Code repository contains only custom modules/themes/ libraries, sites directory and build scripts 23. GIT REPO STRATEGY: CODE REPO All dependencies are managed by Composer Package and version added to composer.json and it is built with all dependency dependencies resolved automatically 24. Conguration is just another dependency. -Erich Beyrent 25. CONFIGURATION AS DEPENDENCY Manage conguration as a dependency in composer.json Use tags to identify conguration versions 26. "repositories": [ { "type": "composer", "url": "" }, { "type": "vcs", "url": "" } ], 27. "require": { "composer/installers": "^1.0.20", "drupal-composer/drupal-scaffold": "^2.0.1", "cweagans/composer-patches": "~1.0", "drupal/core": "~8.0", "drush/drush": "8.x-dev", "drupal/console": "~1.0", "multiplesite-config/alpha": "dev-alpha", "multiplesite-config/bravo": "dev-bravo" }, 28. "config": { "preferred-install": { "multiplesite-config/*": "source" } } 29. "extra": { "installer-paths": { "config/{$name}": ["type:bonefish-package"], "web/core": ["type:drupal-core"], "web/modules/contrib/{$name}": ["type:drupal-module"], "web/profiles/contrib/{$name}": ["type:drupal-profile"], "web/themes/contrib/{$name}": ["type:drupal-theme"], "drush/contrib/{$name}": ["type:drupal-drush"] } }, 30. "scripts": { "drupal-scaffold": "DrupalComposerDrupalScaffoldPlugin::scaffold", "pre-install-cmd": [ "DrupalProjectcomposerScriptHandler::checkComposerVersion" ], "pre-update-cmd": [ "DrupalProjectcomposerScriptHandler::checkComposerVersion" ], "post-install-cmd": [ "DrupalProjectcomposerScriptHandler::createRequiredFiles" ], "post-update-cmd": [ "DrupalProjectcomposerScriptHandler::createRequiredFiles" ] }, 31. GIT REPO STRATEGY: CONFIG REPO Master branch contains the default congurations for any/all modules Each client site gets its own branch in the cong repository For a site to work, we need both repos Master branch containing site defaults is mirrored from the Cong Repo into the Drupal Repo (read-only) using git subtree split 32. DEVELOPER WORKFLOW Create a branch of Code Repo for a new ticket/card/bug/ feature and do some work The Cong Repo will be available to edit congs for sites where module is already enabled The same YAML will also have to be added to the module for sites where it was never enabled 33. CONFIG REPO BENEFITS While a feature is being worked on, a specic version of cong can be used that wont conict with other features being developed If a problem arises with conguration, it can easily be rolled back by specifying the working version Exact replica of an entire sites conguration can be built from scratch during development or debugging without any client data being used 34. MORE CONFIG REPO BENEFITS Helps determine if a bug involving cong is actually solved rather than just solved for a particular piece of data Helps with testing unique conguration considerations Potential to assist with new site rollouts 35. WHAT ELSE? Theme repositories? 36. MULTISITE CONFIGURATION REQUIREMENTS Conguration defaults exist and may need to be updated Each site is congured uniquely and may override defaults as required Both simple cong (e.g. site name) and complex cong (cong entities) may need to be overridden A cong may need to be to be changed for a single site or a group of sites Conict management varies from case to case 37. THE EXPERIMENT An experiment in how to to handle the "multisite" pattern in Drupal 8. This is when you run dozens or hundreds of very similar sites. You want these sites to vary configuration in slight ways, but still easily push out config changes to all. Examples include one site for each member of Congress, or one site for each musician in our portfolio. 38. IMPLEMENTATION multisite multisite-config master config master config client a branch client b branch client c branch git subtree-split 39. IMPLEMENTATION ALTERNATIVE multisite multisite-config master config master config client a branch client b branch client c branch x 40. IMPLEMENTATION master config client a branch client b branch client c branch master config changes git merge client c config changes 41. PUSHING COMMITS When xing bugs while using a client site, a developer can choose to push commits to master cong or to client cong as needed. Pushing to client cong happens automatically since thats origin. If dev wants to integrate changes into multiplesite, add a remote pointing to multiplesite and then push commits there. git remote add multiplesite checkout -b multiplesite-master multiplesite/mastergit cherry-pick git push 42. IMPLEMENTATION master config client c branch client c configuration config changes client c production database 43. SUMMARY Multisite projects have unique cong requirements The proposed workow should be able to handle all of those requirements elegantly The process can be automated enough to reduce cognitive strain and allow everyone to focus their energy on what matters: the product! 44. RESOURCES episode-6-new-back-end-features-drupal-8 management-in-drupal-8-the-key-concepts conguration-management 45. 46. BIORAFT IS HIRING!