- name: configure keycloak service script wrapper become: yes ansible.builtin.template: src: keycloak-service.sh.j2 dest: "{{ keycloak_dest }}/keycloak-service.sh" owner: root group: root mode: 0755 notify: - restart keycloak - name: configure sysconfig file for keycloak service become: yes ansible.builtin.template: src: keycloak-sysconfig.j2 dest: /etc/sysconfig/keycloak owner: root group: root mode: 0644 notify: - restart keycloak - name: configure systemd unit file for keycloak service ansible.builtin.template: src: keycloak.service.j2 dest: /etc/systemd/system/keycloak.service owner: root group: root mode: 0644 become: yes register: systemdunit notify: - restart keycloak - name: reload systemd become: yes ansible.builtin.systemd: daemon_reload: yes when: systemdunit.changed - name: start keycloak ansible.builtin.systemd: name: keycloak enabled: yes state: started become: yes - name: Check service status ansible.builtin.command: "systemctl status keycloak" register: keycloak_service_status changed_when: False - name: Verify service status ansible.builtin.assert: that: - keycloak_service_status is defined - keycloak_service_status.stdout is defined - name: Flush handlers ansible.builtin.meta: flush_handlers - name: "Wait until Keycloak becomes active {{ keycloak.health_url }}" ansible.builtin.uri: url: "{{ keycloak.health_url }}" register: keycloak_status until: keycloak_status.status == 200 retries: 25 delay: 10