Run monit check only against localhost

This commit is contained in:
phil 2023-02-15 23:01:10 +01:00
parent 73bf0925bc
commit 6ebb563bf6
3 changed files with 2 additions and 5 deletions

View file

@ -16,12 +16,10 @@ Folgende Variablen können über die jeweilige `host_vars` im Dictionary `maria
|--|--|--| |--|--|--|
| local_backupdir | string | Lokales Verzeichnis der sql-Backups | | local_backupdir | string | Lokales Verzeichnis der sql-Backups |
| bind_address | string | Listen-Adresse des Mariadb-Servers, wird bisher nicht konfiguriert | | bind_address | string | Listen-Adresse des Mariadb-Servers, wird bisher nicht konfiguriert |
| monit_check_address | string | Adresse für den Monit-Verbindungscheck |
Beispiel: Beispiel:
```YAML ```YAML
mariadb: mariadb:
local_backupdir: /var/lib/backups/mariadb local_backupdir: /var/lib/backups/mariadb
bind_address: "10.0.0.2" bind_address: "10.0.0.2"
monit_check_address: "127.0.0.1"
``` ```

View file

@ -2,7 +2,7 @@
- name: "Monit | Create sql user" - name: "Monit | Create sql user"
community.mysql.mysql_user: community.mysql.mysql_user:
name: "{{ monit_sql_user }}" name: "{{ monit_sql_user }}"
host: "{{ mariadb.bind_address | default('localhost') }}" host: localhost
password: "{{ monit_sql_password }}" password: "{{ monit_sql_password }}"
state: present state: present
login_unix_socket: "{{ mysql_socket }}" login_unix_socket: "{{ mysql_socket }}"

View file

@ -2,8 +2,7 @@ check process mariadb with pidfile /run/mysqld/mysqld.pid
group database group database
start program = "/usr/sbin/service mysql start" start program = "/usr/sbin/service mysql start"
stop program = "/usr/sbin/service mysql stop" stop program = "/usr/sbin/service mysql stop"
if failed host {{ mariadb.monit_check_address | default(ansible_default_ipv4.address) }} if failed host port 3306 protocol mysql
port 3306 protocol mysql
username "{{ monit_sql_user }}" password "{{ monit_sql_password }}" username "{{ monit_sql_user }}" password "{{ monit_sql_password }}"
with timeout 15 seconds for 3 times within 4 cycles then restart 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 if failed unixsocket /run/mysqld/mysqld.sock protocol mysql for 3 times within 4 cycles then restart