"Monitor" service via systemd

This commit is contained in:
phil 2023-11-01 08:23:48 +01:00
parent 719fc93598
commit 65a0d4046e
5 changed files with 23 additions and 21 deletions

View file

@ -0,0 +1,4 @@
# Ansible managed
[Service]
Restart=always

View file

@ -8,12 +8,11 @@
name: nginx name: nginx
state: reloaded state: reloaded
- name: reload monit
ansible.builtin.service:
name: monit
state: reloaded
- name: reload fail2ban - name: reload fail2ban
ansible.builtin.service: ansible.builtin.service:
name: fail2ban name: fail2ban
state: reloaded state: reloaded
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: true

View file

@ -46,3 +46,18 @@
mode: "0644" mode: "0644"
notify: reload nginx notify: reload nginx
when: nginx_type == 'gateway' or nginx_type == 'standalone' when: nginx_type == 'gateway' or nginx_type == 'standalone'
- name: "Configuration | Create systemd override directory"
ansible.builtin.file:
path: /etc/systemd/system/nginx.service.d
state: directory
mode: "0755"
- name: "Configuration | Copy systemd override configuration"
ansible.builtin.copy:
src: systemd/override.conf
dest: /etc/systemd/system/nginx.service.d/override.conf
mode: "0644"
notify:
- Reload systemd
- reload nginx

View file

@ -23,11 +23,3 @@
dest: /etc/nginx/sites-enabled/local-statistics dest: /etc/nginx/sites-enabled/local-statistics
state: link state: link
notify: reload nginx notify: reload nginx
- name: "Monitoring | Copy Monit configuration"
ansible.builtin.template:
src: monit.j2
dest: /etc/monit/conf-enabled/nginx
mode: 0644
notify: reload monit
when: "'monit' in ansible_facts.packages"

View file

@ -1,8 +0,0 @@
# {{ ansible_managed }}
check process nginx with pidfile /var/run/nginx.pid
group webserver
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
if failed host 127.0.0.1 port {{ nginx_port | default(80) }} for 3 cycles then restart
if 5 restarts with 5 cycles then timeout