Upgrading the Dransible project to Drupal 9opdavies5th September 2020

This week I gave a new talk on upgrading to Drupal 9 for the Drupal NYC meetup. Whilst preparing for that, I decided to upgrade my Dransible example project that I use for my Ansible and Ansistrano talk to Drupal 9 and document the process.

Whilst the steps taken are in the slides for that talk, here is the full list of steps that I took including the Composer commands.

Updating from Drupal 8.8 to 8.9

To begin with, let's update to the latest version of Drupal 8 so that we can do some testing and see all of the latest deprecation notices before moving to Drupal 9.

  1. Remove Drush temporarily using composer remove drush/drush as it will cause us being stuck on Drupal 8.9.0-beta2 rather than a newer, stable 8.9 version.
  2. Update ^8.8 to ^8.9 in composer.json for drupal/core-recommended, drupal/core-dev and drupal/core-composer-scaffold, and run composer update drupal/core-* --with-dependencies to update core to 8.9.5.
  3. Re-add Drush so that it's present for the deployment by running composer require drush/drush:^9.

Preparing for Drupal 9

  1. Add the Upgrade Status module by running composer require drupal/upgrade_status.
  2. Upgrade to Drush 10 by running composer require drush/drush:^10.
  3. Remove the Config Installer module by running composer remove drupal/config_installer. This is no longer needed since Drupal 8.6, and there will be no Drupal 9 version.
  4. Update the Admin Toolbar module to 2.3, a Drupal 9 compatible version, by running composer update drupal/admin_toolbar.

As I'd previously updated the Simple Message custom module to be Drupal 9 compatible (adding the core_version_requirement key to the info.yml file, and removing usages of deprecated code), no changes needed to be made to that.

Upgrading to Drupal 9

  1. Update ^8.9 to ^9.0 for the core packages in composer.json, and run composer update drupal/core-* --with-dependencies to update to 9.0.5.
  2. Re-add Drush by running composer require drush/drush. This will install Drush 10 by default.

Post upgrade

Although everything seemed to have updated OK locally, there were some errors when running a deployment to the Vagrant virtual machine that needed to be addressed, as well as some post-upgrade housekeeping steps to perform.

  1. Fix the deployment error by adding the Symfony Configuration component as a dependency by running composer require symfony/config:^4.
  2. Alias Drupal\Core\Messenger\MessengerInterface to messenger in simple_message.services.yml to fix the autowiring error.
  3. Add settings["config_sync_directory"] to settings file variables (this will be added automatically in the next version of the Drupal settings Ansible role).
  4. Remove the Upgrade Status module by running composer remove drupal/upgrade_status, as it's no longer needed.

And that's it! The Dransible demo project is upgraded, and if you see my Ansible deployments talk in the future, the demo site will be running on Drupal 9.

If you want to see the original pull request, it's at https://github.com/opdavies/dransible/pull/7.