Fix pre-commit hooks and move directories

roles/ and inventory/ are now in playbooks/
also fixed issues reported by ansible-lint
This commit is contained in:
Tobias Reisinger 2024-10-14 18:30:24 +02:00
parent dc398ddb6e
commit 4104057771
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
123 changed files with 91 additions and 39 deletions

View file

@ -0,0 +1,6 @@
FROM ubuntu
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update -y \
&& apt install -y curl dnsutils msmtp gettext-base python3-matrix-nio python3-requests

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

View file

@ -0,0 +1,5 @@
To: ${MAIL_HC_UID}@hc-ping.com
From: ${MAIL_USER}
Subject: Healthcheck
Mailserver alive

View file

@ -0,0 +1,43 @@
#!/usr/bin/python3
import datetime
import os
import requests
import sys
import asyncio
from nio import AsyncClient, RoomMessageNotice
def send_ping(success, msg=""):
url = os.environ['MATRIX_HC_URL']
if not success:
url += "/fail"
requests.get(url, data=msg, headers={'user-agent': os.environ['USER_AGENT']})
async def main():
try:
client = AsyncClient(os.environ['MATRIX_SERVER'])
client.access_token = os.environ['MATRIX_TOKEN']
client.device_id = os.environ['USER_AGENT']
await client.room_send(
room_id = os.environ['MATRIX_ROOM'],
message_type = "m.room.message",
content = {
"msgtype": "m.text",
"body": "!ping"
}
)
except Exception as e:
print(e)
print("exception during login or sending")
send_ping(False, str(e))
sys.exit(1)
await client.close()
send_ping(True)
sys.exit(0)
asyncio.new_event_loop().run_until_complete(main())

View file

@ -0,0 +1,13 @@
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /tmp/msmtp.log
account default
host ${MAIL_HOST}
port ${MAIL_PORT}
tls_starttls on
from ${MAIL_USER}
user ${MAIL_USER}
password ${MAIL_PASS}

View file

@ -0,0 +1,4 @@
[Timer]
OnCalendar=*:0/5
[Install]
WantedBy=timers.target