diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 18722640..4e479d29 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -5,7 +5,8 @@ - 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 }}\" > /dev/null" + _cron_job_command: >- + cd {{ _ce_deploy_base_dir }} && {{ _ce_deploy_ansible_location }} {{ drupal.defer_target }} -m shell -a "{{ _cron_job_command }} > /dev/null{% if entry.cron_error_mailto is defined %} 2>&1 | mail -s 'Cron Error - {{ inventory_hostname }}' {{ entry.cron_error_mailto }}{% endif %}" when: - drupal.defer is defined - drupal.defer @@ -14,7 +15,8 @@ - name: Add dev null redirection (for non-deferred). ansible.builtin.set_fact: - _cron_job_command: "{{ _cron_job_command }} > /dev/null" + _cron_job_command: >- + {{ _cron_job_command }} > /dev/null{% if entry.cron_error_mailto is defined %} 2>&1 | mail -s 'Cron Error - {{ inventory_hostname }}' {{ entry.cron_error_mailto }}{% endif %} when: - drupal.defer is not defined or not drupal.defer diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 2022daaf..37c1c634 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -5,7 +5,8 @@ - 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 }}\" > /dev/null" + _cron_job_command: >- + cd {{ _ce_deploy_base_dir }} && {{ _ce_deploy_ansible_location }} {{ drupal.defer_target }} -m shell -a "{{ _cron_job_command }} > /dev/null{% if entry.cron_error_mailto is defined %} 2>&1 | mail -s 'Cron Error - {{ inventory_hostname }}' {{ entry.cron_error_mailto }}{% endif %}" when: - drupal.defer is defined - drupal.defer @@ -14,7 +15,8 @@ - name: Add dev null redirection (for non-deferred). ansible.builtin.set_fact: - _cron_job_command: "{{ _cron_job_command }} > /dev/null" + _cron_job_command: >- + {{ _cron_job_command }} > /dev/null{% if entry.cron_error_mailto is defined %} 2>&1 | mail -s 'Cron Error - {{ inventory_hostname }}' {{ entry.cron_error_mailto }}{% endif %} when: - drupal.defer is not defined or not drupal.defer