Add healthcheck to ansible

This commit is contained in:
Tobias Reisinger 2023-12-09 20:12:42 +01:00
parent 68463c03f1
commit 1cb92e3825
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
13 changed files with 68 additions and 6 deletions
_ansible/roles/healthcheck/files/data

View file

@ -0,0 +1,17 @@
#!/usr/bin/sh
cd /opt/ || exit
hc_url="https://hc-ping.com/$MAIL_HC_UID"
alias curl_hc='curl -LA "$USER_AGENT" --retry 3'
envsubst < template.msmtprc > /tmp/msmtprc
envsubst < mailcheck.template.mail > /tmp/mailcheck.mail
result=$(msmtp -C /tmp/msmtprc -a default "$MAIL_HC_UID@hc-ping.com" < /tmp/mailcheck.mail 2>&1)
if [ "$?" != "0" ]
then
echo "$result"
curl_hc --data-raw "$result" "$hc_url/fail" >/dev/null
fi