diff --git a/roles/cron/cron_drupal7/defaults/main.yml b/roles/cron/cron_drupal7/defaults/main.yml index 13121bb3..40956fdf 100644 --- a/roles/cron/cron_drupal7/defaults/main.yml +++ b/roles/cron/cron_drupal7/defaults/main.yml @@ -19,6 +19,6 @@ drupal: # 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" - cron_error_filter: "> /tmp/cron_output.txt 2>&1 && if ! grep -q '\"rc\": -13' /tmp/cron_output.txt; then cat /tmp/cron_output.txt | grep -iE '(error|fail|fatal|critical|exception)' | grep -v 'MODULE FAILURE'; fi || true" + cron_error_filter: "> /tmp/cron_output.txt 2>&1; rc=$?; if [ $rc -ne 0 ] || (grep -iE \"(error|fail|fatal|critical|exception)\" /tmp/cron_output.txt | grep -v -E '(\"rc\": -13|MODULE FAILURE)' | grep -q .); then mail -s \"Cron Error - $(hostname)\" sysadm@codeenigma.com < /tmp/cron_output.txt; fi" cron_error_email: "{% if entry.cron_error_mailto is defined %} || (echo 'Command failed' | mail -s 'Cron Error - {{ inventory_hostname }}' {{ entry.cron_error_mailto }}){% endif %}" python_interpreter: "-e 'ansible_python_interpreter=/home/controller/ce-python/bin/python'" diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 6ce56936..76801b89 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -5,7 +5,7 @@ - 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 }} {{ drupal.python_interpreter }} -m shell -a '{{ _cron_job_command }} {{ drupal.cron_error_filter }} {{ drupal.cron_error_email }}" + _cron_job_command: "cd {{ _ce_deploy_base_dir }} && {{ _ce_deploy_ansible_location }} {{ drupal.defer_target }} {{ drupal.python_interpreter }} -m shell -a '{{ _cron_job_command }} {{ drupal.cron_error_filter }} {{ drupal.cron_error_email | default('') }}'" when: - drupal.defer is defined - drupal.defer diff --git a/roles/cron/cron_drupal8/defaults/main.yml b/roles/cron/cron_drupal8/defaults/main.yml index 6e40fdfe..f5a0297b 100644 --- a/roles/cron/cron_drupal8/defaults/main.yml +++ b/roles/cron/cron_drupal8/defaults/main.yml @@ -21,6 +21,6 @@ drupal: # 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" - cron_error_filter: "> /tmp/cron_output.txt 2>&1 && if ! grep -q '\"rc\": -13' /tmp/cron_output.txt; then cat /tmp/cron_output.txt | grep -iE '(error|fail|fatal|critical|exception)' | grep -v 'MODULE FAILURE'; fi || true" + cron_error_filter: "> /tmp/cron_output.txt 2>&1; rc=$?; if [ $rc -ne 0 ] || (grep -iE \"(error|fail|fatal|critical|exception)\" /tmp/cron_output.txt | grep -v -E '(\"rc\": -13|MODULE FAILURE)' | grep -q .); then mail -s \"Cron Error - $(hostname)\" sysadm@codeenigma.com < /tmp/cron_output.txt; fi" cron_error_email: "{% if entry.cron_error_mailto is defined %} || (echo 'Command failed' | mail -s 'Cron Error - {{ inventory_hostname }}' {{ entry.cron_error_mailto }}){% endif %}" python_interpreter: "-e 'ansible_python_interpreter=/home/controller/ce-python/bin/python'" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index b49105bb..802e085b 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -5,7 +5,7 @@ - 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 }} {{ drupal.python_interpreter }} -m shell -a '{{ _cron_job_command }} {{ drupal.cron_error_filter }} {{ drupal.cron_error_email }}" + _cron_job_command: "cd {{ _ce_deploy_base_dir }} && {{ _ce_deploy_ansible_location }} {{ drupal.defer_target }} {{ drupal.python_interpreter }} -m shell -a '{{ _cron_job_command }} {{ drupal.cron_error_filter }} {{ drupal.cron_error_email | default('') }}'" when: - drupal.defer is defined - drupal.defer