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 }}"