Shorted monitor-bot- to mon-bot-

This commit is contained in:
2025-07-09 03:22:01 +02:00
parent dd1aab70fb
commit ae5f021b8d
82 changed files with 150 additions and 150 deletions

View File

@@ -0,0 +1,21 @@
# mon-bot-msmtp
## Description
This Ansible role sends periodic health check emails using **msmtp** to verify that your mail transport agent is operational. It deploys a simple script and hooks it into a systemd service and timer, with failure notifications sent via Telegram.
## Overview
Optimized for Archlinux, this role creates the required directory structure, installs and configures the mon-bot-check script, and integrates with the **alert-telegram** role. It uses the **generic-timer** role to schedule regular checks based on your customizable `OnCalendar` setting.
## Purpose
The **mon-bot-msmtp** role ensures that your mail transport system stays available by sending a test email at defined intervals. If the email fails, a Telegram alert is triggered, allowing you to detect and address issues before they impact users.
## Features
- **Directory & Script Deployment:** Sets up `mon-bot-msmtp/` and deploys a templated Bash script to send test emails via msmtp.
- **Systemd Service & Timer:** Provides `.service` and `.timer` units to run the check and schedule it automatically.
- **Failure Notifications:** Leverages **alert-telegram** to push alerts when the script exits with an error.
- **Configurable Schedule:** Define your desired check frequency using the `on_calendar_health_msmtp` variable.
- **Email Destination:** Specify the recipient via the `users.administrator.email` variable.

View File

@@ -0,0 +1,5 @@
- name: reload mon-bot-msmtp.cymais.service
systemd:
name: mon-bot-msmtp.cymais.service
enabled: yes
daemon_reload: yes

View File

@@ -0,0 +1,24 @@
---
galaxy_info:
author: "Kevin Veen-Birkenbach"
description: "Periodic MTA health-check: sends test mail via msmtp and alerts on failure."
company: |
Kevin Veen-Birkenbach
Consulting & Coaching Solutions
https://www.veen.world
license: "CyMaIS NonCommercial License (CNCL)"
license_url: "https://s.veen.world/cncl"
min_ansible_version: "2.9"
platforms:
- name: Archlinux
versions: ["rolling"]
galaxy_tags:
- monitor
- msmtp
- email
- health
- systemd
repository: "https://s.veen.world/cymais"
documentation: "https://s.veen.world/cymais"
dependencies:
- alert-telegram

View File

@@ -0,0 +1,27 @@
- name: "create {{ health_msmtp_folder }}"
file:
path: "{{ health_msmtp_folder }}"
state: directory
mode: 0755
- name: create mon-bot-msmtp.sh
template:
src: mon-bot-msmtp.sh.j2
dest: "{{ health_msmtp_folder }}mon-bot-msmtp.sh"
mode: '0755'
- name: create mon-bot-msmtp.cymais.service
template:
src: mon-bot-msmtp.service.j2
dest: /etc/systemd/system/mon-bot-msmtp.cymais.service
notify: reload mon-bot-msmtp.cymais.service
- name: set service_name to the name of the current role
set_fact:
service_name: "{{ role_name }}"
- name: include role for generic-timer for {{ service_name }}
include_role:
name: generic-timer
vars:
on_calendar: "{{ on_calendar_health_msmtp }}"

View File

@@ -0,0 +1,7 @@
[Unit]
Description=Check msmtp liveliness
OnFailure=alert-telegram.cymais@%n.service
[Service]
Type=oneshot
ExecStart=/bin/bash {{ health_msmtp_folder }}mon-bot-msmtp.sh

View File

@@ -0,0 +1,4 @@
#!/bin/bash
echo "Subject: $HOST is alive
Host $HOSTNAME reports at $(date): I'm alive." | msmtp -t {{ users.administrator.email }}

View File

@@ -0,0 +1 @@
health_msmtp_folder: "{{ path_administrator_scripts }}mon-bot-msmtp/"