From 52477fd5c8d9f217b0607df8daa1c4dd207f505f Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 15 Mar 2023 10:17:37 +0100 Subject: [PATCH 1/2] Refactoring cachetool path setting to match other squashfs vars. --- roles/_init/tasks/main.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index e939def3..7f28f3ff 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -21,6 +21,9 @@ - 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: "{{ cachetool_bin | default('{{ deploy_base_path }}/cachetool.phar') }}" # Manipulate variables for SquashFS builds. - name: Define image builds base path. @@ -47,6 +50,12 @@ when: - deploy_code.mount_type is defined - deploy_code.mount_type == "squashfs" +- name: Overwrite cachetool path if SquashFS deploy. + ansible.builtin.set_fact: + cachetool_bin: "{{ cachetool_bin | default('{{ build_base_path }}/cachetool.phar') }}" + when: + - deploy_code.mount_type is defined + - deploy_code.mount_type == "squashfs" # Gather last known good build directly from symlink. # This can happen: @@ -105,18 +114,6 @@ when: - _project_type_task_result.stat.exists -- name: Define opcache cachetool path. - ansible.builtin.set_fact: - cachetool_bin: "{{ cachetool_bin | default('{{ deploy_base_path }}/cachetool.phar') }}" - when: deploy_code.mount_type != "squashfs" - -- name: Define opcache cachetool path if SquashFS deploy. - ansible.builtin.set_fact: - cachetool_bin: "{{ cachetool_bin | default('{{ build_base_path }}/cachetool.phar') }}" - when: - - deploy_code.mount_type is defined - - deploy_code.mount_type == "squashfs" - - name: Ensure we have a cachetool binary. ansible.builtin.import_role: name: cli/cachetool From d1e530fb0160d2fd26810b2cd85c8413ed371447 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 15 Mar 2023 12:52:15 +0100 Subject: [PATCH 2/2] Refactoring cachetool_bin handling. --- docs/roles/cache_clear/cache_clear-opcache.md | 1 + roles/_init/tasks/main.yml | 10 +++++++++- roles/cache_clear/cache_clear-opcache/README.md | 1 + .../cache_clear/cache_clear-opcache/defaults/main.yml | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/roles/cache_clear/cache_clear-opcache.md b/docs/roles/cache_clear/cache_clear-opcache.md index c7959bcb..465307e2 100644 --- a/docs/roles/cache_clear/cache_clear-opcache.md +++ b/docs/roles/cache_clear/cache_clear-opcache.md @@ -19,6 +19,7 @@ cache_clear_opcache: clear_opcache: true clear_apcu: false clear_stat: false + # cachetool_bin: "/path/to/cachetool.phar" # see _init for paths if undefined ``` diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index 7f28f3ff..f68be544 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -23,7 +23,14 @@ 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: "{{ cachetool_bin | default('{{ deploy_base_path }}/cachetool.phar') }}" + cachetool_bin: "{{ deploy_base_path }}/cachetool.phar" + when: cache_clear_opcache.cachetool_bin is not defined +- name: Set opcache cachetool path from variable. + ansible.builtin.set_fact: + cachetool_bin: "{{ cache_clear_opcache.cachetool_bin }}" + when: + - 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. @@ -56,6 +63,7 @@ when: - deploy_code.mount_type is defined - deploy_code.mount_type == "squashfs" + - cache_clear_opcache.cachetool_bin is not defined # Gather last known good build directly from symlink. # This can happen: diff --git a/roles/cache_clear/cache_clear-opcache/README.md b/roles/cache_clear/cache_clear-opcache/README.md index c7959bcb..465307e2 100644 --- a/roles/cache_clear/cache_clear-opcache/README.md +++ b/roles/cache_clear/cache_clear-opcache/README.md @@ -19,6 +19,7 @@ cache_clear_opcache: clear_opcache: true clear_apcu: false clear_stat: false + # cachetool_bin: "/path/to/cachetool.phar" # see _init for paths if undefined ``` diff --git a/roles/cache_clear/cache_clear-opcache/defaults/main.yml b/roles/cache_clear/cache_clear-opcache/defaults/main.yml index 97623e62..222325ce 100644 --- a/roles/cache_clear/cache_clear-opcache/defaults/main.yml +++ b/roles/cache_clear/cache_clear-opcache/defaults/main.yml @@ -9,3 +9,4 @@ cache_clear_opcache: clear_opcache: true clear_apcu: false clear_stat: false + # cachetool_bin: "/path/to/cachetool.phar" # see _init for paths if undefined