From 0a0f3f8957ebf01f53e9c30a6f801def3d6ab4ec Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Tue, 16 Sep 2025 15:37:33 +0200 Subject: [PATCH 1/6] Updating 'default()' filter paths in _init as an initial test. --- roles/_init/tasks/drupal8.yml | 6 +++--- roles/_init/tasks/main.yml | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/roles/_init/tasks/drupal8.yml b/roles/_init/tasks/drupal8.yml index afd1217b..a0501259 100644 --- a/roles/_init/tasks/drupal8.yml +++ b/roles/_init/tasks/drupal8.yml @@ -1,15 +1,15 @@ --- - name: Define path to drush for this build. ansible.builtin.set_fact: - drush_bin: "{{ drush_bin | default('{{ deploy_path }}/vendor/bin/drush') }}" + drush_bin: "{{ drush_bin | default(deploy_path + '/vendor/bin/drush') }}" - name: Define path to drush for previous build. ansible.builtin.set_fact: - previous_drush_bin: "{{ previous_drush_bin | default('{{ previous_deploy_path }}/vendor/bin/drush') }}" + previous_drush_bin: "{{ previous_drush_bin | default(previous_deploy_path + '/vendor/bin/drush') }}" - name: Define path to drush for currently live build. ansible.builtin.set_fact: - drush_live_bin: "{{ drush_live_bin | default('{{ live_symlink_dest }}/vendor/bin/drush') }}" + drush_live_bin: "{{ drush_live_bin | default(live_symlink_dest + '/vendor/bin/drush') }}" - name: Ensure we have a cachetool binary and configuration. ansible.builtin.import_role: diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index b2be45d8..f9c4b618 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -32,11 +32,11 @@ - name: Define deploy base path. ansible.builtin.set_fact: - deploy_base_path: "{{ deploy_base_path | default('/home/{{ deploy_user }}/deploy/{{ project_name }}_{{ build_type }}') }}" + 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') }}" + 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: @@ -53,11 +53,11 @@ - name: Define build deploy path. ansible.builtin.set_fact: - deploy_path: "{{ deploy_path | default('{{ deploy_path_prefix }}{{ build_number }}') }}" + 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 }}') }}" + live_symlink_dest: "{{ live_symlink_dest | default(deploy_base_path + '/live.' + project_name + '_' + build_type) }}" - name: Read the live symlink to get the path to the current build. ansible.builtin.stat: @@ -114,11 +114,11 @@ - 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 }}') }}" + 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 }}') }}" + 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: @@ -206,7 +206,7 @@ - name: Set the previous deploy's path for later use where we need to manipulate the live site. ansible.builtin.set_fact: - previous_deploy_path: "{{ previous_deploy_path | default('{{ deploy_path_prefix }}{{ previous_build_number }}') }}" + previous_deploy_path: "{{ previous_deploy_path | default(deploy_path_prefix + previous_build_number) }}" # Make sure the deploy target exists. - name: Ensure deploy target directory exists. From e3e9bf83d42821fcfa78df6f4a8ff84f8cf9ba60 Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Tue, 16 Sep 2025 15:46:00 +0200 Subject: [PATCH 2/6] Explicitly casting integers as strings for path creation. --- roles/_init/tasks/main.yml | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index f9c4b618..e38f2c49 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -30,31 +30,19 @@ ansible.builtin.set_fact: deploy_user: "{{ deploy_user | default('deploy') }}" -- name: Define deploy base path. +- name: Define deploy paths. 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') }}" + deploy_path_prefix: "{{ deploy_base_path }}/{{ project_name }}_{{ build_type }}_build_" + deploy_path: "{{ deploy_path | default(deploy_path_prefix + build_number|string) }}" # This is passed from caller. - name: Gather last known good build number. ansible.builtin.set_fact: previous_build_number: "{{ previous_known_build_number }}" -- 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) }}" @@ -85,7 +73,7 @@ msg: "Track file ID: {{ previous_build_number }}. Build path ID: {{ _current_build_id }}. These should match, something is wrong, failing the build." when: - _current_build_path.stat.islnk - - _current_build_id | int != previous_build_number | int + - _current_build_id|int != previous_build_number|int - not skip_build_path_check - name: Define opcache cachetool path. @@ -118,7 +106,7 @@ - name: Overwrite deploy and live_symlink paths if SquashFS deploy. ansible.builtin.set_fact: - deploy_path: "{{ build_path | default(build_path_prefix + build_number) }}" + deploy_path: "{{ build_path | default(build_path_prefix + build_number|string) }}" - name: Overwrite cachetool path if SquashFS deploy and path not provided. ansible.builtin.set_fact: @@ -206,7 +194,7 @@ - name: Set the previous deploy's path for later use where we need to manipulate the live site. ansible.builtin.set_fact: - previous_deploy_path: "{{ previous_deploy_path | default(deploy_path_prefix + previous_build_number) }}" + previous_deploy_path: "{{ previous_deploy_path | default(deploy_path_prefix + previous_build_number|string) }}" # Make sure the deploy target exists. - name: Ensure deploy target directory exists. From b3f0807c8182be43d21c32f39ac799cb27c999bf Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Tue, 16 Sep 2025 15:50:21 +0200 Subject: [PATCH 3/6] Over refactored the variable setting! --- roles/_init/tasks/main.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index e38f2c49..00b0553d 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -30,12 +30,18 @@ ansible.builtin.set_fact: deploy_user: "{{ deploy_user | default('deploy') }}" -- name: Define deploy paths. +- name: Define initial deploy paths. ansible.builtin.set_fact: deploy_base_path: "{{ deploy_base_path | default('/home/' + deploy_user + '/deploy/' + project_name + '_' + build_type) }}" deploy_assets_base_path: "{{ deploy_assets_base_path | default('/home/' + deploy_user + '/shared/' + project_name + '_' + build_type + '/assets') }}" webroot: "{{ webroot | default('web') }}" + +- name: Define deploy_path_prefix variable. + ansible.builtin.set_fact: deploy_path_prefix: "{{ deploy_base_path }}/{{ project_name }}_{{ build_type }}_build_" + +- name: Define final deploy_path variable. + ansible.builtin.set_fact: deploy_path: "{{ deploy_path | default(deploy_path_prefix + build_number|string) }}" # This is passed from caller. From 3b9b024395f5a0b5a56203471caea8e4b15b3d4f Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Tue, 16 Sep 2025 18:04:19 +0200 Subject: [PATCH 4/6] Fixing Drupal 7 include in _init. --- roles/_init/tasks/custom.yml | 3 +-- roles/_init/tasks/drupal7.yml | 13 +++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/roles/_init/tasks/custom.yml b/roles/_init/tasks/custom.yml index 6f34c92f..0ce85358 100644 --- a/roles/_init/tasks/custom.yml +++ b/roles/_init/tasks/custom.yml @@ -1,3 +1,2 @@ --- - -# Nothing to do here. \ No newline at end of file +# Nothing to do here. diff --git a/roles/_init/tasks/drupal7.yml b/roles/_init/tasks/drupal7.yml index f6919125..08df1c76 100644 --- a/roles/_init/tasks/drupal7.yml +++ b/roles/_init/tasks/drupal7.yml @@ -1,14 +1,11 @@ --- -- name: Define path to drush for this build. - set_fact: - drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush.phar') }}" - -- name: Define path to drush for currently live build. # usually the same as drush_bin for Drupal 7 - set_fact: - drush_live_bin: "{{ drush_live_bin | default('{{ bin_directory }}/drush.phar') }}" +- name: Define paths to drush for this build. + ansible.builtin.set_fact: + drush_bin: "{{ drush_bin | default(bin_directory + '/drush.phar') }}" + drush_live_bin: "{{ drush_live_bin | default(bin_directory + '/drush.phar') }}" # usually the same as drush_bin for Drupal 7 - name: Ensure we have a drush binary. - import_role: + ansible.builtin.import_role: name: cli/drush - name: Ensure we have a cachetool binary and configuration. From a43bca15155989687ff923e21e8f1f25495f64ee Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Wed, 17 Sep 2025 15:55:26 +0200 Subject: [PATCH 5/6] Another string truthy bug for Ansible 12. --- roles/database_apply/database_apply-drupal8/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/database_apply/database_apply-drupal8/tasks/main.yml b/roles/database_apply/database_apply-drupal8/tasks/main.yml index 7915d95f..a5734a60 100644 --- a/roles/database_apply/database_apply-drupal8/tasks/main.yml +++ b/roles/database_apply/database_apply-drupal8/tasks/main.yml @@ -128,7 +128,7 @@ loop_var: site when: - previous_build_number > 0 - - site.config_import_command + - site.config_import_command | length > 0 register: _drush_output - name: Show drush output. From 286208c1fec4b9d83ae5835846e544b207300d78 Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Wed, 24 Sep 2025 10:44:19 +0200 Subject: [PATCH 6/6] Removing duplication in Mautic cron job paths. --- roles/cron/cron_mautic/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/cron/cron_mautic/tasks/main.yml b/roles/cron/cron_mautic/tasks/main.yml index 403536dd..92173127 100644 --- a/roles/cron/cron_mautic/tasks/main.yml +++ b/roles/cron/cron_mautic/tasks/main.yml @@ -8,7 +8,7 @@ name: "{{ project_name }}_{{ build_type }}_{{ entry.job }}" minute: "{{ entry.minute }}" hour: "{{ entry.hour | default(omit) }}" - job: "env php {{ symfony_console_bin }} {{ entry.job }}" + job: "{{ symfony_console_bin }} {{ entry.job }}" with_items: "{{ cron_mautic.entries }}" loop_control: loop_var: entry