From 3f23647383d9869da0032a4b84adee18e0cbc14a Mon Sep 17 00:00:00 2001 From: Drazen Date: Fri, 29 Nov 2024 15:55:32 +0100 Subject: [PATCH 01/22] Updating-cron-path-fixing-mailto --- roles/cron/cron_drupal7/defaults/main.yml | 2 +- roles/cron/cron_drupal7/tasks/job.yml | 4 ++-- roles/cron/cron_drupal8/defaults/main.yml | 2 +- roles/cron/cron_drupal8/tasks/job.yml | 9 ++------- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/roles/cron/cron_drupal7/defaults/main.yml b/roles/cron/cron_drupal7/defaults/main.yml index 4dc29105..636557ca 100644 --- a/roles/cron/cron_drupal7/defaults/main.yml +++ b/roles/cron/cron_drupal7/defaults/main.yml @@ -12,7 +12,7 @@ drupal: # month: job: cron # disabled: true - mailto: "{{ drupal.cron_mailto | default('') }}" + # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index f2eb2ff7..ee1a136c 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -1,7 +1,7 @@ --- - name: Define cron job command. ansible.builtin.set_fact: - _cron_job_command: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }}" + _cron_job_command: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }} > /dev/null 2>&1" - name: Define cron job command if deferred (ASG). ansible.builtin.set_fact: @@ -31,5 +31,5 @@ job: "{{ _cron_job_command }}" state: present disabled: "{{ entry.disabled | default(omit) }}" - mailto: "{{ entry.mailto if entry.mailto is defined else omit }}" + mailto: "{{ entry.mailto | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/defaults/main.yml b/roles/cron/cron_drupal8/defaults/main.yml index 4dc29105..636557ca 100644 --- a/roles/cron/cron_drupal8/defaults/main.yml +++ b/roles/cron/cron_drupal8/defaults/main.yml @@ -12,7 +12,7 @@ drupal: # month: job: cron # disabled: true - mailto: "{{ drupal.cron_mailto | default('') }}" + # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 77f3c6ae..e58a2d92 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -1,14 +1,9 @@ --- - name: Define cron job command. ansible.builtin.set_fact: - _cron_job_command: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }}" + _cron_job_command: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }} > /dev/null 2>&1" when: deploy_operation == "deploy" -- name: Revert cron job command. - ansible.builtin.set_fact: - _cron_job_command: "cd {{ previous_deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }}" - when: deploy_operation == "revert" - - name: Define cron job command if deferred (ASG). ansible.builtin.set_fact: _cron_job_command: "cd {{ _ce_deploy_base_dir }} && {{ _ce_deploy_ansible_location }} {{ drupal.defer_target }} -m shell -a \"{{ _cron_job_command }}\"" @@ -37,5 +32,5 @@ job: "{{ _cron_job_command }}" state: present disabled: "{{ entry.disabled | default(omit) }}" - mailto: "{{ entry.mailto if entry.mailto is defined else omit }}" + mailto: "{{ entry.mailto | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From d4b7796014d71e6ca3db748e71507d515ecd7cf3 Mon Sep 17 00:00:00 2001 From: Drazen Date: Fri, 29 Nov 2024 15:57:13 +0100 Subject: [PATCH 02/22] Adding-md --- docs/_Sidebar.md | 1 + docs/roles/cache_clear/cache_clear-symfony.md | 14 ++++++++++++++ docs/roles/cron/cron_drupal7.md | 3 +++ docs/roles/cron/cron_drupal8.md | 2 ++ docs/roles/deploy_code.md | 8 ++++++++ .../sync/database_sync/database_sync-mysql.md | 6 +++++- roles/cache_clear/cache_clear-symfony/README.md | 7 +++++++ roles/cron/cron_drupal7/README.md | 3 +++ roles/cron/cron_drupal8/README.md | 2 ++ roles/deploy_code/README.md | 8 ++++++++ .../database_sync/database_sync-mysql/README.md | 6 +++++- 11 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 docs/roles/cache_clear/cache_clear-symfony.md diff --git a/docs/_Sidebar.md b/docs/_Sidebar.md index b8c4d52e..b1f28b08 100644 --- a/docs/_Sidebar.md +++ b/docs/_Sidebar.md @@ -10,6 +10,7 @@ - [Matomo](/roles/cache_clear/cache_clear-matomo) - [Drupal 8](/roles/cache_clear/cache_clear-mautic) - [Opcache](/roles/cache_clear/cache_clear-opcache) + - [Symfony](/roles/cache_clear/cache_clear-symfony) - [ce-dev](/roles/ce_dev) - [ce-dev prebuild](/roles/ce_dev/ce_dev_prebuild) - [CLI Tools](/roles/cli) diff --git a/docs/roles/cache_clear/cache_clear-symfony.md b/docs/roles/cache_clear/cache_clear-symfony.md new file mode 100644 index 00000000..65c608f9 --- /dev/null +++ b/docs/roles/cache_clear/cache_clear-symfony.md @@ -0,0 +1,14 @@ +# Symfony +Clears the Symfony application cache. + + + + +## Default variables +```yaml +--- +cache_clear_symfony_env: prod + +``` + + diff --git a/docs/roles/cron/cron_drupal7.md b/docs/roles/cron/cron_drupal7.md index 14356d15..dd46727a 100644 --- a/docs/roles/cron/cron_drupal7.md +++ b/docs/roles/cron/cron_drupal7.md @@ -19,11 +19,14 @@ drupal: # month: job: cron # disabled: true + # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. + cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] defer_target: "" drush_location: "{{ drush_bin }}" # you might specify another location, e.g. "{{ deploy_path }}/vendor/bin/drush" + ``` diff --git a/docs/roles/cron/cron_drupal8.md b/docs/roles/cron/cron_drupal8.md index bafd49b0..7ff5f24c 100644 --- a/docs/roles/cron/cron_drupal8.md +++ b/docs/roles/cron/cron_drupal8.md @@ -19,6 +19,8 @@ drupal: # month: job: cron # disabled: true + # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. + cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] diff --git a/docs/roles/deploy_code.md b/docs/roles/deploy_code.md index 634dbbe5..b3860144 100644 --- a/docs/roles/deploy_code.md +++ b/docs/roles/deploy_code.md @@ -85,7 +85,15 @@ Deploying code with autoscaling clusters relies on [cloud-init](https://cloudini ## Default variables ```yaml --- +# Required for NGINX config in feature branching. +_ce_provision_data_dir: /home/deploy/ce-deploy/data + deploy_code: + # Feature branching config. + feature_branch: + enabled: false + # NGINX domains to build, see ce-provision for docs: https://github.com/codeenigma/ce-provision/blob/2.x/roles/debian/nginx/defaults/main.yml#L133 + domains: [] # Specify any additional symlink to create, with src (target) and dest (link). # src: can be either absolute or relative to the dest (eg. '/var/my_data', '/home/deploy/simplesaml', '../../../myconfig') # dest: can only be relative to the root of your repository (eg. 'www/themes/myassets', 'var/cache') diff --git a/docs/roles/sync/database_sync/database_sync-mysql.md b/docs/roles/sync/database_sync/database_sync-mysql.md index ab07346d..1fd2afe8 100644 --- a/docs/roles/sync/database_sync/database_sync-mysql.md +++ b/docs/roles/sync/database_sync/database_sync-mysql.md @@ -25,8 +25,9 @@ mysql_sync: credentials_file: "/home/{{ deploy_user }}/.mysql.creds" # This can be of types: # - rolling: (database backups). In that case we'll need build parameters.@todo - # - fixed: "fixed" database name + # - fixed: "fixed" database name # currently this var means the same as "dump" # - dump: Use an existing dump. In that case, the "database" variable is the absolute file path. + # This parameter is ignored if var 'path_on_deploy_server' is defined. type: fixed # For "rolling builds", so we can compute the database name. build_id: mybuildprod @@ -37,6 +38,9 @@ mysql_sync: dumps_directory: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/db_backups/mysql/regular" # If the source is on an ASG, provide the ASG name here. Otherwise, leave empty. asg: "" + # Uncomment and specify full path if you want to use your own dump file on the deploy server (gzip compressed). + # In this case it's the only variable you need in 'database.source'. + #path_on_deploy_server: "/home/{{ deploy_user }}/compressed_database_dump.gz" target: database: "{{ project_name }}_dev" credentials_file: "/home/{{ deploy_user }}/.mysql.creds" diff --git a/roles/cache_clear/cache_clear-symfony/README.md b/roles/cache_clear/cache_clear-symfony/README.md index 8bb3fde2..65c608f9 100644 --- a/roles/cache_clear/cache_clear-symfony/README.md +++ b/roles/cache_clear/cache_clear-symfony/README.md @@ -4,4 +4,11 @@ Clears the Symfony application cache. +## Default variables +```yaml +--- +cache_clear_symfony_env: prod + +``` + diff --git a/roles/cron/cron_drupal7/README.md b/roles/cron/cron_drupal7/README.md index 14356d15..dd46727a 100644 --- a/roles/cron/cron_drupal7/README.md +++ b/roles/cron/cron_drupal7/README.md @@ -19,11 +19,14 @@ drupal: # month: job: cron # disabled: true + # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. + cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] defer_target: "" drush_location: "{{ drush_bin }}" # you might specify another location, e.g. "{{ deploy_path }}/vendor/bin/drush" + ``` diff --git a/roles/cron/cron_drupal8/README.md b/roles/cron/cron_drupal8/README.md index bafd49b0..7ff5f24c 100644 --- a/roles/cron/cron_drupal8/README.md +++ b/roles/cron/cron_drupal8/README.md @@ -19,6 +19,8 @@ drupal: # month: job: cron # disabled: true + # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. + cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] diff --git a/roles/deploy_code/README.md b/roles/deploy_code/README.md index 634dbbe5..b3860144 100644 --- a/roles/deploy_code/README.md +++ b/roles/deploy_code/README.md @@ -85,7 +85,15 @@ Deploying code with autoscaling clusters relies on [cloud-init](https://cloudini ## Default variables ```yaml --- +# Required for NGINX config in feature branching. +_ce_provision_data_dir: /home/deploy/ce-deploy/data + deploy_code: + # Feature branching config. + feature_branch: + enabled: false + # NGINX domains to build, see ce-provision for docs: https://github.com/codeenigma/ce-provision/blob/2.x/roles/debian/nginx/defaults/main.yml#L133 + domains: [] # Specify any additional symlink to create, with src (target) and dest (link). # src: can be either absolute or relative to the dest (eg. '/var/my_data', '/home/deploy/simplesaml', '../../../myconfig') # dest: can only be relative to the root of your repository (eg. 'www/themes/myassets', 'var/cache') diff --git a/roles/sync/database_sync/database_sync-mysql/README.md b/roles/sync/database_sync/database_sync-mysql/README.md index ab07346d..1fd2afe8 100644 --- a/roles/sync/database_sync/database_sync-mysql/README.md +++ b/roles/sync/database_sync/database_sync-mysql/README.md @@ -25,8 +25,9 @@ mysql_sync: credentials_file: "/home/{{ deploy_user }}/.mysql.creds" # This can be of types: # - rolling: (database backups). In that case we'll need build parameters.@todo - # - fixed: "fixed" database name + # - fixed: "fixed" database name # currently this var means the same as "dump" # - dump: Use an existing dump. In that case, the "database" variable is the absolute file path. + # This parameter is ignored if var 'path_on_deploy_server' is defined. type: fixed # For "rolling builds", so we can compute the database name. build_id: mybuildprod @@ -37,6 +38,9 @@ mysql_sync: dumps_directory: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/db_backups/mysql/regular" # If the source is on an ASG, provide the ASG name here. Otherwise, leave empty. asg: "" + # Uncomment and specify full path if you want to use your own dump file on the deploy server (gzip compressed). + # In this case it's the only variable you need in 'database.source'. + #path_on_deploy_server: "/home/{{ deploy_user }}/compressed_database_dump.gz" target: database: "{{ project_name }}_dev" credentials_file: "/home/{{ deploy_user }}/.mysql.creds" From 381aecc48916de9a646d1dbef71d6bc3974ec65a Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 10 Dec 2024 09:34:59 +0100 Subject: [PATCH 03/22] Using-cronvar-module --- roles/cron/cron_drupal7/tasks/job.yml | 15 ++++++++++++++- roles/cron/cron_drupal8/tasks/job.yml | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index ee1a136c..864f6f91 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -20,6 +20,20 @@ - drupal.defer is defined - drupal.defer +- name: Set global MAILTO for cron jobs (if defined) + community.general.cronvar: + name: MAILTO + value: "{{ drupal.cron_mailto | default(omit) }}" + state: present + when: drupal.cron_mailto is defined and drupal.cron_mailto != "" + +- name: Setup specific cron job with custom MAILTO + community.general.cronvar: + name: MAILTO + value: "{{ entry.mailto | default(drupal.cron_mailto | default(omit)) }}" + state: present + when: entry.mailto is defined + - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: name: "{{ project_name }}_{{ site.folder }}_{{ build_type }}_{{ entry.job }}" @@ -31,5 +45,4 @@ job: "{{ _cron_job_command }}" state: present disabled: "{{ entry.disabled | default(omit) }}" - mailto: "{{ entry.mailto | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index e58a2d92..b67f4b3b 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -21,6 +21,20 @@ - drupal.defer is defined - drupal.defer +- name: Set global MAILTO for cron jobs (if defined) + community.general.cronvar: + name: MAILTO + value: "{{ drupal.cron_mailto | default(omit) }}" + state: present + when: drupal.cron_mailto is defined and drupal.cron_mailto != "" + +- name: Setup specific cron job with custom MAILTO + community.general.cronvar: + name: MAILTO + value: "{{ entry.mailto | default(drupal.cron_mailto | default(omit)) }}" + state: present + when: entry.mailto is defined + - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: name: "{{ project_name }}_{{ site.folder }}_{{ build_type }}_{{ entry.job }}" @@ -32,5 +46,4 @@ job: "{{ _cron_job_command }}" state: present disabled: "{{ entry.disabled | default(omit) }}" - mailto: "{{ entry.mailto | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From c1932f80a8deeadde6636c32a0358c5dfaea373f Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 10 Dec 2024 09:46:22 +0100 Subject: [PATCH 04/22] Fixing-linting-condition --- roles/cron/cron_drupal7/tasks/job.yml | 2 +- roles/cron/cron_drupal8/tasks/job.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 864f6f91..df0722d2 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -25,7 +25,7 @@ name: MAILTO value: "{{ drupal.cron_mailto | default(omit) }}" state: present - when: drupal.cron_mailto is defined and drupal.cron_mailto != "" + when: drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 - name: Setup specific cron job with custom MAILTO community.general.cronvar: diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index b67f4b3b..71eb0d9f 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -26,7 +26,7 @@ name: MAILTO value: "{{ drupal.cron_mailto | default(omit) }}" state: present - when: drupal.cron_mailto is defined and drupal.cron_mailto != "" + when: drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 - name: Setup specific cron job with custom MAILTO community.general.cronvar: From c4f46f3c83188867a6fa0c6974e1f4bc66cb066a Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 10 Dec 2024 10:01:07 +0100 Subject: [PATCH 05/22] Adding-mailto-dynamically-for-specific-jobs --- roles/cron/cron_drupal7/tasks/job.yml | 5 ++++- roles/cron/cron_drupal8/tasks/job.yml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index df0722d2..ba6109be 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -42,7 +42,10 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: "{{ _cron_job_command }}" + job: | + {% if entry.mailto is defined %} + MAILTO={{ entry.mailto }} + {% endif %} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 71eb0d9f..d1e41df6 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -43,7 +43,10 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: "{{ _cron_job_command }}" + job: | + {% if entry.mailto is defined %} + MAILTO={{ entry.mailto }} + {% endif %} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From 883ba2114aef9f803f9db29c57743c6b4da6f732 Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 10 Dec 2024 10:18:28 +0100 Subject: [PATCH 06/22] Fixing-incorrect-crontab-entries --- roles/cron/cron_drupal8/tasks/job.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index d1e41df6..0b4944e3 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -28,12 +28,14 @@ state: present when: drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 -- name: Setup specific cron job with custom MAILTO +- name: Setup specific MAILTO for cron jobs. community.general.cronvar: name: MAILTO value: "{{ entry.mailto | default(drupal.cron_mailto | default(omit)) }}" state: present - when: entry.mailto is defined + when: + - entry.mailto is defined + - entry.mailto | length > 0 - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: @@ -43,10 +45,7 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: | - {% if entry.mailto is defined %} - MAILTO={{ entry.mailto }} - {% endif %} + job: "{{ _cron_job_command }}" state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From e19a4f56b767f49535236ec2c418176fdc5042f2 Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 10 Dec 2024 10:34:07 +0100 Subject: [PATCH 07/22] Updating-condition-for-crons --- roles/cron/cron_drupal8/tasks/job.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 0b4944e3..4c3ce0a8 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -31,11 +31,9 @@ - name: Setup specific MAILTO for cron jobs. community.general.cronvar: name: MAILTO - value: "{{ entry.mailto | default(drupal.cron_mailto | default(omit)) }}" + value: "{{ entry.mailto | default(omit) }}" state: present - when: - - entry.mailto is defined - - entry.mailto | length > 0 + when: entry.mailto is defined and entry.mailto | length > 0 - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: From 965656b71516a5dbc5c56dcb56138f69baeefc19 Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 10 Dec 2024 10:48:21 +0100 Subject: [PATCH 08/22] Updating-condition-for-crons --- roles/cron/cron_drupal7/tasks/job.yml | 15 ++++----------- roles/cron/cron_drupal8/tasks/job.yml | 10 +++------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index ba6109be..f8e8d608 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -27,13 +27,6 @@ state: present when: drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 -- name: Setup specific cron job with custom MAILTO - community.general.cronvar: - name: MAILTO - value: "{{ entry.mailto | default(drupal.cron_mailto | default(omit)) }}" - state: present - when: entry.mailto is defined - - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: name: "{{ project_name }}_{{ site.folder }}_{{ build_type }}_{{ entry.job }}" @@ -42,10 +35,10 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: | - {% if entry.mailto is defined %} - MAILTO={{ entry.mailto }} - {% endif %} + env: + name: MAILTO + value: "{{ entry.mailto | default(drupal.cron_mailto | default('')) }}" + job: "{{ _cron_job_command }}" state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 4c3ce0a8..fdfd4f05 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -28,13 +28,6 @@ state: present when: drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 -- name: Setup specific MAILTO for cron jobs. - community.general.cronvar: - name: MAILTO - value: "{{ entry.mailto | default(omit) }}" - state: present - when: entry.mailto is defined and entry.mailto | length > 0 - - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: name: "{{ project_name }}_{{ site.folder }}_{{ build_type }}_{{ entry.job }}" @@ -43,6 +36,9 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" + env: + name: MAILTO + value: "{{ entry.mailto | default(drupal.cron_mailto | default('')) }}" job: "{{ _cron_job_command }}" state: present disabled: "{{ entry.disabled | default(omit) }}" From a612333e2199701376bedfdcbdfe180e715a5d39 Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 10 Dec 2024 11:09:19 +0100 Subject: [PATCH 09/22] Updating-condition-for-crons --- roles/cron/cron_drupal7/tasks/job.yml | 18 ++++++++++++++---- roles/cron/cron_drupal8/tasks/job.yml | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index f8e8d608..d72306f6 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -27,6 +27,13 @@ state: present when: drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 +- name: Setup specific MAILTO for cron jobs if defined + community.general.cronvar: + name: MAILTO + value: "{{ entry.mailto | default(omit) }}" + state: present + when: entry.mailto is defined and entry.mailto | length > 0 + - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: name: "{{ project_name }}_{{ site.folder }}_{{ build_type }}_{{ entry.job }}" @@ -35,10 +42,13 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - env: - name: MAILTO - value: "{{ entry.mailto | default(drupal.cron_mailto | default('')) }}" - job: "{{ _cron_job_command }}" + job: | + {% if entry.mailto is defined and entry.mailto | length > 0 %} + MAILTO={{ entry.mailto }} + {% elif drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 %} + MAILTO={{ drupal.cron_mailto }} + {% endif %} + {{ cronjob_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index fdfd4f05..59a436f5 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -28,6 +28,13 @@ state: present when: drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 +- name: Setup specific MAILTO for cron jobs if defined + community.general.cronvar: + name: MAILTO + value: "{{ entry.mailto | default(omit) }}" + state: present + when: entry.mailto is defined and entry.mailto | length > 0 + - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: name: "{{ project_name }}_{{ site.folder }}_{{ build_type }}_{{ entry.job }}" @@ -36,10 +43,13 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - env: - name: MAILTO - value: "{{ entry.mailto | default(drupal.cron_mailto | default('')) }}" - job: "{{ _cron_job_command }}" + job: | + {% if entry.mailto is defined and entry.mailto | length > 0 %} + MAILTO={{ entry.mailto }} + {% elif drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 %} + MAILTO={{ drupal.cron_mailto }} + {% endif %} + {{ cronjob_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From 20a8b03dd9dab9dfbab83d4b245a4afd4686553c Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 10 Dec 2024 11:13:49 +0100 Subject: [PATCH 10/22] Updating-condition-for-crons --- roles/cron/cron_drupal7/tasks/job.yml | 2 +- roles/cron/cron_drupal8/tasks/job.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index d72306f6..d2a2c4bc 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -48,7 +48,7 @@ {% elif drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 %} MAILTO={{ drupal.cron_mailto }} {% endif %} - {{ cronjob_command }} + {{ _cronjob_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 59a436f5..69131e58 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -49,7 +49,7 @@ {% elif drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 %} MAILTO={{ drupal.cron_mailto }} {% endif %} - {{ cronjob_command }} + {{ _cronjob_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From 9df40c5afed87d7d5ad416f390ae971dd8957b19 Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 10 Dec 2024 11:21:49 +0100 Subject: [PATCH 11/22] Updating-condition-for-crons --- roles/cron/cron_drupal7/tasks/job.yml | 2 +- roles/cron/cron_drupal8/tasks/job.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index d2a2c4bc..cd96032f 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -48,7 +48,7 @@ {% elif drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 %} MAILTO={{ drupal.cron_mailto }} {% endif %} - {{ _cronjob_command }} + {{ _cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 69131e58..0d996748 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -49,7 +49,7 @@ {% elif drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 %} MAILTO={{ drupal.cron_mailto }} {% endif %} - {{ _cronjob_command }} + {{ _cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From 82b3710e9d719402c5d8fb37bb178656bb78b373 Mon Sep 17 00:00:00 2001 From: Drazen Date: Tue, 10 Dec 2024 11:44:46 +0100 Subject: [PATCH 12/22] Updating-condition-for-crons --- roles/cron/cron_drupal7/tasks/job.yml | 8 +------- roles/cron/cron_drupal8/tasks/job.yml | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index cd96032f..c52d67ce 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -42,13 +42,7 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: | - {% if entry.mailto is defined and entry.mailto | length > 0 %} - MAILTO={{ entry.mailto }} - {% elif drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 %} - MAILTO={{ drupal.cron_mailto }} - {% endif %} - {{ _cron_job_command }} + job: "{{ _cron_job_command }}" state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 0d996748..308d77bb 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -43,13 +43,7 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: | - {% if entry.mailto is defined and entry.mailto | length > 0 %} - MAILTO={{ entry.mailto }} - {% elif drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 %} - MAILTO={{ drupal.cron_mailto }} - {% endif %} - {{ _cron_job_command }} + job: "{{ _cron_job_command }}" state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From d55d9b90d9f65e732e6f58efc53685ffd3965f4e Mon Sep 17 00:00:00 2001 From: Drazen Date: Wed, 11 Dec 2024 10:31:54 +0100 Subject: [PATCH 13/22] Updating-cron-path-fixing-mailto --- roles/cron/cron_drupal7/tasks/job.yml | 11 +++-------- roles/cron/cron_drupal8/tasks/job.yml | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index c52d67ce..f20388e7 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -27,13 +27,6 @@ state: present when: drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 -- name: Setup specific MAILTO for cron jobs if defined - community.general.cronvar: - name: MAILTO - value: "{{ entry.mailto | default(omit) }}" - state: present - when: entry.mailto is defined and entry.mailto | length > 0 - - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: name: "{{ project_name }}_{{ site.folder }}_{{ build_type }}_{{ entry.job }}" @@ -42,7 +35,9 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: "{{ _cron_job_command }}" + job: > + {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %} + {{ cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 308d77bb..9c074d89 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -28,13 +28,6 @@ state: present when: drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 -- name: Setup specific MAILTO for cron jobs if defined - community.general.cronvar: - name: MAILTO - value: "{{ entry.mailto | default(omit) }}" - state: present - when: entry.mailto is defined and entry.mailto | length > 0 - - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: name: "{{ project_name }}_{{ site.folder }}_{{ build_type }}_{{ entry.job }}" @@ -43,7 +36,9 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: "{{ _cron_job_command }}" + job: > + {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %} + {{ cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From 5489bce0f73b771ce6dfe29b7d1e88b185427f16 Mon Sep 17 00:00:00 2001 From: Drazen Date: Wed, 11 Dec 2024 10:49:17 +0100 Subject: [PATCH 14/22] Updating-cron-path-fixing-mailto --- roles/cron/cron_drupal7/tasks/job.yml | 3 +-- roles/cron/cron_drupal8/tasks/job.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index f20388e7..2d301991 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -36,8 +36,7 @@ weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" job: > - {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %} - {{ cron_job_command }} + {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %}{{ cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 9c074d89..4b743469 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -37,8 +37,7 @@ weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" job: > - {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %} - {{ cron_job_command }} + {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %}{{ cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From b4fb7254b2493e45c316e35edfcba88deb03b5cc Mon Sep 17 00:00:00 2001 From: Drazen Date: Wed, 11 Dec 2024 11:25:31 +0100 Subject: [PATCH 15/22] Updating-cron-path-fixing-mailto --- roles/cron/cron_drupal7/tasks/job.yml | 2 +- roles/cron/cron_drupal8/tasks/job.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 2d301991..307c9342 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -36,7 +36,7 @@ weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" job: > - {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %}{{ cron_job_command }} + {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %}{{ _cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 4b743469..e3eeafeb 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -37,7 +37,7 @@ weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" job: > - {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %}{{ cron_job_command }} + {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %}{{ _cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From 6cf1371f1d03effd3431adddaeafa1fa2f17ef42 Mon Sep 17 00:00:00 2001 From: Drazen Date: Wed, 18 Dec 2024 09:32:41 +0100 Subject: [PATCH 16/22] Mailto-filtering --- roles/cron/cron_drupal7/tasks/job.yml | 3 ++- roles/cron/cron_drupal8/tasks/job.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 307c9342..5db27375 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -36,7 +36,8 @@ weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" job: > - {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %}{{ _cron_job_command }} + {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} + {% endif %}{{ _cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index e3eeafeb..2bd74273 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -37,7 +37,8 @@ weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" job: > - {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} {% endif %}{{ _cron_job_command }} + {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} + {% endif %}{{ _cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From d5cfc3d0548b5ff5ef96089aba6fde39ccbb92f8 Mon Sep 17 00:00:00 2001 From: Drazen Date: Wed, 18 Dec 2024 09:57:15 +0100 Subject: [PATCH 17/22] Polishing-cron-output --- roles/cron/cron_drupal7/tasks/job.yml | 8 +++++--- roles/cron/cron_drupal8/tasks/job.yml | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 5db27375..289b4e87 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -1,7 +1,7 @@ --- - name: Define cron job command. ansible.builtin.set_fact: - _cron_job_command: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }} > /dev/null 2>&1" + _cron_job_command: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }} >/dev/null" - name: Define cron job command if deferred (ASG). ansible.builtin.set_fact: @@ -36,8 +36,10 @@ weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" job: > - {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} - {% endif %}{{ _cron_job_command }} + {% if entry.mailto is defined and entry.mailto | length > 0 %} + MAILTO={{ entry.mailto }} + {% endif %} + { _cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 2bd74273..b138b71b 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -1,7 +1,7 @@ --- - name: Define cron job command. ansible.builtin.set_fact: - _cron_job_command: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }} > /dev/null 2>&1" + _cron_job_command: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }} >/dev/null" when: deploy_operation == "deploy" - name: Define cron job command if deferred (ASG). @@ -37,8 +37,10 @@ weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" job: > - {% if entry.mailto is defined and entry.mailto | length > 0 %}MAILTO={{ entry.mailto }} - {% endif %}{{ _cron_job_command }} + {% if entry.mailto is defined and entry.mailto | length > 0 %} + MAILTO={{ entry.mailto }} + {% endif %} + { _cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From ae5a2d73522c79218ef191e75e509f290129c5da Mon Sep 17 00:00:00 2001 From: Drazen Date: Wed, 18 Dec 2024 10:40:01 +0100 Subject: [PATCH 18/22] Fixing-syntax --- roles/cron/cron_drupal7/tasks/job.yml | 2 +- roles/cron/cron_drupal8/tasks/job.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 289b4e87..43e5e563 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -39,7 +39,7 @@ {% if entry.mailto is defined and entry.mailto | length > 0 %} MAILTO={{ entry.mailto }} {% endif %} - { _cron_job_command }} + {{ _cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index b138b71b..29bdc272 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -40,7 +40,7 @@ {% if entry.mailto is defined and entry.mailto | length > 0 %} MAILTO={{ entry.mailto }} {% endif %} - { _cron_job_command }} + {{ _cron_job_command }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From bea3fdf472dc9f8f119b0ecf8d227e84c53b64fb Mon Sep 17 00:00:00 2001 From: Drazen Date: Wed, 18 Dec 2024 10:54:12 +0100 Subject: [PATCH 19/22] Filtering-test-crons-mailto --- roles/cron/cron_drupal7/tasks/job.yml | 2 +- roles/cron/cron_drupal8/tasks/job.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 43e5e563..33f99e7c 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -35,7 +35,7 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: > + job: | {% if entry.mailto is defined and entry.mailto | length > 0 %} MAILTO={{ entry.mailto }} {% endif %} diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 29bdc272..aea0826e 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -36,7 +36,7 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: > + job: | {% if entry.mailto is defined and entry.mailto | length > 0 %} MAILTO={{ entry.mailto }} {% endif %} From 97929d0bf52173616006d762317ccddae2d5b0b3 Mon Sep 17 00:00:00 2001 From: Drazen Date: Wed, 18 Dec 2024 11:58:51 +0100 Subject: [PATCH 20/22] Testing-trim-jinja --- roles/cron/cron_drupal7/tasks/job.yml | 4 ++-- roles/cron/cron_drupal8/tasks/job.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 33f99e7c..50194883 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -37,9 +37,9 @@ month: "{{ entry.month | default(omit) }}" job: | {% if entry.mailto is defined and entry.mailto | length > 0 %} - MAILTO={{ entry.mailto }} + MAILTO={{ entry.mailto | trim }} {% endif %} - {{ _cron_job_command }} + {{ _cron_job_command | trim }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index aea0826e..23c7bd5b 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -38,9 +38,9 @@ month: "{{ entry.month | default(omit) }}" job: | {% if entry.mailto is defined and entry.mailto | length > 0 %} - MAILTO={{ entry.mailto }} + MAILTO={{ entry.mailto | trim }} {% endif %} - {{ _cron_job_command }} + {{ _cron_job_command | trim }} state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From 6d83d6c9ae90649e545731eea8fd39fc79661d43 Mon Sep 17 00:00:00 2001 From: Drazen Date: Thu, 19 Dec 2024 11:41:48 +0100 Subject: [PATCH 21/22] Cronjob-path-fix --- roles/cron/cron_drupal7/defaults/main.yml | 2 -- roles/cron/cron_drupal7/tasks/job.yml | 13 +------------ roles/cron/cron_drupal8/defaults/main.yml | 2 -- roles/cron/cron_drupal8/tasks/job.yml | 13 +------------ 4 files changed, 2 insertions(+), 28 deletions(-) diff --git a/roles/cron/cron_drupal7/defaults/main.yml b/roles/cron/cron_drupal7/defaults/main.yml index 636557ca..9d4b90f6 100644 --- a/roles/cron/cron_drupal7/defaults/main.yml +++ b/roles/cron/cron_drupal7/defaults/main.yml @@ -12,8 +12,6 @@ drupal: # month: job: cron # disabled: true - # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. - cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 50194883..09c386e6 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -20,13 +20,6 @@ - drupal.defer is defined - drupal.defer -- name: Set global MAILTO for cron jobs (if defined) - community.general.cronvar: - name: MAILTO - value: "{{ drupal.cron_mailto | default(omit) }}" - state: present - when: drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 - - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: name: "{{ project_name }}_{{ site.folder }}_{{ build_type }}_{{ entry.job }}" @@ -35,11 +28,7 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: | - {% if entry.mailto is defined and entry.mailto | length > 0 %} - MAILTO={{ entry.mailto | trim }} - {% endif %} - {{ _cron_job_command | trim }} + job: "{{ _cron_job_command }}" state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal8/defaults/main.yml b/roles/cron/cron_drupal8/defaults/main.yml index 636557ca..9d4b90f6 100644 --- a/roles/cron/cron_drupal8/defaults/main.yml +++ b/roles/cron/cron_drupal8/defaults/main.yml @@ -12,8 +12,6 @@ drupal: # month: job: cron # disabled: true - # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. - cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 23c7bd5b..612bf649 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -21,13 +21,6 @@ - drupal.defer is defined - drupal.defer -- name: Set global MAILTO for cron jobs (if defined) - community.general.cronvar: - name: MAILTO - value: "{{ drupal.cron_mailto | default(omit) }}" - state: present - when: drupal.cron_mailto is defined and drupal.cron_mailto | length > 0 - - name: Setup Drupal cron tasks on app server. ansible.builtin.cron: name: "{{ project_name }}_{{ site.folder }}_{{ build_type }}_{{ entry.job }}" @@ -36,11 +29,7 @@ day: "{{ entry.day | default(omit) }}" weekday: "{{ entry.weekday | default(omit) }}" month: "{{ entry.month | default(omit) }}" - job: | - {% if entry.mailto is defined and entry.mailto | length > 0 %} - MAILTO={{ entry.mailto | trim }} - {% endif %} - {{ _cron_job_command | trim }} + job: "{{ _cron_job_command }}" state: present disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" From 980b4efa0f57268a23ea529537a18c844749f127 Mon Sep 17 00:00:00 2001 From: Drazen Date: Thu, 19 Dec 2024 11:43:29 +0100 Subject: [PATCH 22/22] Reverting --- docs/roles/cron/cron_drupal7.md | 2 -- docs/roles/cron/cron_drupal8.md | 2 -- roles/cron/cron_drupal7/README.md | 2 -- roles/cron/cron_drupal7/tasks/job.yml | 2 +- roles/cron/cron_drupal8/README.md | 2 -- roles/cron/cron_drupal8/tasks/job.yml | 2 +- 6 files changed, 2 insertions(+), 10 deletions(-) diff --git a/docs/roles/cron/cron_drupal7.md b/docs/roles/cron/cron_drupal7.md index dd46727a..32c2103f 100644 --- a/docs/roles/cron/cron_drupal7.md +++ b/docs/roles/cron/cron_drupal7.md @@ -19,8 +19,6 @@ drupal: # month: job: cron # disabled: true - # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. - cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] diff --git a/docs/roles/cron/cron_drupal8.md b/docs/roles/cron/cron_drupal8.md index 7ff5f24c..bafd49b0 100644 --- a/docs/roles/cron/cron_drupal8.md +++ b/docs/roles/cron/cron_drupal8.md @@ -19,8 +19,6 @@ drupal: # month: job: cron # disabled: true - # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. - cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] diff --git a/roles/cron/cron_drupal7/README.md b/roles/cron/cron_drupal7/README.md index dd46727a..32c2103f 100644 --- a/roles/cron/cron_drupal7/README.md +++ b/roles/cron/cron_drupal7/README.md @@ -19,8 +19,6 @@ drupal: # month: job: cron # disabled: true - # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. - cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 09c386e6..ae176e11 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -1,7 +1,7 @@ --- - name: Define cron job command. ansible.builtin.set_fact: - _cron_job_command: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }} >/dev/null" + _cron_job_command: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }}" - name: Define cron job command if deferred (ASG). ansible.builtin.set_fact: diff --git a/roles/cron/cron_drupal8/README.md b/roles/cron/cron_drupal8/README.md index 7ff5f24c..bafd49b0 100644 --- a/roles/cron/cron_drupal8/README.md +++ b/roles/cron/cron_drupal8/README.md @@ -19,8 +19,6 @@ drupal: # month: job: cron # disabled: true - # mailto: "{{ drupal.cron_mailto | default('') }}" # Each cron can have it's own mailto and can be configured to use different e-mail addresses. - cron_mailto: "" # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 612bf649..ffa28b2c 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -1,7 +1,7 @@ --- - name: Define cron job command. ansible.builtin.set_fact: - _cron_job_command: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }} >/dev/null" + _cron_job_command: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }}" when: deploy_operation == "deploy" - name: Define cron job command if deferred (ASG).