From d154afd699e290c03e7ddce8cb08d9ba5529f2d1 Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Fri, 15 Nov 2024 15:50:05 +0500 Subject: [PATCH] Set up load balancing and health checks for nextcloud --- roles/haproxy/files/haproxy.cfg | 7 ++++++- roles/nextcloud/tasks/main.yml | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/roles/haproxy/files/haproxy.cfg b/roles/haproxy/files/haproxy.cfg index 51ef135..d2d6320 100644 --- a/roles/haproxy/files/haproxy.cfg +++ b/roles/haproxy/files/haproxy.cfg @@ -201,7 +201,12 @@ backend authentik_ldap backend nextcloud mode http - server s1 nextcloud-1:80 check + option httpchk + http-check send meth GET uri /status.php hdr Host nc.comfycamp.space + http-check expect status 200 + cookie SERVER insert indirect nocache + server s1 nextcloud-1:80 check inter 15s cookie s1 + server s2 nextcloud-2:80 check inter 15s cookie s2 backend mta_sts mode http diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index 09b0300..17c72dd 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -34,7 +34,15 @@ - /mnt/hdd/nextcloud/data:/var/www/html/data recreate: "{{ cfg.changed }}" restart_policy: unless-stopped - loop: [1] + healthcheck: + test: ["CMD", "curl", "--fail", "http://127.0.0.1/status.php"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 30s + # TODO: enable after ansible update + # state: healthy + loop: [1, 2] - name: Schedule background jobs become: true ansible.builtin.cron: