Skip to content

Commit

Permalink
Merge pull request #4 from inmotionhosting/NGX-356
Browse files Browse the repository at this point in the history
NGX-356: Update monit configuration
  • Loading branch information
combssm authored Apr 13, 2023
2 parents 31895d8 + bc3883d commit 4d0641d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
3 changes: 1 addition & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
monit_daemon: monit
monit_executable_path: /usr/bin/monit
monit_config_dir: "/etc/monit.d/"
monit_config_file: "/etc/monitrc"
monitored_services:
- { var_name: 'apache_daemon', daemon_name: 'httpd' }
- { var_name: 'mysql_daemon', daemon_name: 'mariadb' }
- { var_name: 'nginx_daemon', daemon_name: 'nginx' }
- { var_name: 'php_fpm_daemon', daemon_name: 'php-fpm' }
- { var_name: 'redis_daemon', daemon_name: 'redis' }
- { var_name: 'network', daemon_name: 'network' }

# Enable systemd to restart monit if monit fails
monit_systemd_restart: true
systemd_restart_setting: on-failure
monit_prometheus_exporter: false
11 changes: 11 additions & 0 deletions tasks/facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
monit_config_dir is not string
or monit_config_dir == 0
- name: Check monit_config_file
fail:
msg: |
Invalid value for 'monit_config_file': {{ monit_config_file }}
Supported types : String
Supported values : Any non-null string
when: >-
monit_config_file is not string
or monit_config_file == 0
- name: Check monitored_services
fail:
msg: |
Expand Down
11 changes: 3 additions & 8 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
package:
name: monit
state: present

- name: Install Monit Prometheus Exporter
package:
name: imh-monit-prometheus
state: present

- name: Include systemd restart configuation
include: systemd.yml
Expand All @@ -44,11 +39,11 @@

- name: Install Monit config
template:
src: monitrc
dest: "{{ monit_config_dir }}/monitrc"
src: etc/monitrc
dest: "{{ monit_config_file }}"
owner: root
group: root
mode: 0644
mode: 0600
notify: restart monit

- name: Install service configs
Expand Down
2 changes: 2 additions & 0 deletions templates/monitrc → templates/etc/monitrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ set eventqueue
set httpd port 11000 and
use address localhost # only accept connection from localhost (drop if you use M/Monit)
allow localhost # allow localhost to connect to the server

include /etc/monit.d/*
1 change: 0 additions & 1 deletion templates/services/network

This file was deleted.

1 change: 1 addition & 0 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# vars/Debian.yml

monit_config_dir: "/etc/monit/conf.d/"
monit_config_file: "/etc/monit.d/monitrc"

0 comments on commit 4d0641d

Please sign in to comment.