move health url fact to variables

main
Guido Grazioli 2022-01-27 14:23:11 +01:00
parent 8882b36c83
commit 0f02037746
No known key found for this signature in database
GPG Key ID: 22C8C31EF2BC093B
3 changed files with 14 additions and 13 deletions

View File

@ -15,7 +15,7 @@
- name: Link default logs directory - name: Link default logs directory
file: file:
state: link state: link
src: "{{keycloak_jboss_home}}/standalone/log" src: "{{ keycloak_jboss_home }}/standalone/log"
dest: /var/log/keycloak dest: /var/log/keycloak
- block: - block:
@ -30,7 +30,7 @@
retries: 2 retries: 2
delay: 2 delay: 2
rescue: rescue:
- name: create Keycloak admin user - name: "Create {{ keycloak.service_name }} admin user"
command: command:
args: args:
argv: argv:
@ -39,11 +39,11 @@
- "-u{{ keycloak_admin_user }}" - "-u{{ keycloak_admin_user }}"
- "-p{{ keycloak_admin_password }}" - "-p{{ keycloak_admin_password }}"
become: yes become: yes
- name: restart keycloak - name: "Restart {{ keycloak.service_name }}"
include_tasks: tasks/restart_keycloak.yml include_tasks: tasks/restart_keycloak.yml
- name: "Wait until Keycloak becomes active {{ health_url }}" - name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}"
uri: uri:
url: "{{ health_url }}" url: "{{ keycloak.health_url }}"
register: keycloak_status register: keycloak_status
until: keycloak_status.status == 200 until: keycloak_status.status == 200
retries: 25 retries: 25

View File

@ -38,9 +38,6 @@
daemon_reload: yes daemon_reload: yes
when: systemdunit.changed when: systemdunit.changed
- set_fact:
health_url: "{{ keycloak_management_url }}/health"
- name: start keycloak - name: start keycloak
systemd: systemd:
name: keycloak name: keycloak
@ -48,20 +45,22 @@
state: started state: started
become: yes become: yes
- command: "systemctl status keycloak" - name: Check service status
command: "systemctl status keycloak"
register: keycloak_service_status register: keycloak_service_status
changed_when: False changed_when: False
- assert: - name: Verify service status
assert:
that: that:
- keycloak_service_status is defined - keycloak_service_status is defined
- keycloak_service_status.stdout is defined - keycloak_service_status.stdout is defined
- meta: flush_handlers - meta: flush_handlers
- name: "Wait until Keycloak becomes active {{ health_url }}" - name: "Wait until Keycloak becomes active {{ keycloak.health_url }}"
uri: uri:
url: "{{ health_url }}" url: "{{ keycloak.health_url }}"
register: keycloak_status register: keycloak_status
until: keycloak_status.status == 200 until: keycloak_status.status == 200
retries: 25 retries: 25

View File

@ -16,7 +16,9 @@ keycloak_management_url: "http://{{ keycloak_host }}:{{ keycloak_management_http
keycloak: keycloak:
home: "{{ keycloak_jboss_home }}" home: "{{ keycloak_jboss_home }}"
config_dir: "{{ keycloak_config_dir }}" config_dir: "{{ keycloak_config_dir }}"
bundle: "{{ keycloak_rhsso_archive if keycloak_rhsso_enable else keycloak_archive }}"
service_name: "{{ 'rhsso' if keycloak_rhsso_enable else 'keycloak') }}"
health_url: "{{ keycloak_management_url }}/health"
# database # database
keycloak_jdbc: keycloak_jdbc: