From eb0f90f4792c53d7cc0a7f6a8dd705be369bfba3 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 16 Jun 2020 22:01:56 +0100 Subject: [PATCH] Add a block of post-update tasks Add tasks to run after the site has been updated, but only if the site has not been installed from scratch. There's no point in importing config or running database updates on a freshly installed site. --- tools/ansible/deploy/after-symlink-shared.yml | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/tools/ansible/deploy/after-symlink-shared.yml b/tools/ansible/deploy/after-symlink-shared.yml index 377d116..6159f7e 100644 --- a/tools/ansible/deploy/after-symlink-shared.yml +++ b/tools/ansible/deploy/after-symlink-shared.yml @@ -1,13 +1,39 @@ --- - name: Install Drupal - command: | - {{ release_drush_path }} site-install config_installer -y + command: > + {{ release_drush_path }} + site-install -y --account-pass=admin123 - args: - chdir: '{{ release_drupal_path }}' - when: drupal_install + config_installer + chdir={{ release_drupal_path }} + when: drupal_install|bool -- name: Rebuild cache - command: '{{ release_drush_path }} cache-rebuild' - args: - chdir: '{{ release_drupal_path }}' +- name: Post-update tasks + when: not drupal_install|bool + block: + - name: Clear Drush cache + command: > + {{ release_drush_path }} + cache-clear drush + chdir={{ release_drupal_path }} + + - name: Run database updates + command: > + {{ release_drush_path }} + updatedb -y + chdir={{ release_drupal_path }} + register: update_database_output + changed_when: "'No pending updates' not in update_database_output.stderr" + + - name: Import configuration + command: > + {{ release_drush_path }} + config-import -y + chdir={{ release_drupal_path }} + register: config_import_output + changed_when: "'There are no changes to import' not in config_import_output.stderr" + + - name: Rebuild cache + command: > + {{ release_drush_path }} cache-rebuild + chdir={{ release_drupal_path }}