32
©2018 Acquia Inc. — Confidential and Proprietary Configuration Workflow in Drupal 8 Mike Madison

Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

  • Upload
    others

  • View
    36

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Configuration Workflow in Drupal 8

Mike Madison

Page 2: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

About Me

Technical Architect @ AcquiaOrganizer of Drupal GovConMaintainer of BLT + COD

D.O: mikemadison Github: mikemadison13 LinkedIn: mikemadisonTwitter: mikemadison

Page 3: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Agenda

– Basics of D8 Configuration– Managing Configuration Across Environments– Config Split– Config Ignore– Configuration in Code

Page 4: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Topics Covered

● Managing different configuration for different environments (config split)

● Ignoring configuration entirely (config ignore)● Basic configuration workflow (including git, CI, testing, etc.)● Interaction with DevOps (using tools like Acquia BLT)● Dependency interactions with other config, modules, and

composer● Working with configuration in code

Page 5: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Disclaimer

Recommended approach as of August 2018. Subject to change.

https://www.drupal.org/project/cmi2https://www.drupal.org/project/drupal/issues/1613424 https://www.drupal.org/project/drupal/issues/2982056https://www.phase2technology.com/blog/drupal-8-configuration-management

Page 6: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Take Away #1

Keep up to date with all the happenings.

Page 7: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

What is Configuration?

Configuration is the collection of admin settings that determine how the site default functions, as opposed to the content of the site.

Configuration will typically include things such as the site name, the content types and fields, taxonomy vocabularies, views and so on.

https://www.drupal.org/docs/8/configuration-management

Page 8: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

What is Configuration?

Adding a Menu: “Config”Adding a link to a Menu: “Content”

Adding a User Role: “Config”Assigning a Permission to a Role: “Config”Assigning a User to a Role: “Content”

Page 9: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

What is Configuration?

File System– YML files

Database– Config table

Page 10: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

What is Configuration?

Local

Dev

Test

Prod

Page 11: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

EXAMPLE

https://github.com/Drupal4Gov/Drupal-GovCon-2017/

- What is configuration?- How is it stored?- How do you read it?- How do you change it?

Page 12: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Problem

If it’s in the database…

- How to execute a proper workflow?- How to preserve changes after updates?- How to not break your @#%!?

Page 13: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Example: Configuration Workflow

Development1. Install Drupal2. Create Blog Content Type3. Add fields and configure form / display4. Add Blog View5. Export Configuration6. Commit yml files7. Writes Behat Tests8. Pull Request

Page 14: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Example: Configuration Workflow

Code Review / QA1. Install Drupal2. Import Configuration3. Configuration Creates Content Type, Fields, Display, View, etc.4. Review Blog Content Type5. Review View6. Review Tests7. Merge Pull request

Page 15: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Example: Configuration Workflow

Deployment1. Import Configuration2. Blog Features on Production

Page 16: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Take Away #2

Config will bite you. Limit where it can bite you.

Page 17: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Benefits of Configuration Workflow

– Develop new features for a site outside of production

– Mirror environments without having to move databases

– Bootstrap and test Drupal during CI

– Store in version control

Page 18: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Challenges of Configuration Workflow

– Core Config is all or nothing

– Core does not import configuration by default during installs or database updates

– No implicit / explicit logical, conditional, or environment specific capabilities

– Drastic changes (e.g. deleting a field) may require data manipulation and/or custom development

Page 19: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Core Config is all or nothing

Solutions:Store all active configuration in repository (e.g. config/default)

Don’t ever make config changes on a production site. Always rely on workflow.

Use contrib to limit what core manages.

Overcoming Challenges

Page 20: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Overcoming Challenges

Core does not import configuration by default during installs or database updates

Solutions:Use automation tools (e.g. Acquia BLT) that manage configuration for you

Host with a company that provides deployment hooks easy CI integration

Page 21: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Overcoming Challenges

No implicit / explicit logical, conditional, or environment specific capabilities

Solutions:Expand Core features with contrib modules such as Config Split / Config Ignore

Use automation tools (e.g. Acquia BLT) to detect environments and activate specific version of config / config splits

Page 22: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Overcoming Challenges

Drastic changes (e.g. deleting a field) may require data manipulation and/or custom development

Solutions:Limit data model changes to production sites (BEST PRACTICE)

Write migrations prior to removing key features (BEST PRACTICE)

Page 23: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Solutions: Store Config

https://github.com/Drupal4Gov/Drupal-GovCon-2017

Page 24: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2016 Acquia Inc. — Confidential and Proprietary

Solutions: Automation with BLT

● An Acquia-built tool for creating new projects from a standardized template● A common set of tools for building, testing, validating, deploying, etc.● A collection of commands for automating common project tasks● A repository and enforcer of best practices

Page 25: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

Build & TestDevelop, Build & Test

Review Deploy

Acquia PipelinesOr Travis

Acquia CloudAcquia Cloudor GitHub

BLT

Local Machine

BLT

Solutions: Automation with BLT

Page 26: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Take Away #3

There is no try. Do or do not.

Page 27: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Managing Block Config

- Drush- Git- BLT

EXAMPLE

Page 28: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Managing Config Splits

- Why config split?- What can you do with it?

EXAMPLE

Page 29: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Managing Config Ignores

- Why config ignore?- What can you do with it?

EXAMPLE

Page 30: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

EXAMPLE

Changing / Using Config in Code

https://github.com/mikemadison13/govcon2018php

Page 31: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Take Away #4

Core config needs help. BUT there is good help in contrib.

Page 32: Drupal 8 Configuration Workflow in - Drupal GovCon 2020 … · Example: Configuration Workflow Code Review / QA 1. Install Drupal 2. Import Configuration 3. Configuration Creates

©2018 Acquia Inc. — Confidential and Proprietary

Questions?