Skip to content

Commit

Permalink
cron: rewrite ansible-daily-run script (one trap only)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpelisse committed Apr 12, 2024
1 parent 56fa9be commit 3362071
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions roles/cron/templates/ansible-daily-run.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ zeus_status() {
fi
}

mail_report() {
local subject=$(head -1 "${LOGFILE}" | sed -e "s;$; (Status: $(zeus_status));")
cat "${LOGFILE}" | \
mailx -r "{{ mailer.to }}" -s "{{ jobs.name }}:${subject}" \
-S smtp="{{ mailer.smtp.host }}:{{mailer.smtp.port }}" "{{ mailer.replyTo }}"
mail_report_and_clean() {
local subject=$(head -1 "${LOGFILE}" | sed -e "s;$; (Status: $(zeus_status));")
cat "${LOGFILE}" | \
mailx -r "{{ mailer.to }}" -s "{{ jobs.name }}:${subject}" \
-S smtp="{{ mailer.smtp.host }}:{{mailer.smtp.port }}" "{{ mailer.replyTo }}"
rm -f "${LOGFILE}"
}

run_zeus() {
Expand All @@ -36,7 +37,6 @@ run_zeus() {
echo "${?}" > "${ZEUS_STATUS_FILE}"
}

trap mail_report EXIT
trap "rm -f ${LOGFILE}" EXIT
trap mail_report_and_clean EXIT

run_zeus >> "${LOGFILE}"

0 comments on commit 3362071

Please sign in to comment.