INF-162 - Configure keycloak client setting via built-in Ansible plugin
Change-Id: Ifd6b43d148a52727e2044c0c4314203fa7711286
diff --git a/tasks/main.yml b/tasks/main.yml
index 0df97e8..5722125 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -75,3 +75,35 @@
notify:
- "start-keycloak"
- "restart-keycloak"
+- name: Flush handlers to start keycloak server before configuring it via API
+ meta: flush_handlers
+
+- name: Wait for Keycloak to be ready
+ uri:
+ url: "http://localhost:9990/health"
+ method: GET
+ return_content: "yes"
+ timeout: 5
+ body_format: raw
+ follow_redirects: "no"
+ status_code: 200
+ register: result
+ until: result.status == 200
+ retries: 60
+ delay: 5
+
+- name: Configure Keycloak client
+ community.general.keycloak_client:
+ auth_keycloak_url: http://localhost:8080/auth
+ auth_realm: "{{ item.auth_realm }}"
+ auth_username: "{{ keycloak_admin_username }}"
+ auth_password: "{{ keycloak_admin_password }}"
+ client_id: "{{ item.client_id }}"
+ name: "{{ item.name }}"
+ protocol: "{{ item.protocol }}"
+ description: "{{ item.description }}"
+ attributes: "{{ item.attributes }}"
+ redirect_uris: "{{ item.redirect_uris }}"
+ protocol_mappers: "{{ item.protocol_mappers }}"
+ state: present
+ with_items: "{{ keycloak_client_settings }}"