Fix shell_module executable and mail healthcheck

This commit is contained in:
Tobias Reisinger 2024-10-18 14:32:30 +02:00
parent 0c60e974a2
commit 36c12a330f
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
4 changed files with 23 additions and 9 deletions

View file

@ -9,9 +9,21 @@ alias curl_hc='curl -LA "$USER_AGENT" --retry 3'
envsubst < template.msmtprc > /tmp/msmtprc envsubst < template.msmtprc > /tmp/msmtprc
envsubst < mailcheck.template.mail > /tmp/mailcheck.mail envsubst < mailcheck.template.mail > /tmp/mailcheck.mail
# 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) result=$(msmtp -C /tmp/msmtprc -a default "$MAIL_HC_UID@hc-ping.com" < /tmp/mailcheck.mail 2>&1)
if [ "$?" != "0" ] if [ "$?" = "0" ]
then
exit 0
fi
if [ $i -eq 3 ]
then then
echo "$result" echo "$result"
curl_hc --data-raw "$result" "$hc_url/fail" >/dev/null curl_hc --data-raw "$result" "$hc_url/fail" >/dev/null
exit 1
fi fi
sleep 3
done

View file

@ -14,6 +14,7 @@
- name: Get all healthcheck timers - name: Get all healthcheck timers
ansible.builtin.shell: # noqa: command-instead-of-module 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'" cmd: "set -o pipefail && systemctl list-timers 'healthcheck@*' --all --output=json | jq -r '.[].unit'"
register: systemd_timers_result register: systemd_timers_result
changed_when: false changed_when: false

View file

@ -14,6 +14,7 @@
- name: Get all lego timers - name: Get all lego timers
ansible.builtin.shell: ansible.builtin.shell:
executable: /usr/bin/bash
cmd: "set -o pipefail && systemctl list-timers 'lego@*' --all --output=json | jq -r '.[].unit'" cmd: "set -o pipefail && systemctl list-timers 'lego@*' --all --output=json | jq -r '.[].unit'"
register: systemd_timers_result register: systemd_timers_result
changed_when: false changed_when: false

View file

@ -23,9 +23,9 @@
register: autorestic_status register: autorestic_status
- name: Install autorestic - name: Install autorestic
ansible.builtin.shell: set -o pipefail && wget -qO - https://raw.githubusercontent.com/cupcakearmy/autorestic/master/install.sh | bash ansible.builtin.shell:
args: executable: /usr/bin/bash
executable: /bin/bash cmd: set -o pipefail && wget -qO - https://raw.githubusercontent.com/cupcakearmy/autorestic/master/install.sh | bash
when: not autorestic_status.stat.exists when: not autorestic_status.stat.exists
changed_when: true changed_when: true
become: true become: true