From 6ebb563bf6304a394aacc797e1ece18974f40683 Mon Sep 17 00:00:00 2001 From: phil Date: Wed, 15 Feb 2023 23:01:10 +0100 Subject: [PATCH] Run monit check only against localhost --- README.md | 2 -- tasks/monit.yml | 2 +- templates/monit.conf | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 04f0123..550890a 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,10 @@ Folgende Variablen können über die jeweilige `host_vars` im Dictionary `maria |--|--|--| | local_backupdir | string | Lokales Verzeichnis der sql-Backups | | bind_address | string | Listen-Adresse des Mariadb-Servers, wird bisher nicht konfiguriert | -| monit_check_address | string | Adresse für den Monit-Verbindungscheck | Beispiel: ```YAML mariadb: local_backupdir: /var/lib/backups/mariadb bind_address: "10.0.0.2" - monit_check_address: "127.0.0.1" ``` diff --git a/tasks/monit.yml b/tasks/monit.yml index 22a047d..64a102e 100644 --- a/tasks/monit.yml +++ b/tasks/monit.yml @@ -2,7 +2,7 @@ - name: "Monit | Create sql user" community.mysql.mysql_user: name: "{{ monit_sql_user }}" - host: "{{ mariadb.bind_address | default('localhost') }}" + host: localhost password: "{{ monit_sql_password }}" state: present login_unix_socket: "{{ mysql_socket }}" diff --git a/templates/monit.conf b/templates/monit.conf index 2726bef..8ce13e7 100644 --- a/templates/monit.conf +++ b/templates/monit.conf @@ -2,8 +2,7 @@ check process mariadb with pidfile /run/mysqld/mysqld.pid group database start program = "/usr/sbin/service mysql start" stop program = "/usr/sbin/service mysql stop" - if failed host {{ mariadb.monit_check_address | default(ansible_default_ipv4.address) }} - port 3306 protocol mysql + if failed host port 3306 protocol mysql username "{{ monit_sql_user }}" password "{{ monit_sql_password }}" with timeout 15 seconds for 3 times within 4 cycles then restart if failed unixsocket /run/mysqld/mysqld.sock protocol mysql for 3 times within 4 cycles then restart