From be582171ce0adb4d3c58c5f47ad536b6389578b4 Mon Sep 17 00:00:00 2001 From: Guido Grazioli Date: Wed, 28 Sep 2022 16:30:26 +0200 Subject: [PATCH] restart handler: orchestrate --- roles/keycloak/tasks/restart_keycloak.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/roles/keycloak/tasks/restart_keycloak.yml b/roles/keycloak/tasks/restart_keycloak.yml index eff9ddf..2d78244 100644 --- a/roles/keycloak/tasks/restart_keycloak.yml +++ b/roles/keycloak/tasks/restart_keycloak.yml @@ -5,3 +5,23 @@ enabled: yes state: restarted become: yes + delegate_to: "{{ ansible_play_hosts | first }}" + run_once: True + +- name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}" + ansible.builtin.uri: + url: "{{ keycloak.health_url }}" + register: keycloak_status + until: keycloak_status.status == 200 + delegate_to: "{{ ansible_play_hosts | first }}" + run_once: True + retries: 25 + delay: 10 + +- name: "Restart and enable {{ keycloak.service_name }} service" + ansible.builtin.systemd: + name: keycloak + enabled: yes + state: restarted + become: yes + when: and inventory_hostname != ansible_play_hosts | first