diff --git a/defaults/main.yml b/defaults/main.yml index e09cd1d..a6c525e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/tasks/facts.yml b/tasks/facts.yml index 4b45d3a..719e3dd 100644 --- a/tasks/facts.yml +++ b/tasks/facts.yml @@ -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: | diff --git a/tasks/main.yml b/tasks/main.yml index 928b837..374d23e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 @@ -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 diff --git a/templates/monitrc b/templates/etc/monitrc similarity index 96% rename from templates/monitrc rename to templates/etc/monitrc index 8de43d1..df0c40b 100644 --- a/templates/monitrc +++ b/templates/etc/monitrc @@ -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/* diff --git a/templates/services/network b/templates/services/network deleted file mode 100644 index 1c5da3a..0000000 --- a/templates/services/network +++ /dev/null @@ -1 +0,0 @@ -check network venet0 with interface venet0 diff --git a/vars/Debian.yml b/vars/Debian.yml index da2721c..bd1a57f 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -1,3 +1,4 @@ # vars/Debian.yml monit_config_dir: "/etc/monit/conf.d/" +monit_config_file: "/etc/monit.d/monitrc"