From ec41e9abaf5596fb269e43f9e70d78c27311e968 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Sun, 2 Feb 2025 21:43:47 -0800 Subject: [PATCH] Round robin on all haproxy backup servers for blue-green deploys. --- ansible/playbooks/deploy_app.yml | 2 ++ docker/haproxy/haproxy.consul.cfg.j2 | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/ansible/playbooks/deploy_app.yml b/ansible/playbooks/deploy_app.yml index aad3e79f3..c64cacbc8 100644 --- a/ansible/playbooks/deploy_app.yml +++ b/ansible/playbooks/deploy_app.yml @@ -5,6 +5,7 @@ # serial: "50%" vars_files: - ../env_vars/base.yml + - roles/letsencrypt/defaults/main.yml vars: haproxy_host: "{{ 'hstaging' if 'staging' in inventory_hostname else 'hwww' }}" @@ -232,6 +233,7 @@ - name: Update HAProxy config to use new server delegate_to: "{{ haproxy_host }}" + run_once: true block: - name: Generate temporary HAProxy config with new server template: diff --git a/docker/haproxy/haproxy.consul.cfg.j2 b/docker/haproxy/haproxy.consul.cfg.j2 index bd82ebf8a..f03e813c0 100644 --- a/docker/haproxy/haproxy.consul.cfg.j2 +++ b/docker/haproxy/haproxy.consul.cfg.j2 @@ -103,6 +103,8 @@ backend nginx {% endfor %} backend app_django + balance roundrobin + option allbackups option httpchk GET /_haproxychk default-server check inter 1000ms on-error mark-down fall 2 rise 2 resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none {% for host in groups.hdjango %} @@ -115,6 +117,7 @@ backend app_django backend app_count balance roundrobin + option allbackups option httpchk GET /_haproxychk default-server check inter 1000ms on-error mark-down fall 2 rise 2 resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none {% for host in groups.hcount %} @@ -128,6 +131,7 @@ backend app_count backend app_refresh balance roundrobin + option allbackups option httpchk GET /_haproxychk default-server check inter 2000ms on-error mark-down fall 2 rise 2 resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none {% for host in groups.hrefresh %} @@ -141,6 +145,7 @@ backend app_refresh backend app_push balance roundrobin + option allbackups option httpchk GET /_haproxychk default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none {% for host in groups.hpush %}