Initial bring up of monit role

This commit is contained in:
KemoNine 2020-08-04 23:57:58 +00:00
parent 12bbc819f8
commit 1985761f00
6 changed files with 67 additions and 0 deletions

View File

@ -4,3 +4,4 @@
roles:
- msmtp
- hdmi
- monit

View File

@ -0,0 +1,18 @@
---
# Notifiation email setup
monit_notification_email: "user@domain.tld"
monit_smtp_server: "mail.domain.tld"
monit_smtp_user: "user@domain.tld"
monit_smtp_password: "password"
# Filesystems to monitor
monit_filesystems:
- { name: "rootfs", path: "/", alert: "80%" }
# Monitor WireGuard?
monit_wireguard: true
# Username / password for monit web service
monit_web_user: "admin"
monit_web_pasword: "password"

View File

View File

@ -0,0 +1,31 @@
---
- name: Gather instance facts
setup:
- name: Update APT package cache
apt:
update_cache: "true"
cache_valid_time: "3600"
tags:
- monit-install
- name: Install monit
package:
name: "{{ packages }}"
state: present
vars:
packages:
- monit
tags:
- monit-install
- block:
- name: Setup filesystem monitoring
template:
src: filesystem
dest: "/etc/monit/conf.d/{{item.name}}"
owner: root
group: root
mode: 0644
loop:
{{ monit_filesystems }}
tags:
- monit-config
- monit-filesystems

View File

@ -0,0 +1,2 @@
check filesystem {{ item.name }} with path {{ item.path }}
if space usage > {{ item.alert }} then alert

View File

@ -0,0 +1,15 @@
set log /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set eventqueue
set mailserver {{ monit_smtp_server }} port 587
username "{{ monit_smtp_user }}" password "{{ monit_smtp_password }}"
using tls
set httpd port 2812 and
use address 0.0.0.0
allow {{ monit_web_user }}:{{ monit_web_pasword }}
include /etc/monit/conf.d/*
include /etc/monit/conf-enabled/*