|
6 | 6 | KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" |
7 | 7 | PATH: "{{ cifmw_path }}" |
8 | 8 | tasks: |
| 9 | + - name: Set the loki-operator version to pin the version |
| 10 | + ansible.builtin.set_fact: |
| 11 | + loki_operator_version: "v6.3.0" |
| 12 | + |
9 | 13 | - name: Deploy loki operator |
10 | 14 | ansible.builtin.shell: |
11 | 15 | cmd: | |
12 | 16 | oc apply -f {{ ansible_user_dir }}/{{ zuul.projects['github.com/openstack-k8s-operators/telemetry-operator'].src_dir }}/ci/deploy-loki-for-ck.yaml |
13 | 17 |
|
14 | | - - name: Wait up to 5 minutes until the Loki CSV is Succeeded |
| 18 | + - name: Get and approve the installplan when the version is pinned |
| 19 | + when: loki_operator_version is defined |
| 20 | + block: |
| 21 | + - name: Get the installplan from the loki-operator subscription |
| 22 | + ansible.builtin.shell: |
| 23 | + cmd: | |
| 24 | + oc get installplan -n openshift-operators-redhat | grep "loki-operator.{{ loki_operator_version }}" | awk '{print $1}' |
| 25 | + retries: 10 |
| 26 | + delay: 10 |
| 27 | + register: loki_installplan |
| 28 | + until: loki_installplan.stdout_lines | length != 0 |
| 29 | + |
| 30 | + - name: Show the loki_installplan from oc get installplan |
| 31 | + ansible.builtin.debug: |
| 32 | + var: loki_installplan |
| 33 | + |
| 34 | + - name: Approve the installation |
| 35 | + ansible.builtin.shell: |
| 36 | + cmd: | |
| 37 | + oc patch -n openshift-operators-redhat installplan {{ loki_installplan.stdout }} --type='json' -p='[{"op": "replace", "path": "/spec/approved", "value":true}]' |
| 38 | +
|
| 39 | + # need to have a wait here, since the csv is not created immediately. There is a slight delay, during which time, the oc wait command would fail, since there's no resource to watch |
| 40 | + - name: Wait for the required resource to be created |
| 41 | + ansible.builtin.command: |
| 42 | + cmd: |
| 43 | + oc get csv --namespace=openshift-operators loki-operator.{{ loki_operator_version }} |
| 44 | + delay: 10 |
| 45 | + retries: 60 |
| 46 | + register: output |
| 47 | + until: output.stdout_lines | length != 0 |
| 48 | + |
| 49 | + - name: Wait for the resources to be available |
15 | 50 | ansible.builtin.shell: |
16 | | - cmd: |
17 | | - oc get csv | grep loki-operator | grep Succeeded |
| 51 | + cmd: | |
| 52 | + oc get csv | grep loki-operator |
18 | 53 | ignore_errors: true |
19 | 54 | register: output |
20 | | - until: output.stdout_lines | length == 1 |
| 55 | + until: output.stdout_lines | length == 1 and "Succeeded" in output.stdout_lines |
21 | 56 | retries: 30 |
22 | 57 | delay: 10 |
0 commit comments