From 00fa6b31e231111afc03d03c1ca09018a2d9f69f Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Fri, 29 Nov 2024 16:12:42 +0500 Subject: [PATCH] Disable website server in haproxy before updates --- roles/comfycamp/tasks/main.yml | 18 ++++---------- roles/comfycamp/tasks/start_server.yml | 33 ++++++++++++++++++++++++++ roles/haproxy/files/haproxy.cfg | 3 ++- 3 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 roles/comfycamp/tasks/start_server.yml diff --git a/roles/comfycamp/tasks/main.yml b/roles/comfycamp/tasks/main.yml index 1cb0019..e5d27fe 100644 --- a/roles/comfycamp/tasks/main.yml +++ b/roles/comfycamp/tasks/main.yml @@ -16,17 +16,7 @@ become: true community.docker.docker_volume: name: comfycamp -- name: Create comfycamp container - become: true - community.docker.docker_container: - name: comfycamp - image: git.comfycamp.space/lumin/comfycamp:v2.3.1 - networks: - - name: postgresql - - name: haproxy - volumes: - - /etc/comfycamp/config.local.toml:/usr/src/comfycamp/config.local.toml:ro - - comfycamp:/var/lib/comfycamp - env: - RUST_LOG: warn - restart_policy: unless-stopped +- include_tasks: start_server.yml + loop: [1, 2] + loop_control: + loop_var: server_idx diff --git a/roles/comfycamp/tasks/start_server.yml b/roles/comfycamp/tasks/start_server.yml new file mode 100644 index 0000000..d9dd8a5 --- /dev/null +++ b/roles/comfycamp/tasks/start_server.yml @@ -0,0 +1,33 @@ +--- +- name: Disable server in haproxy + become: true + community.general.haproxy: + socket: /run/haproxy/admin.sock + state: disabled + drain: true + wait: true + backend: comfycamp + host: s{{ server_idx }} + fail_on_not_found: true +- name: Create comfycamp container + become: true + community.docker.docker_container: + name: comfycamp-{{ server_idx }} + image: git.comfycamp.space/lumin/comfycamp:v2.3.1 + networks: + - name: postgresql + - name: haproxy + volumes: + - /etc/comfycamp/config.local.toml:/usr/src/comfycamp/config.local.toml:ro + - comfycamp:/var/lib/comfycamp + env: + RUST_LOG: warn + restart_policy: unless-stopped +- name: Enable server in haproxy + become: true + community.general.haproxy: + socket: /run/haproxy/admin.sock + state: enabled + backend: comfycamp + host: s{{ server_idx }} + fail_on_not_found: true diff --git a/roles/haproxy/files/haproxy.cfg b/roles/haproxy/files/haproxy.cfg index 35825c8..ef536e6 100644 --- a/roles/haproxy/files/haproxy.cfg +++ b/roles/haproxy/files/haproxy.cfg @@ -143,7 +143,8 @@ backend comfycamp option httpchk GET /health http-check expect status 200 http-response set-header Onion-Location http://comfycgmgfvowbbw2ckkobuvk4cejo2e56uxrhznravxnrl7itftpkad.onion%[capture.req.uri] - server s1 comfycamp:4000 check inter 15s + server s1 comfycamp-1:4000 check inter 15s + server s2 comfycamp-2:4000 check inter 15s backend mastodon mode http