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 < template.msmtprc > /tmp/msmtprc
|
||||||
envsubst < mailcheck.template.mail > /tmp/mailcheck.mail
|
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)
|
# Retry 3 times
|
||||||
if [ "$?" != "0" ]
|
for i in 1 2 3
|
||||||
then
|
do
|
||||||
echo "$result"
|
result=$(msmtp -C /tmp/msmtprc -a default "$MAIL_HC_UID@hc-ping.com" < /tmp/mailcheck.mail 2>&1)
|
||||||
curl_hc --data-raw "$result" "$hc_url/fail" >/dev/null
|
if [ "$?" = "0" ]
|
||||||
fi
|
then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $i -eq 3 ]
|
||||||
|
then
|
||||||
|
echo "$result"
|
||||||
|
curl_hc --data-raw "$result" "$hc_url/fail" >/dev/null
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue