From 3b9a0d4141c27f382e2a1025e1c22dbcc5384667 Mon Sep 17 00:00:00 2001
From: Evangelos Foutras <evangelos@foutrelis.com>
Date: Sun, 26 Feb 2023 20:52:32 +0200
Subject: [PATCH] tasks/upgrade-servers: upgrade Keycloak box first

matrix.archlinux.org doesn't like it when accounts.archlinux.org is
unavailable at start-up. Try to work around this by upgrading
accounts.archlinux.org first and doing a health check before proceeding
to update the rest of the servers.

Fixes: #496
---
 playbooks/tasks/upgrade-servers.yml | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/playbooks/tasks/upgrade-servers.yml b/playbooks/tasks/upgrade-servers.yml
index f51c53bcf..dd4d8f320 100644
--- a/playbooks/tasks/upgrade-servers.yml
+++ b/playbooks/tasks/upgrade-servers.yml
@@ -1,5 +1,22 @@
+- name: Upgrade, reboot and health-check accounts.archlinux.org
+  hosts: accounts.archlinux.org
+  max_fail_percentage: 0
+  gather_facts: false
+
+  tasks:
+    - name: Upgrade and reboot
+      include_tasks: include/upgrade-server.yml
+
+    - name: Wait for Keycloak to become available
+      uri: url=https://{{ inventory_hostname }}/metrics
+      register: result
+      until: result.status == 200
+      # retry for 5 minutes after boot
+      retries: 30
+      delay: 10
+
 - name: Upgrade and reboot all hetzner servers
-  hosts: all,!kape_servers,!equinix_metal
+  hosts: all,!accounts.archlinux.org,!kape_servers,!equinix_metal
   max_fail_percentage: 0
   serial: 20%
   gather_facts: false
-- 
GitLab