diff --git a/playbooks/keycloak.yml b/playbooks/keycloak.yml index 4a2706c..020c1f7 100644 --- a/playbooks/keycloak.yml +++ b/playbooks/keycloak.yml @@ -1,11 +1,9 @@ --- - name: Playbook for Keycloak Hosts hosts: keycloak + vars: + keycloak_admin_password: "changeme" collections: - middleware_automation.keycloak - tasks: - - name: Include keycloak role - ansible.builtin.include_role: - name: middleware_automation.keycloak.keycloak - vars: - keycloak_admin_password: "changeme" \ No newline at end of file + roles: + - middleware_automation.keycloak.keycloak diff --git a/playbooks/rhsso.yml b/playbooks/rhsso.yml index 8aa73e9..13f4ce6 100644 --- a/playbooks/rhsso.yml +++ b/playbooks/rhsso.yml @@ -1,14 +1,12 @@ --- - name: Playbook for Keycloak Hosts hosts: keycloak + vars: + keycloak_admin_password: "changeme" + keycloak_rhsso_enable: True collections: - middleware_automation.redhat_csp_download + - middleware_automation.keycloak roles: - middleware_automation.redhat_csp_download.redhat_csp_download - tasks: - - name: Keycloak Role - ansible.builtin.include_role: - name: middleware_automation.keycloak.keycloak - vars: - keycloak_admin_password: "changeme" - keycloak_rhsso_enable: True \ No newline at end of file + - middleware_automation.keycloak.keycloak diff --git a/roles/keycloak/tasks/firewalld.yml b/roles/keycloak/tasks/firewalld.yml index e17b55c..15f91cb 100644 --- a/roles/keycloak/tasks/firewalld.yml +++ b/roles/keycloak/tasks/firewalld.yml @@ -12,7 +12,7 @@ enabled: yes state: started -- name: Configure firewall for keycloak ports +- name: "Configure firewall for {{ keycloak.service_name }} ports" become: yes firewalld: port: "{{ item }}" diff --git a/roles/keycloak/tasks/install.yml b/roles/keycloak/tasks/install.yml index e8ee292..c45a842 100644 --- a/roles/keycloak/tasks/install.yml +++ b/roles/keycloak/tasks/install.yml @@ -17,13 +17,13 @@ register: existing_deploy - block: - - name: Stop the old keycloak service + - name: "Stop the old {{ keycloak.service_name }} service" become: yes ignore_errors: yes ansible.builtin.systemd: name: keycloak state: stopped - - name: Remove the old Keycloak deployment + - name: "Remove the old {{ keycloak.service_name }} deployment" become: yes ansible.builtin.file: path: "{{ keycloak_jboss_home }}" @@ -35,7 +35,7 @@ ansible.builtin.stat: path: "{{ keycloak_jboss_home }}" -- name: Create Keycloak service user/group +- name: "Create {{ keycloak.service_name }} service user/group" become: yes ansible.builtin.user: name: "{{ keycloak_service_user }}" @@ -43,7 +43,7 @@ system: yes create_home: no -- name: Create Keycloak install location +- name: "Create {{ keycloak.service_name }} install location" become: yes ansible.builtin.file: dest: "{{ keycloak_dest }}" @@ -58,6 +58,7 @@ archive: "{{ keycloak_dest }}/{{ keycloak.bundle }}" - name: Check download archive path + become: yes ansible.builtin.stat: path: "{{ archive }}" register: archive_path diff --git a/roles/keycloak/tasks/main.yml b/roles/keycloak/tasks/main.yml index ef00cd0..c16f6cb 100644 --- a/roles/keycloak/tasks/main.yml +++ b/roles/keycloak/tasks/main.yml @@ -36,7 +36,7 @@ dest: /var/log/keycloak - block: - - name: Check admin credentials by generating a token + - name: Check admin credentials by generating a token (supposed to fail on first installation) ansible.builtin.uri: url: "{{ keycloak_url }}/auth/realms/master/protocol/openid-connect/token" method: POST diff --git a/roles/keycloak/tasks/restart_keycloak.yml b/roles/keycloak/tasks/restart_keycloak.yml index 255cb22..eff9ddf 100644 --- a/roles/keycloak/tasks/restart_keycloak.yml +++ b/roles/keycloak/tasks/restart_keycloak.yml @@ -1,5 +1,5 @@ --- -- name: "Restart and enable keycloack service" +- name: "Restart and enable {{ keycloak.service_name }} service" ansible.builtin.systemd: name: keycloak enabled: yes diff --git a/roles/keycloak/tasks/rhsso_patch.yml b/roles/keycloak/tasks/rhsso_patch.yml index d0ba46d..d4a4273 100644 --- a/roles/keycloak/tasks/rhsso_patch.yml +++ b/roles/keycloak/tasks/rhsso_patch.yml @@ -62,7 +62,7 @@ when: - cli_result.rc == 0 - - name: "Wait until Keycloak becomes active {{ keycloak.health_url }}" + - name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}" ansible.builtin.uri: url: "{{ keycloak.health_url }}" register: keycloak_status diff --git a/roles/keycloak/tasks/start_keycloak.yml b/roles/keycloak/tasks/start_keycloak.yml index 62d4f99..bdf42f9 100644 --- a/roles/keycloak/tasks/start_keycloak.yml +++ b/roles/keycloak/tasks/start_keycloak.yml @@ -1,12 +1,12 @@ --- -- name: Start keycloak +- name: "Start {{ keycloak.service_name }} service" ansible.builtin.systemd: name: keycloak enabled: yes state: started become: yes -- name: "Wait until Keycloak becomes active {{ keycloak.health_url }}" +- name: "Wait until {{ keycloak.service_name }} becomes active {{ keycloak.health_url }}" ansible.builtin.uri: url: "{{ keycloak.health_url }}" register: keycloak_status diff --git a/roles/keycloak/tasks/stop_keycloak.yml b/roles/keycloak/tasks/stop_keycloak.yml index ecf4411..fd87802 100644 --- a/roles/keycloak/tasks/stop_keycloak.yml +++ b/roles/keycloak/tasks/stop_keycloak.yml @@ -1,5 +1,5 @@ --- -- name: Stop keycloak +- name: "Stop {{ keycloak.service_name }}" ansible.builtin.systemd: name: keycloak enabled: yes diff --git a/roles/keycloak/tasks/systemd.yml b/roles/keycloak/tasks/systemd.yml index de643af..cfc3762 100644 --- a/roles/keycloak/tasks/systemd.yml +++ b/roles/keycloak/tasks/systemd.yml @@ -1,4 +1,4 @@ -- name: Configure keycloak service script wrapper +- name: "Configure {{ keycloak.service_name }} service script wrapper" become: yes ansible.builtin.template: src: keycloak-service.sh.j2 @@ -9,7 +9,7 @@ notify: - restart keycloak -- name: Configure sysconfig file for keycloak service +- name: "Configure sysconfig file for {{ keycloak.service_name }} service" become: yes ansible.builtin.template: src: keycloak-sysconfig.j2 @@ -20,7 +20,7 @@ notify: - restart keycloak -- name: Configure systemd unit file for keycloak service +- name: "Configure systemd unit file for {{ keycloak.service_name }} service" ansible.builtin.template: src: keycloak.service.j2 dest: /etc/systemd/system/keycloak.service @@ -38,12 +38,12 @@ daemon_reload: yes when: systemdunit.changed -- name: Start and wait for keycloak service (first node db) +- name: "Start and wait for {{ keycloak.service_name }} service (first node db)" ansible.builtin.include_tasks: start_keycloak.yml run_once: yes when: keycloak_db_enabled -- name: Start and wait for keycloak service (remaining nodes) +- name: "Start and wait for {{ keycloak.service_name }} service (remaining nodes)" ansible.builtin.include_tasks: start_keycloak.yml - name: Check service status