From aa0ef58ef5afc0dac44e9c64cf08c28e9e781952 Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Fri, 29 Nov 2024 16:19:28 +0500 Subject: [PATCH] Disable nextcloud server in haproxy before updates --- roles/nextcloud/tasks/main.yml | 25 ++-------------- roles/nextcloud/tasks/start_server.yml | 41 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 roles/nextcloud/tasks/start_server.yml diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index 7273e4e..fa00782 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -20,29 +20,10 @@ owner: "33" group: "33" register: cfg -- name: Run nextcloud container - become: true - community.docker.docker_container: - name: nextcloud-{{ item }} - image: nextcloud:30.0.2-apache - networks: - - name: nextcloud - - name: haproxy - - name: postgresql - volumes: - - nextcloud:/var/www/html - - /mnt/hdd/nextcloud/data:/var/www/html/data - recreate: "{{ cfg.changed }}" - restart_policy: unless-stopped - 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 +- include_tasks: start_server.yml loop: [1, 2] + loop_control: + loop_var: server_idx - name: Schedule background jobs become: true ansible.builtin.cron: diff --git a/roles/nextcloud/tasks/start_server.yml b/roles/nextcloud/tasks/start_server.yml new file mode 100644 index 0000000..639e346 --- /dev/null +++ b/roles/nextcloud/tasks/start_server.yml @@ -0,0 +1,41 @@ +--- +- name: Disable server in haproxy + become: true + community.general.haproxy: + socket: /run/haproxy/admin.sock + state: disabled + drain: true + wait: true + backend: nextcloud + host: s{{ server_idx }} + fail_on_not_found: true +- name: Run nextcloud container + become: true + community.docker.docker_container: + name: nextcloud-{{ server_idx }} + image: nextcloud:30.0.2-apache + networks: + - name: nextcloud + - name: haproxy + - name: postgresql + volumes: + - nextcloud:/var/www/html + - /mnt/hdd/nextcloud/data:/var/www/html/data + recreate: "{{ cfg.changed }}" + restart_policy: unless-stopped + 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 +- name: Enable server in haproxy + become: true + community.general.haproxy: + socket: /run/haproxy/admin.sock + state: enabled + backend: nextcloud + host: s{{ server_idx }} + fail_on_not_found: true