diff --git a/roles/sso/tasks/main.yml b/roles/sso/tasks/main.yml index e3d1124..4e3efb3 100644 --- a/roles/sso/tasks/main.yml +++ b/roles/sso/tasks/main.yml @@ -87,7 +87,14 @@ # Update the secure route to use "Re-encrypt" instead of "Passthrough" - include: update-route.yml tags: update-route - + + - include: wait_for.yml + static: no + vars: + pod_to_wait: + - sso + tags: status + - name: Get Admin Username command: oc get dc {{ sso_application_name }} -n "{{ sso_project }}" -o 'jsonpath={.spec.template.spec.containers[0].env[?(@.name=="SSO_ADMIN_USERNAME")].value}' register: username @@ -109,3 +116,5 @@ - name: SSO is ready ! debug: msg="Login on https://{{ route.stdout }}/auth/admin with username = '{{ username.stdout }}' and password = '{{ password.stdout }}'" tags: status + + - include: post-install.yml diff --git a/roles/sso/tasks/post-install.yml b/roles/sso/tasks/post-install.yml new file mode 100644 index 0000000..3052fc5 --- /dev/null +++ b/roles/sso/tasks/post-install.yml @@ -0,0 +1,6 @@ +--- + +# TODO Steps : +# - register a client +# - use that client to authenticate (openid connect password flow) +# - use the REST APIs to administer RH-SSO diff --git a/roles/sso/tasks/wait_for.yml b/roles/sso/tasks/wait_for.yml new file mode 100644 index 0000000..212b22b --- /dev/null +++ b/roles/sso/tasks/wait_for.yml @@ -0,0 +1,9 @@ +--- + + - name: Wait for all pending deployments to become ready + command: 'oc get rc -o json -n "{{ sso_project }}"' + register: rc_state + changed_when: false + retries: "{{ sso_retries }}" + delay: "{{ sso_delay }}" + until: 'rc_state.stdout |from_json |json_query(''items[? status.replicas != `0` && (status.readyReplicas == ""|| status.readyReplicas == `0`) ].metadata.annotations."openshift.io/deployment-config.name"'') |intersect(pod_to_wait) |length == 0' diff --git a/roles/sso/vars/main.yml b/roles/sso/vars/main.yml index 9d4b9ab..9dc4c1b 100644 --- a/roles/sso/vars/main.yml +++ b/roles/sso/vars/main.yml @@ -15,3 +15,5 @@ sso_admin_username: admin sso_application_name: sso sso_service_username: cli + sso_retries: 30 + sso_delay: 5