|
| 1 | +--- |
| 2 | +# Workaround: fix Swift (RGW) endpoint IP and port in Keystone. |
| 3 | +# |
| 4 | +# The cifmw_cephadm configure_object.yml registers the endpoint using |
| 5 | +# cifmw_cephadm_rgw_vip:8080, which assumes the ceph ingress service |
| 6 | +# (haproxy+keepalived) is deployed. On single-host HCI (no ingress), |
| 7 | +# the VIP is never bound and port 8080 never listens — RGW is directly |
| 8 | +# reachable on the host's storage IP at port 8082. |
| 9 | +# |
| 10 | +# This hook discovers the actual RGW address and port from the running |
| 11 | +# ceph cluster and updates the Keystone endpoints to match. |
| 12 | +# |
| 13 | +# FIXME(ci-framework): The proper fix belongs in |
| 14 | +# cifmw_cephadm/tasks/configure_object.yml — it should detect whether |
| 15 | +# ingress is deployed and choose VIP:8080 vs host_ip:8082 accordingly. |
| 16 | +- name: Fix Swift endpoint to match actual RGW address |
| 17 | + hosts: "{{ groups[cifmw_ceph_target | default('computes')] | first }}" |
| 18 | + gather_facts: false |
| 19 | + vars: |
| 20 | + _target_group: "{{ cifmw_ceph_target | default('computes') }}" |
| 21 | + _target: "{{ groups[_target_group] | default([]) | first }}" |
| 22 | + ansible_ssh_private_key_file: >- |
| 23 | + {{ |
| 24 | + hostvars[_target]['ansible_ssh_private_key_file'] | |
| 25 | + default(lookup('env', 'ANSIBLE_SSH_PRIVATE_KEY')) |
| 26 | + }} |
| 27 | + tasks: |
| 28 | + - name: Get RGW daemon endpoint from ceph |
| 29 | + become: true |
| 30 | + ansible.builtin.shell: | |
| 31 | + set -euo pipefail |
| 32 | + cephadm shell -- ceph orch ps --daemon-type rgw --format json 2>/dev/null |
| 33 | + register: _rgw_ps |
| 34 | + |
| 35 | + - name: Get ingress service status |
| 36 | + become: true |
| 37 | + ansible.builtin.shell: | |
| 38 | + set -euo pipefail |
| 39 | + cephadm shell -- ceph orch ls --service-type ingress --format json 2>/dev/null |
| 40 | + register: _ingress_ls |
| 41 | + |
| 42 | + - name: Set RGW endpoint facts |
| 43 | + vars: |
| 44 | + _rgw_daemons: "{{ _rgw_ps.stdout | from_json }}" |
| 45 | + _ingress_services: "{{ _ingress_ls.stdout | from_json }}" |
| 46 | + _has_ingress: >- |
| 47 | + {{ _ingress_services | length > 0 and |
| 48 | + (_ingress_services | first).status.running | default(0) | int > 0 }} |
| 49 | + block: |
| 50 | + - name: Determine endpoint from ingress VIP |
| 51 | + when: _has_ingress | bool |
| 52 | + ansible.builtin.set_fact: |
| 53 | + _rgw_port: "{{ (_ingress_services | first).spec.frontend_port | default(8080) }}" |
| 54 | + _rgw_ip: >- |
| 55 | + {{ (_ingress_services | first).status.virtual_ip | |
| 56 | + regex_replace('/.*$', '') }} |
| 57 | +
|
| 58 | + - name: Determine endpoint from RGW daemon |
| 59 | + when: not (_has_ingress | bool) |
| 60 | + ansible.builtin.set_fact: |
| 61 | + _rgw_port: "{{ (_rgw_daemons | first).ports | first }}" |
| 62 | + _rgw_ip: "{{ (_rgw_daemons | first).ip | default(ansible_host) }}" |
| 63 | + |
| 64 | + - name: Update Swift endpoints in Keystone |
| 65 | + environment: |
| 66 | + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" |
| 67 | + delegate_to: localhost |
| 68 | + block: |
| 69 | + - name: Get current Swift endpoints |
| 70 | + ansible.builtin.shell: | |
| 71 | + set -euo pipefail |
| 72 | + oc -n {{ cifmw_cephadm_ns | default('openstack') }} \ |
| 73 | + exec -t openstackclient -- \ |
| 74 | + openstack endpoint list --service object-store -f json |
| 75 | + register: _swift_eps |
| 76 | + |
| 77 | + - name: Update each Swift endpoint URL |
| 78 | + vars: |
| 79 | + _eps: "{{ _swift_eps.stdout | from_json }}" |
| 80 | + _url_prefix: "http://{{ _rgw_ip }}:{{ _rgw_port }}" |
| 81 | + ansible.builtin.shell: | |
| 82 | + set -euo pipefail |
| 83 | + oc -n {{ cifmw_cephadm_ns | default('openstack') }} \ |
| 84 | + exec -t openstackclient -- \ |
| 85 | + openstack endpoint set \ |
| 86 | + --url '{{ _url_prefix }}/swift/v1/AUTH_%(tenant_id)s' \ |
| 87 | + {{ item.ID }} |
| 88 | + loop: "{{ _eps }}" |
| 89 | + loop_control: |
| 90 | + label: "{{ item.Interface }}" |
| 91 | + when: >- |
| 92 | + _url_prefix not in (item.URL | default('')) |
0 commit comments