2022-05-09 13:57:12 +00:00
|
|
|
---
|
2022-03-17 09:45:55 +00:00
|
|
|
- name: "Configure {{ keycloak.service_name }} service script wrapper"
|
2021-12-14 10:26:42 +00:00
|
|
|
become: yes
|
2022-02-24 14:00:10 +00:00
|
|
|
ansible.builtin.template:
|
2021-12-14 10:26:42 +00:00
|
|
|
src: keycloak-service.sh.j2
|
|
|
|
dest: "{{ keycloak_dest }}/keycloak-service.sh"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
notify:
|
|
|
|
- restart keycloak
|
|
|
|
|
2022-04-28 09:58:29 +00:00
|
|
|
- name: Determine JAVA_HOME for selected JVM RPM # noqa blocked_modules
|
|
|
|
ansible.builtin.shell: |
|
2022-04-28 09:33:23 +00:00
|
|
|
set -o pipefail
|
|
|
|
rpm -ql {{ keycloak_jvm_package }} | grep -Po '/usr/lib/jvm/.*(?=/bin/java$)'
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
2022-04-28 09:58:29 +00:00
|
|
|
changed_when: False
|
2022-04-28 09:33:23 +00:00
|
|
|
register: rpm_java_home
|
|
|
|
|
2022-03-17 09:45:55 +00:00
|
|
|
- name: "Configure sysconfig file for {{ keycloak.service_name }} service"
|
2021-12-14 10:26:42 +00:00
|
|
|
become: yes
|
2022-02-24 14:00:10 +00:00
|
|
|
ansible.builtin.template:
|
2021-12-14 10:26:42 +00:00
|
|
|
src: keycloak-sysconfig.j2
|
|
|
|
dest: /etc/sysconfig/keycloak
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2022-04-28 09:33:23 +00:00
|
|
|
vars:
|
|
|
|
keycloak_rpm_java_home: "{{ rpm_java_home.stdout }}"
|
2021-12-14 10:26:42 +00:00
|
|
|
notify:
|
|
|
|
- restart keycloak
|
|
|
|
|
2022-03-17 09:45:55 +00:00
|
|
|
- name: "Configure systemd unit file for {{ keycloak.service_name }} service"
|
2022-02-24 14:00:10 +00:00
|
|
|
ansible.builtin.template:
|
2021-12-14 10:26:42 +00:00
|
|
|
src: keycloak.service.j2
|
|
|
|
dest: /etc/systemd/system/keycloak.service
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
become: yes
|
|
|
|
register: systemdunit
|
|
|
|
notify:
|
|
|
|
- restart keycloak
|
|
|
|
|
2022-03-08 11:08:40 +00:00
|
|
|
- name: Reload systemd
|
2021-12-14 10:26:42 +00:00
|
|
|
become: yes
|
2022-02-24 14:00:10 +00:00
|
|
|
ansible.builtin.systemd:
|
2021-12-14 10:26:42 +00:00
|
|
|
daemon_reload: yes
|
|
|
|
when: systemdunit.changed
|
|
|
|
|
2022-03-17 09:45:55 +00:00
|
|
|
- name: "Start and wait for {{ keycloak.service_name }} service (first node db)"
|
2022-03-08 11:08:40 +00:00
|
|
|
ansible.builtin.include_tasks: start_keycloak.yml
|
|
|
|
run_once: yes
|
|
|
|
when: keycloak_db_enabled
|
|
|
|
|
2022-03-17 09:45:55 +00:00
|
|
|
- name: "Start and wait for {{ keycloak.service_name }} service (remaining nodes)"
|
2022-03-08 11:08:40 +00:00
|
|
|
ansible.builtin.include_tasks: start_keycloak.yml
|
2021-12-14 10:26:42 +00:00
|
|
|
|
2022-01-27 13:23:11 +00:00
|
|
|
- name: Check service status
|
2022-02-24 14:00:10 +00:00
|
|
|
ansible.builtin.command: "systemctl status keycloak"
|
2021-12-14 10:26:42 +00:00
|
|
|
register: keycloak_service_status
|
|
|
|
changed_when: False
|
|
|
|
|
2022-01-27 13:23:11 +00:00
|
|
|
- name: Verify service status
|
2022-02-24 14:00:10 +00:00
|
|
|
ansible.builtin.assert:
|
2021-12-14 10:26:42 +00:00
|
|
|
that:
|
|
|
|
- keycloak_service_status is defined
|
|
|
|
- keycloak_service_status.stdout is defined
|
|
|
|
|
2022-02-15 12:14:36 +00:00
|
|
|
- name: Flush handlers
|
2022-02-24 14:00:10 +00:00
|
|
|
ansible.builtin.meta: flush_handlers
|