-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add restart strategies, and allow custom task include
Co-authored-by: Helmut Wolf <[email protected]> Co-authored-by: Guido Grazioli <[email protected]>
- Loading branch information
1 parent
1e9a669
commit 2d573c2
Showing
9 changed files
with
104 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,17 @@ | ||
--- | ||
- name: Ensure only one service at a time gets rebooted, to ensure replication of distributed ispn caches | ||
throttle: 1 | ||
block: | ||
- name: "Restart and enable {{ keycloak.service_name }} service on first host" | ||
ansible.builtin.systemd: | ||
name: "{{ keycloak.service_name }}" | ||
enabled: true | ||
state: restarted | ||
daemon_reload: true | ||
become: true | ||
delegate_to: "{{ ansible_play_hosts | first }}" | ||
run_once: true | ||
- name: "Restart and enable {{ keycloak.service_name }} service" | ||
ansible.builtin.systemd: | ||
name: "{{ keycloak.service_name }}" | ||
enabled: true | ||
state: restarted | ||
daemon_reload: true | ||
become: true | ||
|
||
- name: "Wait until {{ keycloak.service_name }} service becomes active {{ keycloak.health_url }}" | ||
ansible.builtin.uri: | ||
url: "{{ keycloak.health_url }}" | ||
register: keycloak_status | ||
until: keycloak_status.status == 200 | ||
retries: 25 | ||
delay: 10 | ||
delegate_to: "{{ ansible_play_hosts | first }}" | ||
run_once: true | ||
|
||
- name: Pause to give distributed ispn caches time to (re-)replicate back onto first host | ||
ansible.builtin.pause: | ||
seconds: 15 | ||
when: | ||
- keycloak_quarkus_ha_enabled | ||
|
||
- name: "Restart and enable {{ keycloak.service_name }} service on all other hosts" | ||
ansible.builtin.systemd: | ||
name: "{{ keycloak.service_name }}" | ||
enabled: true | ||
state: restarted | ||
daemon_reload: true | ||
become: true | ||
when: inventory_hostname != ansible_play_hosts | first | ||
- name: "Wait until {{ keycloak.service_name }} service becomes active {{ keycloak.health_url }}" | ||
ansible.builtin.uri: | ||
url: "{{ keycloak.health_url }}" | ||
register: keycloak_status | ||
until: keycloak_status.status == 200 | ||
retries: 25 | ||
delay: 10 | ||
when: keycloak_quarkus_restart_health_check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- name: "Display message" | ||
ansible.builtin.debug: | ||
msg: "keycloak_quarkus_restart_strategy is none, skipping restart" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- name: "Restart services in serial, with optional healtch check (keycloak_quarkus_restart_health_check)" | ||
throttle: 1 | ||
loop: "{{ ansible_play_hosts }}" | ||
block: | ||
- name: "Restart and enable {{ keycloak.service_name }} service on first host" | ||
ansible.builtin.include_tasks: ../restart.yml | ||
delegate_to: "{{ item }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
- name: Verify first restarted service with health URL, then rest in parallel | ||
block: | ||
- name: "Restart and enable {{ keycloak.service_name }} service on first host" | ||
ansible.builtin.systemd: | ||
name: "{{ keycloak.service_name }}" | ||
enabled: true | ||
state: restarted | ||
daemon_reload: true | ||
become: true | ||
delegate_to: "{{ ansible_play_hosts | first }}" | ||
run_once: true | ||
|
||
- name: "Wait until {{ keycloak.service_name }} service becomes active {{ keycloak.health_url }}" | ||
ansible.builtin.uri: | ||
url: "{{ keycloak.health_url }}" | ||
register: keycloak_status | ||
until: keycloak_status.status == 200 | ||
retries: 25 | ||
delay: 10 | ||
delegate_to: "{{ ansible_play_hosts | first }}" | ||
run_once: true | ||
|
||
- name: Pause to give distributed ispn caches time to (re-)replicate back onto first host | ||
ansible.builtin.pause: | ||
seconds: "{{ keycloak_quarkus_restart_pause }}" | ||
when: | ||
- keycloak_quarkus_ha_enabled | ||
|
||
- name: "Restart and enable {{ keycloak.service_name }} service on other hosts" | ||
ansible.builtin.include_tasks: ../restart.yml | ||
delegate_to: "{{ item }}" | ||
loop: "{{ ansible_play_hosts }}" | ||
when: inventory_hostname != ansible_play_hosts | first |