Skip to content

Commit 3db9882

Browse files
Merge pull request #952 from katarimanojk/configure_swift_service
Configure swift to use rgw backend during ceph migration
2 parents c732c54 + 0aff1db commit 3db9882

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

tests/roles/ceph_migrate/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ ceph_node_exporter_container_image: "quay.io/prometheus/node-exporter:v1.5.0"
4848
ceph_prometheus_container_image: "quay.io/prometheus/prometheus:v2.43.0"
4949
ceph_storagenfs_nic: "nic2"
5050
ceph_storagenfs_vlan_id: "70"
51+
rhoso_namespace: "openstack"
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
- name: Set default namespace to {{ rhoso_namespace }}
2+
delegate_to: localhost
3+
ansible.builtin.shell: |
4+
oc project {{ rhoso_namespace }}
5+
6+
- name: Check for existing object store config
7+
delegate_to: localhost
8+
block:
9+
- name: Check if swift is enabled in deployed controlplane
10+
ansible.builtin.shell: |
11+
{{ shell_header }}
12+
oc get $(oc get oscp -o name) -o json| jq .spec.swift.enabled
13+
register: swift_in_ctlplane
14+
15+
# checking swift_endpoints_count will avoid unnecessary errors during ceph deployment re-run
16+
- name: Check if swift endpoint is already created
17+
ansible.builtin.shell: |
18+
{{ shell_header }}
19+
oc rsh openstackclient openstack endpoint list | grep 'swift.*object-store' | wc -l
20+
register: swift_endpoints_count
21+
ignore_errors: true
22+
23+
- name: Check if swift service is already created
24+
ansible.builtin.shell: |
25+
{{ shell_header }}
26+
oc rsh openstackclient openstack service list | grep 'swift.*object' | wc -l
27+
register: swift_services_count
28+
ignore_errors: true
29+
30+
- name: Display a note about swift deployment
31+
ansible.builtin.debug:
32+
msg: "WARNING: Swift is deployed and the endpoint exists already, ceph RGW cannot be configured as object store service"
33+
when:
34+
- swift_in_ctlplane.stdout | bool
35+
36+
- name: Create swift service
37+
delegate_to: localhost
38+
ansible.builtin.shell: |
39+
oc rsh openstackclient openstack service create --name swift --description 'OpenStack Object Storage' object-store
40+
when:
41+
- not swift_in_ctlplane.stdout | bool
42+
- swift_endpoints_count.stdout == "0"
43+
- swift_services_count.stdout == "0"
44+
45+
- name: Configure object store to use rgw
46+
delegate_to: localhost
47+
when:
48+
- not swift_in_ctlplane.stdout | bool
49+
- swift_endpoints_count.stdout == "0"
50+
block:
51+
- name: Capture required UUIDs
52+
ansible.builtin.command: "oc rsh openstackclient openstack {{ item.os_command }} show {{ item.os_command_object }} -c id -f value"
53+
register: all_uuids
54+
loop:
55+
- {os_command: 'user', os_command_object: 'swift'}
56+
- {os_command: 'service', os_command_object: 'swift'}
57+
- {os_command: 'role', os_command_object: 'member'}
58+
- {os_command: 'role', os_command_object: 'admin'}
59+
- {os_command: 'project', os_command_object: 'admin'}
60+
- {os_command: 'user', os_command_object: 'admin'}
61+
- {os_command: 'role', os_command_object: 'swiftoperator'}
62+
- {os_command: 'project', os_command_object: 'service'}
63+
64+
- name: Configure swift endpoints to use rgw
65+
ansible.builtin.shell: |
66+
{{ shell_header }}
67+
alias openstack="oc exec -t openstackclient -- openstack"
68+
69+
${BASH_ALIASES[openstack]} role add --user {{ all_uuids.results.0.stdout }} --project {{ all_uuids.results.7.stdout }} {{ all_uuids.results.2.stdout }}
70+
${BASH_ALIASES[openstack]} role add --user {{ all_uuids.results.0.stdout }} --project {{ all_uuids.results.7.stdout }} {{ all_uuids.results.3.stdout }}
71+
${BASH_ALIASES[openstack]} endpoint create --region regionOne {{ all_uuids.results.1.stdout }} public http://{{ ceph_rgw_virtual_ips_list[0] | ansible.utils.ipaddr('address') }}:8080/swift/v1/AUTH_%\(tenant_id\)s
72+
${BASH_ALIASES[openstack]} endpoint create --region regionOne {{ all_uuids.results.1.stdout }} internal http://{{ ceph_rgw_virtual_ips_list[0] | ansible.utils.ipaddr('address') }}:8080/swift/v1/AUTH_%\(tenant_id\)s
73+
${BASH_ALIASES[openstack]} role add --project {{ all_uuids.results.4.stdout }} --user {{ all_uuids.results.5.stdout }} {{ all_uuids.results.6.stdout }}

tests/roles/ceph_migrate/tasks/post.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@
55
dump: true
66
tags:
77
- ceph_dump
8+
9+
- name: Configure Swift to use rgw backend
10+
ansible.builtin.include_tasks: configure_object.yaml
11+
vars:
12+
shell_header: "set -euo pipefail"
13+
when: ceph_daemons_layout.rgw | default(true) | bool

0 commit comments

Comments
 (0)