Fix shell_module executable and mail healthcheck
This commit is contained in:
parent
0c60e974a2
commit
36c12a330f
4 changed files with 23 additions and 9 deletions
|
@ -9,9 +9,21 @@ 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
|
||||
# Retry 3 times
|
||||
for i in 1 2 3
|
||||
do
|
||||
result=$(msmtp -C /tmp/msmtprc -a default "$MAIL_HC_UID@hc-ping.com" < /tmp/mailcheck.mail 2>&1)
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $i -eq 3 ]
|
||||
then
|
||||
echo "$result"
|
||||
curl_hc --data-raw "$result" "$hc_url/fail" >/dev/null
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 3
|
||||
done
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
- name: Get all healthcheck timers
|
||||
ansible.builtin.shell: # noqa: command-instead-of-module
|
||||
executable: /usr/bin/bash
|
||||
cmd: "set -o pipefail && systemctl list-timers 'healthcheck@*' --all --output=json | jq -r '.[].unit'"
|
||||
register: systemd_timers_result
|
||||
changed_when: false
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
- name: Get all lego timers
|
||||
ansible.builtin.shell:
|
||||
executable: /usr/bin/bash
|
||||
cmd: "set -o pipefail && systemctl list-timers 'lego@*' --all --output=json | jq -r '.[].unit'"
|
||||
register: systemd_timers_result
|
||||
changed_when: false
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
register: autorestic_status
|
||||
|
||||
- name: Install autorestic
|
||||
ansible.builtin.shell: set -o pipefail && wget -qO - https://raw.githubusercontent.com/cupcakearmy/autorestic/master/install.sh | bash
|
||||
args:
|
||||
executable: /bin/bash
|
||||
ansible.builtin.shell:
|
||||
executable: /usr/bin/bash
|
||||
cmd: set -o pipefail && wget -qO - https://raw.githubusercontent.com/cupcakearmy/autorestic/master/install.sh | bash
|
||||
when: not autorestic_status.stat.exists
|
||||
changed_when: true
|
||||
become: true
|
||||
|
|
Loading…
Reference in a new issue