From 0c79c5d7249b4ef9e278b889ffbcffe2d14b8ae3 Mon Sep 17 00:00:00 2001 From: Mark Dorison Date: Tue, 18 Aug 2020 13:27:18 -0400 Subject: [PATCH] Updated role to depend on drush deploy command. (#25) --- README.md | 7 +++++- defaults/main.yml | 6 ++--- tasks/main.yml | 57 +++++++++-------------------------------------- 3 files changed, 19 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index d866e04..c0df819 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,22 @@ # Ansible Role: deploy-drupal + Manages Drupal site deployments. ## Requirements + None. ## Role Variables + See [defaults](defaults/main.yml) for all available variables and accompanying documentation. ## Example Playbook + Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: -``` +```yaml - hosts: all vars: @@ -29,4 +33,5 @@ passed in as parameters) is always nice for users too: ``` ## License + MIT diff --git a/defaults/main.yml b/defaults/main.yml index 8ddc1f3..d20ff2e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -29,8 +29,8 @@ deploydrupal_site_install: false # deploydrupal_site_install is true. deploydrupal_site_install_config: true -# If set to false, drush config-import will not be run as part of deployment. -deploydrupal_config_import: true +# If set to false, drush deploy will not be run as part of deployment. +deploydrupal_drush_deploy: true # The path the repository should be cloned to. deploydrupal_dir: "/var/www/html" @@ -54,7 +54,7 @@ deploydrupal_npm_theme_build: false deploydrupal_npm_theme_path: "" deploydrupal_npm_theme_run_commands: [] -# Rebuild Drupal cache. +# Rebuild Drush cache. deploydrupal_drush_cache_rebuild: true # Site file directory folders that need permission fixes after site install. diff --git a/tasks/main.yml b/tasks/main.yml index c6435b8..5b7c0b2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -79,13 +79,14 @@ mode: 0770 become: "{{ deploydrupal_files_become }}" -- name: clear caches. - shell: "{{ deploydrupal_drush_path }} cache-rebuild" +- name: run theme build tasks. + shell: "{{ item }}" args: - chdir: "{{ deploydrupal_core_path }}/sites/{{ deploydrupal_site_name }}" + chdir: "{{ deploydrupal_npm_theme_path }}" + with_items: "{{ deploydrupal_npm_theme_run_commands }}" when: - - not deploydrupal_site_install - - deploydrupal_drush_cache_rebuild + - deploydrupal_npm_theme_build + - deploydrupal_npm_theme_path is defined # Drush ^9 uses the Drupal service container. We intentionally clear the Drupal # cache before the Drush cache to avoid fatal errors due to stale cache in the @@ -117,56 +118,18 @@ when: - deploydrupal_site_install -# Import the latest configuration. This includes the latest -# configuration_split configuration. Importing this twice ensures that the -# latter command enables and disables modules based upon the most up to date -# configuration. -- name: import configuration 1/2. - shell: "{{ deploydrupal_drush_path }} config-import -y" - args: - chdir: "{{ deploydrupal_core_path }}/sites/{{ deploydrupal_site_name }}" - register: drush_output - when: - - deploydrupal_config_import - -- name: print drush output - debug: var=drush_output.stdout_lines - when: - - deploydrupal_config_import - -- name: import configuration 2/2. - shell: "{{ deploydrupal_drush_path }} config-import -y" +- name: drush deploy + shell: "{{ deploydrupal_drush_path }} deploy -v -y" args: chdir: "{{ deploydrupal_core_path }}/sites/{{ deploydrupal_site_name }}" register: drush_output when: - - deploydrupal_config_import + - deploydrupal_drush_deploy - name: print drush output debug: var=drush_output.stdout_lines - -- name: run database updates. - shell: "{{ deploydrupal_drush_path }} updatedb -y" - args: - chdir: "{{ deploydrupal_core_path }}/sites/{{ deploydrupal_site_name }}" when: - - not deploydrupal_site_install - -- name: run theme build tasks. - shell: "{{ item }}" - args: - chdir: "{{ deploydrupal_npm_theme_path }}" - with_items: "{{ deploydrupal_npm_theme_run_commands }}" - when: - - deploydrupal_npm_theme_build - - deploydrupal_npm_theme_path is defined - -- name: clear caches. - shell: "{{ deploydrupal_drush_path }} cache-rebuild" - args: - chdir: "{{ deploydrupal_core_path }}/sites/{{ deploydrupal_site_name }}" - when: - - deploydrupal_drush_cache_rebuild + - deploydrupal_drush_deploy # Save redis data to disk. This is necessary in Docker environments to ensure we # preserve the correct cache state.