New file |
| | |
| | | - name: Get codeready route host |
| | | command: > |
| | | oc get route/codeready -o jsonpath='{.spec.host}' -n "{{ _namespace }}" |
| | | register: che_route |
| | | retries: "{{ _retry }}" |
| | | delay: "{{ _delay }}" |
| | | until: che_route.stdout != "" |
| | | |
| | | - name: Get keycloak route host |
| | | command: > |
| | | oc get route/keycloak -o jsonpath='{.spec.host}' -n "{{ _namespace }}" |
| | | register: keycloak_route |
| | | retries: "{{ _retry }}" |
| | | delay: "{{ _delay }}" |
| | | until: keycloak_route.stdout != "" |
| | | |
| | | - name: Get Che user token |
| | | uri: |
| | | url: "http://{{ keycloak_route.stdout }}/auth/realms/codeready/protocol/openid-connect/token" |
| | | method: POST |
| | | body: |
| | | username: "{{ _namespace }}" |
| | | password: "{{ _account_password }}" |
| | | grant_type: "password" |
| | | client_id: "admin-cli" |
| | | body_format: form-urlencoded |
| | | status_code: 200 |
| | | register: user_token |
| | | |
| | | - name: Get workspace for {{ _namespace }} |
| | | uri: |
| | | url: "http://{{ che_route.stdout }}/api/workspace" |
| | | method: GET |
| | | headers: |
| | | Accept: application/json |
| | | Authorization: "Bearer {{ user_token.json.access_token }}" |
| | | status_code: 200 |
| | | register: workspace_def |
| | | |
| | | - name: Verify and start workspace for {{ _namespace }} again if stopped |
| | | when: workspace_def.json[0].status == "STOPPED" |
| | | uri: |
| | | url: "http://{{ che_route.stdout }}/api/workspace/{{ workspace_def.json[0].id }}/runtime" |
| | | method: POST |
| | | headers: |
| | | Accept: application/json |
| | | Authorization: "Bearer {{ user_token.json.access_token }}" |
| | | status_code: 200 |