|
| 1 | +- name: Retrieve the known ns_record values from the designate database |
| 2 | + ansible.builtin.shell: | |
| 3 | + {{ shell_header }} |
| 4 | + {{ oc_header }} |
| 5 | + DB_ROOT_PASSWORD=$(oc get -o json secret/osp-secret | jq -r .data.DbRootPassword | base64 -d) |
| 6 | + oc exec openstack-galera-0 -c galera -- mysql -rs -uroot -p"$DB_ROOT_PASSWORD" \ |
| 7 | + -e "select a.hostname, a.priority from designate.pool_ns_records a;" > /tmp/designate_ns_records_raw.txt |
| 8 | + register: records_check_results |
| 9 | + changed_when: false |
| 10 | + |
| 11 | +- name: Parse ns_record values into YAML format for CR |
| 12 | + ansible.builtin.shell: | |
| 13 | + set -e |
| 14 | + raw=/tmp/designate_ns_records_raw.txt |
| 15 | + out=/tmp/designate_ns_records.yaml |
| 16 | + if [ ! -s "$raw" ]; then |
| 17 | + echo "[]" > "$out" |
| 18 | + else |
| 19 | + awk '{ gsub(/\.$/, "", $1); if (NF >= 2) printf "- hostname: %s.\n priority: %s\n", $1, $2 }' "$raw" > "$out" |
| 20 | + fi |
| 21 | + args: |
| 22 | + executable: /bin/bash |
| 23 | + |
| 24 | +- name: Enable the designate redis instance in OpenShift |
| 25 | + ansible.builtin.shell: | |
| 26 | + {{ shell_header }} |
| 27 | + {{ oc_header }} |
| 28 | +
|
| 29 | + oc patch openstackcontrolplane openstack --type=merge --patch ' |
| 30 | + spec: |
| 31 | + redis: |
| 32 | + enabled: true |
| 33 | + templates: |
| 34 | + designate-redis: |
| 35 | + replicas: 1 |
| 36 | + ' |
| 37 | + register: designate_redis_config_results |
| 38 | + changed_when: true |
| 39 | + failed_when: designate_redis_config_results.rc != 0 |
| 40 | + |
| 41 | +- name: Wait for the designate redis instance to become ready |
| 42 | + ansible.builtin.shell: | |
| 43 | + {{ shell_header }} |
| 44 | + {{ oc_header }} |
| 45 | +
|
| 46 | + oc wait --for condition=Ready --timeout=60s redises.redis.openstack.org/designate-redis |
| 47 | + register: designate_redis_ready_result |
| 48 | + until: designate_redis_ready_result is success |
| 49 | + retries: 60 |
| 50 | + delay: "{{ designate_retry_delay }}" |
| 51 | + |
| 52 | +- name: Create designate OSP patch file (main CR) |
| 53 | + ansible.builtin.shell: | |
| 54 | + patch_file=/tmp/designate_osp_patch.yaml |
| 55 | + cat << MAINCR > "$patch_file" |
| 56 | + spec: |
| 57 | + designate: |
| 58 | + enabled: true |
| 59 | + template: |
| 60 | + designateAPI: |
| 61 | + networkAttachments: |
| 62 | + - internalapi |
| 63 | + designateWorker: |
| 64 | + networkAttachments: |
| 65 | + - designate |
| 66 | + replicas: 3 |
| 67 | + designateCentral: |
| 68 | + replicas: 3 |
| 69 | + designateProducer: |
| 70 | + replicas: 3 |
| 71 | + designateBackendbind9: |
| 72 | + networkAttachments: |
| 73 | + - designate |
| 74 | + override: |
| 75 | + services: |
| 76 | + - metadata: |
| 77 | + annotations: |
| 78 | + metallb.universe.tf/address-pool: designateext |
| 79 | + metallb.universe.tf/allow-shared-ip: designateext |
| 80 | + metallb.universe.tf/loadBalancerIPs: 172.50.0.80 |
| 81 | + - metadata: |
| 82 | + annotations: |
| 83 | + metallb.universe.tf/address-pool: designateext |
| 84 | + metallb.universe.tf/allow-shared-ip: designateext |
| 85 | + metallb.universe.tf/loadBalancerIPs: 172.50.0.81 |
| 86 | + - metadata: |
| 87 | + annotations: |
| 88 | + metallb.universe.tf/address-pool: designateext |
| 89 | + metallb.universe.tf/allow-shared-ip: designateext |
| 90 | + metallb.universe.tf/loadBalancerIPs: 172.50.0.82 |
| 91 | + replicas: 3 |
| 92 | + storageClass: $STORAGE_CLASS_NAME |
| 93 | + storageRequest: 10G |
| 94 | + designateMdns: |
| 95 | + networkAttachments: |
| 96 | + - designate |
| 97 | + replicas: 3 |
| 98 | + designateUnbound: |
| 99 | + networkAttachments: |
| 100 | + - designate |
| 101 | + replicas: 2 |
| 102 | + override: |
| 103 | + services: |
| 104 | + - metadata: |
| 105 | + annotations: |
| 106 | + metallb.universe.tf/address-pool: designateext |
| 107 | + metallb.universe.tf/allow-shared-ip: designateext |
| 108 | + metallb.universe.tf/loadBalancerIPs: 172.50.0.85 |
| 109 | + - metadata: |
| 110 | + annotations: |
| 111 | + metallb.universe.tf/address-pool: designateext |
| 112 | + metallb.universe.tf/allow-shared-ip: designateext |
| 113 | + metallb.universe.tf/loadBalancerIPs: 172.50.0.86 |
| 114 | + MAINCR |
| 115 | + environment: |
| 116 | + STORAGE_CLASS_NAME: "{{ storage_class_name }}" |
| 117 | + |
| 118 | +- name: Append nsRecords to designate OSP patch file |
| 119 | + ansible.builtin.shell: | |
| 120 | + ns_yaml=/tmp/designate_ns_records.yaml |
| 121 | + patch_file=/tmp/designate_osp_patch.yaml |
| 122 | +
|
| 123 | + echo ' nsRecords:' >> "$patch_file" |
| 124 | + if [ -s "$ns_yaml" ] && [ "$(cat "$ns_yaml")" != "[]" ]; then |
| 125 | + sed 's/^/ /' "$ns_yaml" >> "$patch_file" |
| 126 | + else |
| 127 | + echo ' []' >> "$patch_file" |
| 128 | + fi |
| 129 | +
|
| 130 | +- name: Enable designate service in OpenShift |
| 131 | + ansible.builtin.shell: | |
| 132 | + {{ shell_header }} |
| 133 | + {{ oc_header }} |
| 134 | +
|
| 135 | + oc patch openstackcontrolplane openstack --type=merge --patch-file /tmp/designate_osp_patch.yaml |
| 136 | + register: designate_service_config_results |
| 137 | + changed_when: true |
| 138 | + failed_when: designate_service_config_results.rc != 0 |
| 139 | + |
| 140 | +- name: Wait for the designate service to become ready |
| 141 | + ansible.builtin.shell: | |
| 142 | + {{ shell_header }} |
| 143 | + {{ oc_header }} |
| 144 | +
|
| 145 | + oc wait --for condition=Ready --timeout=60s designates.designate.openstack.org/designate |
| 146 | + register: designate_service_ready_result |
| 147 | + until: designate_service_ready_result is success |
| 148 | + retries: 60 |
| 149 | + delay: "{{ designate_retry_delay }}" |
0 commit comments