From e258ed86a11a1baec4e134f84495508df9e1b188 Mon Sep 17 00:00:00 2001 From: tim Date: Tue, 23 Jan 2024 18:49:20 +0200 Subject: [PATCH 01/11] r65896-cache-clear-dir --- roles/_init/tasks/main.yml | 53 +++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index c054e8fb..73bac9f6 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -31,38 +31,33 @@ - cache_clear_opcache.cachetool_bin is defined - cache_clear_opcache.cachetool_bin | length > 0 -# Manipulate variables for SquashFS builds. -- name: Define image builds base path. - ansible.builtin.set_fact: - build_base_path: "/home/{{ deploy_user }}/builds/{{ project_name }}_{{ build_type }}" - when: - - deploy_code.mount_type is defined - - deploy_code.mount_type == "squashfs" -- name: Define image builds build path prefix. - ansible.builtin.set_fact: - build_path_prefix: "{{ build_base_path }}/{{ project_name }}_{{ build_type }}_build_" - when: - - deploy_code.mount_type is defined - - deploy_code.mount_type == "squashfs" -- name: Define live_symlink dest for image builds. - ansible.builtin.set_fact: - live_symlink_build_dest: "{{ live_symlink_build_dest | default('{{ build_base_path }}/live.{{ project_name }}_{{ build_type }}') }}" - when: - - deploy_code.mount_type is defined - - deploy_code.mount_type == "squashfs" -- name: Overwrite deploy and live_symlink paths if SquashFS deploy. - ansible.builtin.set_fact: - deploy_path: "{{ build_path | default('{{ build_path_prefix }}{{ build_number }}') }}" - when: - - deploy_code.mount_type is defined - - deploy_code.mount_type == "squashfs" -- name: Overwrite cachetool path if SquashFS deploy and path not provided. - ansible.builtin.set_fact: - cachetool_bin: "{{ build_base_path }}/cachetool.phar" +- name: Manipulate variables for SquashFS builds. + block: + - name: Define image builds base path. + ansible.builtin.set_fact: + build_base_path: "/home/{{ deploy_user }}/builds/{{ project_name }}_{{ build_type }}" + + - name: Define image builds build path prefix. + ansible.builtin.set_fact: + build_path_prefix: "{{ build_base_path }}/{{ project_name }}_{{ build_type }}_build_" + + - name: Define live_symlink dest for image builds. + ansible.builtin.set_fact: + live_symlink_build_dest: "{{ live_symlink_build_dest | default('{{ build_base_path }}/live.{{ project_name }}_{{ build_type }}') }}" + + - name: Overwrite deploy and live_symlink paths if SquashFS deploy. + ansible.builtin.set_fact: + deploy_path: "{{ build_path | default('{{ build_path_prefix }}{{ build_number }}') }}" + + - name: Overwrite cachetool path if SquashFS deploy and path not provided. + ansible.builtin.set_fact: + cachetool_bin: "{{ build_base_path }}/cachetool.phar" + when: + - cache_clear_opcache.cachetool_bin is not defined when: - deploy_code.mount_type is defined - deploy_code.mount_type == "squashfs" - - cache_clear_opcache.cachetool_bin is not defined + - deploy_operation == 'deploy' # Gather last known good build directly from symlink. # This can happen: From f1397abfb98e51d9004c5b9a8df576dbea71d40b Mon Sep 17 00:00:00 2001 From: tim Date: Tue, 23 Jan 2024 19:05:44 +0200 Subject: [PATCH 02/11] r65896-cache-clear-dir --- roles/_init/tasks/main.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index 73bac9f6..aa5549dd 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -54,6 +54,11 @@ cachetool_bin: "{{ build_base_path }}/cachetool.phar" when: - cache_clear_opcache.cachetool_bin is not defined + + - name: Ensure build target directory exists. + ansible.builtin.file: + path: "{{ build_base_path }}" + state: directory when: - deploy_code.mount_type is defined - deploy_code.mount_type == "squashfs" @@ -94,15 +99,6 @@ path: "{{ deploy_base_path }}" state: directory -# Make sure the build target exists. -- name: Ensure build target directory exists. - ansible.builtin.file: - path: "{{ build_base_path }}" - state: directory - when: - - deploy_code.mount_type is defined - - deploy_code.mount_type == "squashfs" - # Check for project specific init tasks. - name: Check that {{ project_type }}.yml exists. ansible.builtin.stat: From 5d75e695635e02c2c555b5052bfde8b01815713d Mon Sep 17 00:00:00 2001 From: tim Date: Tue, 23 Jan 2024 20:36:50 +0200 Subject: [PATCH 03/11] grouping squashfs tasks --- roles/deploy_code/tasks/cleanup.yml | 126 +++++++++++----------------- 1 file changed, 51 insertions(+), 75 deletions(-) diff --git a/roles/deploy_code/tasks/cleanup.yml b/roles/deploy_code/tasks/cleanup.yml index f3fc2c73..449c1103 100644 --- a/roles/deploy_code/tasks/cleanup.yml +++ b/roles/deploy_code/tasks/cleanup.yml @@ -17,15 +17,6 @@ - deploy_code.perms_fix_path | length > 1 - deploy_code.mount_type != "squashfs" -- name: Ensure permissions are set on builds directory. - ansible.builtin.shell: - cmd: "if [ -d {{ build_path_prefix }}{{ item }}/{{ deploy_code.perms_fix_path }} ]; then chmod 755 {{ build_path_prefix }}{{ item }}/{{ deploy_code.perms_fix_path }}; fi" - with_sequence: start={{ [previous_build_number | int - cleanup_history_depth, 0] | max }} end={{ [previous_build_number | int - deploy_code.keep, 0] | max }} - when: - - deploy_code.perms_fix_path is defined - - deploy_code.perms_fix_path | length > 1 - - deploy_code.mount_type == "squashfs" - - name: Delete codebases from deploy directory. ansible.builtin.file: name: "{{ deploy_path_prefix }}{{ item }}" @@ -34,14 +25,6 @@ when: - deploy_code.mount_type != "squashfs" -- name: Delete codebases from builds directory. - ansible.builtin.file: - name: "{{ build_path_prefix }}{{ item }}" - state: absent - with_sequence: start={{ [previous_build_number | int - cleanup_history_depth, 0] | max }} end={{ [previous_build_number | int - deploy_code.keep, 0] | max }} - when: - - deploy_code.mount_type == "squashfs" - - name: Create a tarball of the deployed codebases. ansible.builtin.command: cmd: "tar -cvf /tmp/{{ project_name }}_{{ build_type }}_{{ build_number }}.tar --owner=0 --group=0 {{ deploy_base_path }}" @@ -51,15 +34,6 @@ - deploy_code.mount_type == "tarball" run_once: true -- name: Create a SquashFS image of the deployed codebases. - ansible.builtin.command: - cmd: "mksquashfs {{ build_base_path }} /tmp/{{ project_name }}_{{ build_type }}_{{ build_number }}.sqsh -e {{ build_base_path }}/deploy.sqsh" - when: - - deploy_code.mount_sync is defined - - deploy_code.mount_sync | length > 1 - - deploy_code.mount_type == "squashfs" - run_once: true - - name: Create destination folder. ansible.builtin.file: path: "{{ deploy_code.mount_sync }}" @@ -79,60 +53,57 @@ - deploy_code.mount_type == "tarball" run_once: true -- name: Move SquashFS image to final destination. - ansible.builtin.command: - cmd: "mv /tmp/{{ project_name }}_{{ build_type }}_{{ build_number }}.sqsh {{ deploy_code.mount_sync }}/{{ project_name }}_{{ build_type }}.sqsh" - when: - - deploy_code.mount_sync is defined - - deploy_code.mount_sync | length > 1 - - deploy_code.mount_type == "squashfs" - run_once: true +# Beginning of the squashFS block. +- name: Execute tasks for squashFS mount type. + block: + - name: Ensure permissions are set on builds directory. + ansible.builtin.shell: + cmd: "if [ -d {{ build_path_prefix }}{{ item }}/{{ deploy_code.perms_fix_path }} ]; then chmod 755 {{ build_path_prefix }}{{ item }}/{{ deploy_code.perms_fix_path }}; fi" + with_sequence: start={{ [previous_build_number | int - cleanup_history_depth, 0] | max }} end={{ [previous_build_number | int - deploy_code.keep, 0] | max }} + when: + - deploy_code.perms_fix_path is defined + - deploy_code.perms_fix_path | length > 1 -- name: Check if we have a SquashFS image already there. - ansible.builtin.stat: - path: "{{ build_base_path }}/deploy.sqsh" - register: _deploy_code_mount_image - when: - - deploy_code.mount_sync is defined - - deploy_code.mount_sync | length > 1 - - deploy_code.mount_type == "squashfs" + - name: Delete codebases from builds directory. + ansible.builtin.file: + name: "{{ build_path_prefix }}{{ item }}" + state: absent + with_sequence: start={{ [previous_build_number | int - cleanup_history_depth, 0] | max }} end={{ [previous_build_number | int - deploy_code.keep, 0] | max }} -- name: Copy previous SquashFS image to shared mount point in case of rollback. - ansible.builtin.copy: - remote_src: true - force: true - src: "{{ build_base_path }}/deploy.sqsh" - dest: "{{ deploy_code.mount_sync }}/{{ project_name }}_{{ build_type }}_previous.sqsh" - when: - - deploy_code.mount_sync is defined - - deploy_code.mount_sync | length > 1 - - deploy_code.mount_type == "squashfs" - - _deploy_code_mount_image.stat.islnk is defined - run_once: true + - name: Create a SquashFS image of the deployed codebases. + ansible.builtin.command: + cmd: "mksquashfs {{ build_base_path }} /tmp/{{ project_name }}_{{ build_type }}_{{ build_number }}.sqsh -e {{ build_base_path }}/deploy.sqsh" + run_once: true -- name: Ensure mounted SquashFS image is deleted. - ansible.builtin.file: - path: "{{ build_base_path }}/deploy.sqsh" - state: absent - when: - - deploy_code.mount_sync is defined - - deploy_code.mount_sync | length > 1 - - deploy_code.mount_type == "squashfs" + - name: Move SquashFS image to final destination. + ansible.builtin.command: + cmd: "mv /tmp/{{ project_name }}_{{ build_type }}_{{ build_number }}.sqsh {{ deploy_code.mount_sync }}/{{ project_name }}_{{ build_type }}.sqsh" + run_once: true + + - name: Check if we have a SquashFS image already there. + ansible.builtin.stat: + path: "{{ build_base_path }}/deploy.sqsh" + register: _deploy_code_mount_image + + - name: Copy previous SquashFS image to shared mount point in case of rollback. + ansible.builtin.copy: + remote_src: true + force: true + src: "{{ build_base_path }}/deploy.sqsh" + dest: "{{ deploy_code.mount_sync }}/{{ project_name }}_{{ build_type }}_previous.sqsh" + when: + - _deploy_code_mount_image.stat.islnk is defined + run_once: true -- name: Copy SquashFS image to local server. - ansible.builtin.command: - cmd: "cp {{ deploy_code.mount_sync }}/{{ project_name }}_{{ build_type }}.sqsh {{ build_base_path }}/deploy.sqsh" - when: - - deploy_code.mount_sync is defined - - deploy_code.mount_sync | length > 1 - - deploy_code.mount_type == "squashfs" + - name: Ensure mounted SquashFS image is deleted. + ansible.builtin.file: + path: "{{ build_base_path }}/deploy.sqsh" + state: absent + + - name: Copy SquashFS image to local server. + ansible.builtin.command: + cmd: "cp {{ deploy_code.mount_sync }}/{{ project_name }}_{{ build_type }}.sqsh {{ build_base_path }}/deploy.sqsh" -- name: Unmount and remount squashfs images. - when: - - deploy_code.mount_sync is defined - - deploy_code.mount_sync | length > 1 - - deploy_code.mount_type == "squashfs" - block: - name: Check if we have a mount already. ansible.builtin.shell: cmd: "set -o pipefail && mount | grep {{ deploy_base_path }}" @@ -224,6 +195,11 @@ - _deploy_code_mount_check.rc == 0 - deploy_code.service_action == "stop" - deploy_code.services | length > 0 + when: + - deploy_code.mount_sync is defined + - deploy_code.mount_sync | length > 1 + - deploy_code.mount_type == "squashfs" +# End of the squashFS block. - name: Trigger an infrastructure rebuild. ansible.builtin.include_role: From 864f32f77d954cf368a26fee7956ab75e69b0838 Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 24 Jan 2024 01:12:47 +0200 Subject: [PATCH 04/11] r65896-cache-clear-dir --- roles/_init/tasks/main.yml | 21 ++++++++++++++++++- .../cache_clear-drupal8/tasks/main.yml | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index aa5549dd..676d97bd 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -3,27 +3,35 @@ - name: Define deploy user. ansible.builtin.set_fact: deploy_user: "{{ deploy_user | default('deploy') }}" + - name: Define deploy base path. ansible.builtin.set_fact: deploy_base_path: "{{ deploy_base_path | default('/home/{{ deploy_user }}/deploy/{{ project_name }}_{{ build_type }}') }}" + - name: Define mounted directory for assets. ansible.builtin.set_fact: deploy_assets_base_path: "{{ deploy_assets_base_path | default('/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/assets') }}" + - name: Define webroot. ansible.builtin.set_fact: webroot: "{{ webroot | default('web') }}" + - name: Define build deploy path prefix. ansible.builtin.set_fact: deploy_path_prefix: "{{ deploy_base_path }}/{{ project_name }}_{{ build_type }}_build_" + - name: Define build deploy path. ansible.builtin.set_fact: deploy_path: "{{ deploy_path | default('{{ deploy_path_prefix }}{{ build_number }}') }}" + - name: Define live_symlink dest. ansible.builtin.set_fact: live_symlink_dest: "{{ live_symlink_dest | default('{{ deploy_base_path }}/live.{{ project_name }}_{{ build_type }}') }}" + - name: Define opcache cachetool path. ansible.builtin.set_fact: cachetool_bin: "{{ deploy_base_path }}/cachetool.phar" + - name: Set opcache cachetool path from variable if provided. ansible.builtin.set_fact: cachetool_bin: "{{ cache_clear_opcache.cachetool_bin }}" @@ -31,6 +39,18 @@ - cache_clear_opcache.cachetool_bin is defined - cache_clear_opcache.cachetool_bin | length > 0 +- name: Define path to clear cache. + ansible.builtin.set_fact: + cache_clear_base_path: "{{ deploy_path }}" + when: + - deploy_operation != 'cleanup' + +- name: Define path to clear cache. + ansible.builtin.set_fact: + cache_clear_base_path: "{{ cache_clear_base_path | default('{{ deploy_path_prefix }}{{ build_number }}') }}" + when: + - deploy_operation == 'cleanup' + - name: Manipulate variables for SquashFS builds. block: - name: Define image builds base path. @@ -62,7 +82,6 @@ when: - deploy_code.mount_type is defined - deploy_code.mount_type == "squashfs" - - deploy_operation == 'deploy' # Gather last known good build directly from symlink. # This can happen: diff --git a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml index 92db6584..e16ab252 100644 --- a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml +++ b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml @@ -2,7 +2,7 @@ - name: Clear Drupal cache. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site_drupal.folder }} -y cr" - chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site_drupal.folder }}" + chdir: "{{ cache_clear_base_path }}/{{ webroot }}/sites/{{ site_drupal.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" with_items: "{{ drupal.sites }}" From 2a5a3407cbebaa4e36f68f60f392a328a3c5ece2 Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 24 Jan 2024 01:34:32 +0200 Subject: [PATCH 05/11] r65896-cache-clear-dir --- roles/_init/tasks/main.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index 676d97bd..21b48dc3 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -39,18 +39,6 @@ - cache_clear_opcache.cachetool_bin is defined - cache_clear_opcache.cachetool_bin | length > 0 -- name: Define path to clear cache. - ansible.builtin.set_fact: - cache_clear_base_path: "{{ deploy_path }}" - when: - - deploy_operation != 'cleanup' - -- name: Define path to clear cache. - ansible.builtin.set_fact: - cache_clear_base_path: "{{ cache_clear_base_path | default('{{ deploy_path_prefix }}{{ build_number }}') }}" - when: - - deploy_operation == 'cleanup' - - name: Manipulate variables for SquashFS builds. block: - name: Define image builds base path. @@ -83,6 +71,18 @@ - deploy_code.mount_type is defined - deploy_code.mount_type == "squashfs" +- name: Define path to clear cache for the deploy step. + ansible.builtin.set_fact: + cache_clear_base_path: "{{ deploy_path }}" + when: + - deploy_operation != 'cleanup' + +- name: Define path to clear cache for the cleanup step. + ansible.builtin.set_fact: + cache_clear_base_path: "{{ cache_clear_base_path | default('{{ deploy_path_prefix }}{{ build_number }}') }}" + when: + - deploy_operation == 'cleanup' + # Gather last known good build directly from symlink. # This can happen: # - when the first builds failed, From d5d238c42e612a680812524826222ca2218bda16 Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 24 Jan 2024 11:21:38 +0200 Subject: [PATCH 06/11] r65896-cache-clear-dir --- .../cache_clear-drupal8/tasks/main.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml index e16ab252..f8ba1228 100644 --- a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml +++ b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: Clear Drupal cache. +- name: Clear Drupal cache, drush is in site build dir. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site_drupal.folder }} -y cr" chdir: "{{ cache_clear_base_path }}/{{ webroot }}/sites/{{ site_drupal.folder }}" @@ -10,6 +10,22 @@ loop_var: site_drupal run_once: true register: _drush_output + when: + - deploy_operation != 'cleanup' + +- name: Clear Drupal cache, drush is in site live dir. + ansible.builtin.command: + cmd: "{{ drush_live_bin }} -l {{ site_drupal.folder }} -y cr" + chdir: "{{ cache_clear_base_path }}/{{ webroot }}/sites/{{ site_drupal.folder }}" + become: "{{ 'no' if www_user == deploy_user else 'yes' }}" + become_user: "{{ www_user }}" + with_items: "{{ drupal.sites }}" + loop_control: + loop_var: site_drupal + run_once: true + register: _drush_output + when: + - deploy_operation == 'cleanup' - name: Show drush output. ansible.builtin.debug: From b5298fc519bdaa02d2d3c3cc5e2f11888150c8c0 Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 24 Jan 2024 12:19:02 +0200 Subject: [PATCH 07/11] r65896-cache-clear-dir --- roles/_init/tasks/drupal8.yml | 2 +- .../cache_clear-drupal8/tasks/main.yml | 22 +++++-------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/roles/_init/tasks/drupal8.yml b/roles/_init/tasks/drupal8.yml index 3792c489..478b4426 100644 --- a/roles/_init/tasks/drupal8.yml +++ b/roles/_init/tasks/drupal8.yml @@ -5,4 +5,4 @@ - name: Define path to drush for currently live build. set_fact: - drush_live_bin: "{{ drush_live_bin | default('{{ live_symlink_dest }}/vendor/bin/drush') }}" \ No newline at end of file + drush_live_bin: "{{ drush_live_bin | default('{{ live_symlink_dest }}/vendor/bin/drush') }}" diff --git a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml index f8ba1228..a4a4203a 100644 --- a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml +++ b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml @@ -1,21 +1,13 @@ --- -- name: Clear Drupal cache, drush is in site build dir. - ansible.builtin.command: - cmd: "{{ drush_bin }} -l {{ site_drupal.folder }} -y cr" - chdir: "{{ cache_clear_base_path }}/{{ webroot }}/sites/{{ site_drupal.folder }}" - become: "{{ 'no' if www_user == deploy_user else 'yes' }}" - become_user: "{{ www_user }}" - with_items: "{{ drupal.sites }}" - loop_control: - loop_var: site_drupal - run_once: true - register: _drush_output +- name: Override path to drush_bin on the cleanup step. + set_fact: + drush_bin: "{{ drush_live_bin }}" when: - - deploy_operation != 'cleanup' + - deploy_operation == 'cleanup' -- name: Clear Drupal cache, drush is in site live dir. +- name: Clear Drupal cache. ansible.builtin.command: - cmd: "{{ drush_live_bin }} -l {{ site_drupal.folder }} -y cr" + cmd: "{{ drush_bin }} -l {{ site_drupal.folder }} -y cr" chdir: "{{ cache_clear_base_path }}/{{ webroot }}/sites/{{ site_drupal.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" @@ -24,8 +16,6 @@ loop_var: site_drupal run_once: true register: _drush_output - when: - - deploy_operation == 'cleanup' - name: Show drush output. ansible.builtin.debug: From b9c4b3bee86275f2f72cdf2853b57c9b8bba7b2a Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 24 Jan 2024 12:24:22 +0200 Subject: [PATCH 08/11] r65896-cache-clear-dir --- roles/_init/tasks/main.yml | 6 ++++++ roles/cache_clear/cache_clear-drupal8/tasks/main.yml | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index 21b48dc3..cecc89e2 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -67,6 +67,12 @@ ansible.builtin.file: path: "{{ build_base_path }}" state: directory + + - name: Override path to drush_bin on the cleanup step. + set_fact: + drush_bin: "{{ drush_live_bin }}" + when: + - deploy_operation == 'cleanup' when: - deploy_code.mount_type is defined - deploy_code.mount_type == "squashfs" diff --git a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml index a4a4203a..e16ab252 100644 --- a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml +++ b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml @@ -1,10 +1,4 @@ --- -- name: Override path to drush_bin on the cleanup step. - set_fact: - drush_bin: "{{ drush_live_bin }}" - when: - - deploy_operation == 'cleanup' - - name: Clear Drupal cache. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site_drupal.folder }} -y cr" From 98e84cccb627bbfeb0977e2af4576db7657b1ed1 Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 24 Jan 2024 12:41:57 +0200 Subject: [PATCH 09/11] r65896-cache-clear-dir --- roles/_init/tasks/drupal8.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/roles/_init/tasks/drupal8.yml b/roles/_init/tasks/drupal8.yml index 478b4426..19e7204d 100644 --- a/roles/_init/tasks/drupal8.yml +++ b/roles/_init/tasks/drupal8.yml @@ -6,3 +6,9 @@ - name: Define path to drush for currently live build. set_fact: drush_live_bin: "{{ drush_live_bin | default('{{ live_symlink_dest }}/vendor/bin/drush') }}" + +- name: Override path to drush_bin on the cleanup step. + set_fact: + drush_bin: "{{ drush_live_bin }}" + when: + - deploy_operation == 'cleanup' From 3632ee4c7b2cdb44d4a127fc80b8b0d71444a2bf Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 24 Jan 2024 13:20:34 +0200 Subject: [PATCH 10/11] r65896-cache-clear-dir --- roles/_init/tasks/drupal8.yml | 6 ------ roles/_init/tasks/main.yml | 6 ------ roles/cache_clear/cache_clear-drupal8/tasks/main.yml | 6 ++++++ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/roles/_init/tasks/drupal8.yml b/roles/_init/tasks/drupal8.yml index 19e7204d..478b4426 100644 --- a/roles/_init/tasks/drupal8.yml +++ b/roles/_init/tasks/drupal8.yml @@ -6,9 +6,3 @@ - name: Define path to drush for currently live build. set_fact: drush_live_bin: "{{ drush_live_bin | default('{{ live_symlink_dest }}/vendor/bin/drush') }}" - -- name: Override path to drush_bin on the cleanup step. - set_fact: - drush_bin: "{{ drush_live_bin }}" - when: - - deploy_operation == 'cleanup' diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index cecc89e2..21b48dc3 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -67,12 +67,6 @@ ansible.builtin.file: path: "{{ build_base_path }}" state: directory - - - name: Override path to drush_bin on the cleanup step. - set_fact: - drush_bin: "{{ drush_live_bin }}" - when: - - deploy_operation == 'cleanup' when: - deploy_code.mount_type is defined - deploy_code.mount_type == "squashfs" diff --git a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml index e16ab252..a4a4203a 100644 --- a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml +++ b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml @@ -1,4 +1,10 @@ --- +- name: Override path to drush_bin on the cleanup step. + set_fact: + drush_bin: "{{ drush_live_bin }}" + when: + - deploy_operation == 'cleanup' + - name: Clear Drupal cache. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site_drupal.folder }} -y cr" From 7bb6b1d46925a724e613b298156af55bea2aabb4 Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 24 Jan 2024 14:10:01 +0200 Subject: [PATCH 11/11] r65896-cache-clear-dir --- roles/_init/tasks/main.yml | 12 ------------ .../cache_clear-drupal8/tasks/main.yml | 15 +++++++++++---- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index 21b48dc3..225e9b60 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -71,18 +71,6 @@ - deploy_code.mount_type is defined - deploy_code.mount_type == "squashfs" -- name: Define path to clear cache for the deploy step. - ansible.builtin.set_fact: - cache_clear_base_path: "{{ deploy_path }}" - when: - - deploy_operation != 'cleanup' - -- name: Define path to clear cache for the cleanup step. - ansible.builtin.set_fact: - cache_clear_base_path: "{{ cache_clear_base_path | default('{{ deploy_path_prefix }}{{ build_number }}') }}" - when: - - deploy_operation == 'cleanup' - # Gather last known good build directly from symlink. # This can happen: # - when the first builds failed, diff --git a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml index a4a4203a..1fc9d2f2 100644 --- a/roles/cache_clear/cache_clear-drupal8/tasks/main.yml +++ b/roles/cache_clear/cache_clear-drupal8/tasks/main.yml @@ -1,14 +1,21 @@ --- -- name: Override path to drush_bin on the cleanup step. - set_fact: - drush_bin: "{{ drush_live_bin }}" +- name: Override paths for squashfs build cleanup step. + block: + - name: Override path to drush binary. + set_fact: + drush_bin: "{{ drush_live_bin }}" + - name: Override deploy_path. + set_fact: + deploy_path: "{{ live_symlink_dest }}" when: + - deploy_code.mount_type is defined + - deploy_code.mount_type == "squashfs" - deploy_operation == 'cleanup' - name: Clear Drupal cache. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site_drupal.folder }} -y cr" - chdir: "{{ cache_clear_base_path }}/{{ webroot }}/sites/{{ site_drupal.folder }}" + chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site_drupal.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" with_items: "{{ drupal.sites }}"