Browse Source

wait for import to finish and keycloak to restart after it

Grega Bremec 1 tháng trước cách đây
mục cha
commit
4b7f1ea087
1 tập tin đã thay đổi với 34 bổ sung0 xóa
  1. 34 0
      playbooks/roles/deploy-rhbk/tasks/present.yml

+ 34 - 0
playbooks/roles/deploy-rhbk/tasks/present.yml

@@ -320,6 +320,40 @@
         namespace: "{{ rhbk.namespace | default('keycloak') }}"
         name: "{{ rhbk.name | default('sso') }}-{{ rhbk.realm | default('sample-realm') }}-import"
         template: templates/realm-import-template.yaml.j2
+      register: created_import
+
+    - name: Wait for the import to rollout.
+      kubernetes.core.k8s_info:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: pod
+        namespace: "{{ rhbk.namespace | default('keycloak') }}"
+        label_selectors:
+          - app=keycloak-realm-import
+      register: import_running
+      until:
+        - import_running.resources is defined
+        - import_running.resources | length > 0
+        - import_running.resources[0].status.phase != "Pending"
+        - import_running.resources[0].status.phase != "Running"
+      when: created_import.changed
+
+    - name: Wait for the Keycloak pod to restart.
+      kubernetes.core.k8s_info:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: pod
+        namespace: "{{ rhbk.namespace | default('keycloak') }}"
+        label_selectors:
+          - app=keycloak
+      register: rhbk_running
+      until:
+        - rhbk_running.resources is defined
+        - rhbk_running.resources | length > 0
+        - rhbk_running.resources[0].status.phase == "Running"
+      when: created_import.changed
 
   when:
     - realms[rhbk.realm | default('sample-realm')] is not defined