-
Notifications
You must be signed in to change notification settings - Fork 141
[multiple] Discover and configure Glance with Ceph RGW secrets #3169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
fultonj marked this conversation as resolved.
Show resolved
Hide resolved
fultonj marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| --- | ||
| # Copyright Red Hat, Inc. | ||
| # All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| # not use this file except in compliance with the License. You may obtain | ||
| # a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for the specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| - name: Set fact for glance S3 backend secrets | ||
| ansible.builtin.set_fact: | ||
| ceph_s3_access_key: "{{ cifmw_ceph_client_s3_glance_user['keys'][0]['access_key'] }}" | ||
| ceph_s3_secret_key: "{{ cifmw_ceph_client_s3_glance_user['keys'][0]['secret_key'] }}" | ||
| ceph_s3_bucket: "glance-s3-bucket" | ||
| ceph_s3_endpoint: "{{ cifmw_ceph_client_s3_internal_swift_url }}" | ||
| when: | ||
| - cifmw_ceph_client_s3_glance_user is defined | ||
| - cifmw_ceph_client_s3_internal_swift_url is defined | ||
| no_log: true | ||
|
|
||
| - name: Generate Glance S3 backend secrets using Ceph RGW credentials | ||
| ansible.builtin.template: | ||
| src: templates/k8s_ceph_rgw_glance_secret.j2 | ||
| dest: k8s_ceph_rgw_glance_secret.yaml | ||
| mode: "0600" | ||
| force: true | ||
| when: | ||
| - ceph_s3_access_key is defined | ||
| - ceph_s3_secret_key is defined | ||
| no_log: true | ||
| register: reg_k8s_ceph_rgw_glance_secret | ||
|
|
||
| - name: Create glance S3 backend secrets | ||
| kubernetes.core.k8s: | ||
| kubeconfig: "{{ cifmw_openshift_kubeconfig }}" | ||
| api_key: "{{ cifmw_openshift_token | default(omit)}}" | ||
| context: "{{ cifmw_openshift_context | default(omit) }}" | ||
| namespace: openstack | ||
| state: present | ||
| apply: true | ||
| force: true | ||
| src: k8s_ceph_rgw_glance_secret.yaml | ||
| register: k8s_glance_s3_secret | ||
| delegate_to: localhost | ||
| no_log: true | ||
| when: reg_k8s_ceph_rgw_glance_secret is not skipped | ||
|
|
||
| - name: Delete the rendered secret file | ||
| ansible.builtin.file: | ||
| path: k8s_ceph_rgw_glance_secret.yaml | ||
| state: absent | ||
| delegate_to: localhost | ||
| when: k8s_glance_s3_secret | default(true) |
fultonj marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Glance secrets used to configure glance with ceph S3 backend | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: s3glance | ||
| stringData: | ||
| s3glance.conf: | | ||
| [default_backend] | ||
| s3_store_host = {{ ceph_s3_endpoint }} | ||
| s3_store_access_key = {{ ceph_s3_access_key }} | ||
| s3_store_secret_key = {{ ceph_s3_secret_key }} | ||
| s3_store_bucket = {{ ceph_s3_bucket }} | ||
| s3_store_cacert = "/etc/pki/tls/certs/ca-bundle.crt" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| --- | ||
| # Copyright 2025 Red Hat, Inc. | ||
| # All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| # not use this file except in compliance with the License. You may obtain | ||
| # a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for the specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| - name: Create glance S3 RGW user and fetch object-store endpoint | ||
| when: cifmw_cephadm_rgw_s3_glance | default(false) | bool | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: put the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we have |
||
| block: | ||
| - name: Refresh ceph_cli | ||
| ansible.builtin.include_tasks: ceph_cli.yml | ||
| vars: | ||
| ceph_command: "radosgw-admin" | ||
|
|
||
| - name: Wait for RGW daemons to be running | ||
| ansible.builtin.command: | ||
| cmd: "{{ cifmw_cephadm_ceph_cli }} orch ps --daemon-type rgw --format json" | ||
| register: rgw_daemon_status | ||
| become: true | ||
| changed_when: false | ||
| failed_when: false | ||
| until: > | ||
| rgw_daemon_status.rc == 0 and | ||
| (rgw_daemon_status.stdout | default('[]') | from_json | default([], true)) | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: second default does not make sense. |
||
| selectattr('status_desc', 'equalto', 'running') | | ||
| list | length > 0 | ||
| retries: 30 | ||
| delay: 10 | ||
|
|
||
| - name: Check if Ceph S3 glance user exists | ||
| ansible.builtin.command: | ||
| cmd: >- | ||
| {{ cifmw_cephadm_ceph_cli }} user info --uid glance | ||
| no_log: true | ||
| become: true | ||
| ignore_errors: true | ||
| changed_when: false | ||
| register: cifmw_ceph_s3_glance_user_check | ||
| when: cifmw_cephadm_ceph_cli is defined | ||
|
|
||
| - name: Create Ceph S3 glance user | ||
| ansible.builtin.command: | ||
| cmd: >- | ||
| {{ cifmw_cephadm_ceph_cli }} user create | ||
| --uid="glance" | ||
| --display-name="Glance S3 User" | ||
| become: true | ||
| when: | ||
| - cifmw_ceph_s3_glance_user_check is not skipped | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the condition for that tasks are almost fine. What is missing: keep logic.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes,cover two cases if |
||
| - cifmw_ceph_s3_glance_user_check.rc != 0 | ||
| register: glance_rgw_user_create | ||
| retries: 3 | ||
| delay: 5 | ||
| until: glance_rgw_user_create.rc == 0 | ||
|
|
||
| - name: Get RGW glance user info | ||
| ansible.builtin.command: | ||
| cmd: >- | ||
| {{ cifmw_cephadm_ceph_cli }} user info --uid="glance" | ||
| become: true | ||
| no_log: true | ||
| changed_when: false | ||
| register: ceph_rgw_glance_user_info | ||
|
|
||
| - name: Show RGW daemon status on failure | ||
| when: ceph_rgw_glance_user_info.rc != 0 | ||
| block: | ||
| - name: Get RGW daemon status for debugging | ||
| ansible.builtin.command: | ||
| cmd: "{{ cifmw_cephadm_ceph_cli }} orch ps --daemon-type rgw" | ||
| become: true | ||
| register: rgw_debug_status | ||
| changed_when: false | ||
|
|
||
| - name: Display RGW status | ||
| ansible.builtin.debug: | ||
| msg: "RGW daemon status: {{ rgw_debug_status.stdout }}" | ||
|
|
||
| - name: Fail with context | ||
| ansible.builtin.fail: | ||
| msg: | | ||
| Failed to fetch glance user info after creation. | ||
| User creation result: {{ glance_rgw_user_create | default('not attempted') }} | ||
| RGW daemon status shown above. | ||
| - name: Set facts RGW glance user | ||
| ansible.builtin.set_fact: | ||
| cifmw_ceph_s3_glance_user: "{{ ceph_rgw_glance_user_info.stdout | from_json }}" | ||
| when: | ||
| - ceph_rgw_glance_user_info is defined | ||
| - ceph_rgw_glance_user_info.rc == 0 | ||
| no_log: true | ||
|
|
||
| - name: Get OpenStack internal object-store endpoints | ||
| cifmw.general.ci_script: | ||
| extra_args: | ||
| KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" | ||
| output_dir: "{{ cifmw_cephadm_basedir }}/artifacts" | ||
| script: |- | ||
| oc -n {{ cifmw_cephadm_ns }} rsh openstackclient openstack endpoint list --service object-store --interface internal -f value -c URL | ||
| delegate_to: localhost | ||
| register: object_store_endpoint_raw | ||
| when: | ||
| - cifmw_openshift_kubeconfig is defined | ||
| - cifmw_cephadm_basedir is defined | ||
| - cifmw_cephadm_rgw_s3_glance is defined | ||
|
|
||
| - name: Extract base URL without path | ||
| ansible.builtin.set_fact: | ||
| rgw_internal_url: >- | ||
| {{ | ||
| object_store_endpoint_raw.stdout | ||
| | regex_replace('(/swift.*)$', '') | ||
| }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the following to this call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can't use
when: cifmw_cephadm_rgw_s3_glance | default(false) | boolwhen we import role .Addedwhen: cifmw_cephadm_rgw_s3_glance | default(false) | boolat begining of glance_s3_info task