|
| 1 | +--- |
| 2 | +- name: Clean up existing mariadb-operator |
| 3 | + community.general.make: |
| 4 | + chdir: "{{ install_yamls_dir }}" |
| 5 | + target: mariadb_cleanup |
| 6 | + environment: |
| 7 | + MARIADB_IMG: "{{ mariadb_operator_index }}" |
| 8 | + OPERATOR_NAMESPACE: "{{ operator_namespace }}" |
| 9 | + NAMESPACE: "{{ cr_namespace }}" |
| 10 | + OUT: "{{ tmp_dir }}" |
| 11 | + TIMEOUT: "{{ deployment_timeout }}" |
| 12 | + tags: |
| 13 | + - operator |
| 14 | + |
| 15 | +- name: Wait until the catalogsource associated with the old mariadb-operator is deleted |
| 16 | + ansible.builtin.shell: > |
| 17 | + oc -n {{ operator_namespace }} wait --for=delete --timeout={{ deployment_timeout }} |
| 18 | + catalogsource/mariadb-operator-index |
| 19 | + changed_when: false |
| 20 | + tags: |
| 21 | + - operator |
| 22 | + |
| 23 | +- name: Remove the leftover install plans associated with the old mariadb-operator |
| 24 | + ansible.builtin.shell: | |
| 25 | + set -o pipefail |
| 26 | + oc -n {{ operator_namespace }} get installplans -o name | xargs -r oc -n {{ operator_namespace }} delete |
| 27 | + changed_when: false |
| 28 | + tags: |
| 29 | + - operator |
| 30 | + |
| 31 | +- name: Prepare the resource required to install a new mariadb-operator |
| 32 | + community.general.make: |
| 33 | + chdir: "{{ install_yamls_dir }}" |
| 34 | + target: mariadb_prep |
| 35 | + environment: |
| 36 | + MARIADB_IMG: "{{ mariadb_operator_index }}" |
| 37 | + OPERATOR_NAMESPACE: "{{ operator_namespace }}" |
| 38 | + NAMESPACE: "{{ cr_namespace }}" |
| 39 | + OUT: "{{ tmp_dir }}" |
| 40 | + TIMEOUT: "{{ deployment_timeout }}" |
| 41 | + tags: |
| 42 | + - operator |
| 43 | + |
| 44 | +- name: Install the catalogsource for the new mariadb-operator |
| 45 | + # Apply CatalogSource first and wait for OLM to have fetch the bundle information, otherwise |
| 46 | + # the old bundle info might be reused when creating the subscription CR |
| 47 | + # Note: several mariadb-operator-index pods are created, but only one gets ready, so wait accordingly |
| 48 | + ansible.builtin.shell: | |
| 49 | + set -e -o pipefail |
| 50 | + oc -n {{ operator_namespace }} apply -f {{ tmp_dir }}/openstack-operators/mariadb/op/catalogsource.yaml |
| 51 | + until oc -n {{ operator_namespace }} get pods -l olm.catalogSource=mariadb-operator-index -o jsonpath='{range .items[*]}{.metadata.name} {.status.containerStatuses[*].ready}{end}' | grep -w -m1 true; do sleep 2; done |
| 52 | + index_pod=$(oc -n {{ operator_namespace }} get pod -l olm.catalogSource=mariadb-operator-index -o name) |
| 53 | + test -n "${index_pod}" |
| 54 | + timeout {{ deployment_timeout | community.general.to_seconds | int }} bash -c "oc -n {{ operator_namespace }} logs '${index_pod}' -f | grep -m1 'grpc.code=OK.*GetBundleForChannel'" |
| 55 | + changed_when: false |
| 56 | + tags: |
| 57 | + - operator |
| 58 | + |
| 59 | +- name: Apply subscriptions and operatorgroup to deploy the new mariadb-operator |
| 60 | + ansible.builtin.shell: | |
| 61 | + set -e |
| 62 | + oc -n {{ operator_namespace }} apply -f {{ tmp_dir }}/openstack-operators/mariadb/op/operatorgroup.yaml |
| 63 | + oc -n {{ operator_namespace }} apply -f {{ tmp_dir }}/openstack-operators/mariadb/op/subscription.yaml |
| 64 | + changed_when: false |
| 65 | + tags: |
| 66 | + - operator |
0 commit comments