diff --git a/roles/keycloak/tasks/main.yml b/roles/keycloak/tasks/main.yml index bcf0c06..6ee9041 100644 --- a/roles/keycloak/tasks/main.yml +++ b/roles/keycloak/tasks/main.yml @@ -15,7 +15,7 @@ - name: Link default logs directory file: state: link - src: "{{keycloak_jboss_home}}/standalone/log" + src: "{{ keycloak_jboss_home }}/standalone/log" dest: /var/log/keycloak - block: @@ -30,7 +30,7 @@ retries: 2 delay: 2 rescue: - - name: create Keycloak admin user + - name: "Create {{ keycloak.service_name }} admin user" command: args: argv: @@ -39,11 +39,11 @@ - "-u{{ keycloak_admin_user }}" - "-p{{ keycloak_admin_password }}" become: yes - - name: restart keycloak + - name: "Restart {{ keycloak.service_name }}" 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: - url: "{{ health_url }}" + url: "{{ keycloak.health_url }}" register: keycloak_status until: keycloak_status.status == 200 retries: 25 diff --git a/roles/keycloak/tasks/systemd.yml b/roles/keycloak/tasks/systemd.yml index 858f5d7..ca63491 100644 --- a/roles/keycloak/tasks/systemd.yml +++ b/roles/keycloak/tasks/systemd.yml @@ -38,9 +38,6 @@ daemon_reload: yes when: systemdunit.changed -- set_fact: - health_url: "{{ keycloak_management_url }}/health" - - name: start keycloak systemd: name: keycloak @@ -48,20 +45,22 @@ state: started become: yes -- command: "systemctl status keycloak" +- name: Check service status + command: "systemctl status keycloak" register: keycloak_service_status changed_when: False -- assert: +- name: Verify service status + assert: that: - keycloak_service_status is defined - keycloak_service_status.stdout is defined - meta: flush_handlers -- name: "Wait until Keycloak becomes active {{ health_url }}" +- name: "Wait until Keycloak becomes active {{ keycloak.health_url }}" uri: - url: "{{ health_url }}" + url: "{{ keycloak.health_url }}" register: keycloak_status until: keycloak_status.status == 200 retries: 25 diff --git a/roles/keycloak/vars/main.yml b/roles/keycloak/vars/main.yml index 3f913d8..094b453 100644 --- a/roles/keycloak/vars/main.yml +++ b/roles/keycloak/vars/main.yml @@ -16,7 +16,9 @@ keycloak_management_url: "http://{{ keycloak_host }}:{{ keycloak_management_http keycloak: home: "{{ keycloak_jboss_home }}" 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 keycloak_jdbc: