-
Notifications
You must be signed in to change notification settings - Fork 156
[adoption_osp_deploy] Add dcn_storage scenario for DCN adoption with Ceph HCI #3697
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
Merged
openshift-merge-bot
merged 1 commit into
openstack-k8s-operators:main
from
fultonj:dcn_adoption_hci
Mar 10, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
|
|
||
| # This playbook exports a TripleO stack for use by DCN stacks. | ||
| # It creates the <stack_name>-export.yaml file that contains | ||
| # the parameters DCN stacks need to connect to the central site. | ||
|
|
||
| - name: Export TripleO stack for DCN | ||
| hosts: "{{ cifmw_target_host | default('localhost') }}" | ||
| gather_facts: false | ||
| vars: | ||
| _stack_name: "{{ stack_name | default('central') }}" | ||
| _ansible_user_dir: "{{ ansible_user_dir | default('/home/zuul') }}" | ||
| tasks: | ||
| - name: Gather ansible_user_dir from undercloud | ||
| delegate_to: "osp-undercloud-0" | ||
| ansible.builtin.setup: | ||
| gather_subset: | ||
| - user_dir | ||
|
|
||
| - name: Export stack for DCN usage | ||
| delegate_to: "osp-undercloud-0" | ||
| vars: | ||
| _export_cmd: >- | ||
| source {{ _ansible_user_dir }}/stackrc; | ||
| openstack overcloud export | ||
| --stack {{ _stack_name }} | ||
| --force-overwrite | ||
| --output-file {{ _ansible_user_dir }}/overcloud-deploy/{{ _stack_name }}/{{ _stack_name }}-export.yaml | ||
| cifmw.general.ci_script: | ||
| chdir: "{{ _ansible_user_dir }}" | ||
| output_dir: "{{ _ansible_user_dir }}/ci-framework-data/artifacts" | ||
| script: "{{ _export_cmd }}" | ||
|
|
||
| - name: Export Ceph configuration for DCN usage | ||
| delegate_to: "osp-undercloud-0" | ||
| vars: | ||
| _export_ceph_cmd: >- | ||
| source {{ ansible_user_dir }}/stackrc; | ||
| openstack overcloud export ceph | ||
| --stack {{ _stack_name }} | ||
| --force-overwrite | ||
| --output-file {{ ansible_user_dir }}/{{ _stack_name }}_ceph_external.yaml | ||
| cifmw.general.ci_script: | ||
| chdir: "{{ ansible_user_dir }}" | ||
| output_dir: "{{ ansible_user_dir }}/ci-framework-data/artifacts" | ||
| script: "{{ _export_ceph_cmd }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,231 @@ | ||
| --- | ||
| # 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. | ||
|
|
||
| # This playbook updates the central site after all DCN sites are deployed. | ||
| # 1. Copy Ceph keys and configuration from DCN sites to central controllers | ||
| # 2. Configure Glance with DCN Ceph stores | ||
| # 3. Restart Glance to apply the new configuration | ||
|
|
||
| - name: Update central site with DCN Ceph stores | ||
| hosts: "{{ cifmw_target_host | default('localhost') }}" | ||
| gather_facts: false | ||
| vars: | ||
| _dcn_stack_names: "{{ dcn_stack_names | default('dcn1,dcn2') }}" | ||
| _glance_config_file: "/var/lib/config-data/puppet-generated/glance_api/etc/glance/glance-api.conf" | ||
| tasks: | ||
| - name: Build list of DCN sites from scenario | ||
| vars: | ||
| _dcn_name: "{{ item }}" | ||
| _dcn_stack: >- | ||
| {{ cifmw_adoption_osp_deploy_scenario.stacks | | ||
| selectattr('stackname', 'equalto', _dcn_name) | | ||
| first }} | ||
| _dcn_group: "{{ _dcn_stack.stack_nodes | first }}" | ||
| _dcn_node: "{{ _vm_groups[_dcn_group] | first }}" | ||
| ansible.builtin.set_fact: | ||
| _dcn_sites: >- | ||
| {{ _dcn_sites | default([]) + [{'name': _dcn_name, 'ceph_node': _dcn_node}] }} | ||
| loop: "{{ _dcn_stack_names.split(',') }}" | ||
|
|
||
| - name: Get list of controller nodes | ||
| vars: | ||
| _central_stack: >- | ||
| {{ cifmw_adoption_osp_deploy_scenario.stacks | | ||
| selectattr('stackname', 'equalto', central_stack_name | default('central')) | | ||
| first }} | ||
| _controller_group: >- | ||
| {{ _central_stack.stack_nodes | | ||
| select('search', 'controller') | | ||
| first | default('osp-controllers') }} | ||
| ansible.builtin.set_fact: | ||
| _controller_nodes: "{{ _vm_groups[_controller_group] | default([]) }}" | ||
|
|
||
| - name: Display discovered nodes | ||
| ansible.builtin.debug: | ||
| msg: | ||
| - "DCN sites: {{ _dcn_sites }}" | ||
| - "Controller nodes: {{ _controller_nodes }}" | ||
|
|
||
| - name: Build Glance DCN store configuration | ||
| ansible.builtin.set_fact: | ||
| _glance_dcn_config: | | ||
| {% for site in _dcn_sites %} | ||
| [{{ site.name }}] | ||
| rbd_store_ceph_conf=/etc/ceph/{{ site.name }}.conf | ||
| rbd_store_user=openstack | ||
| rbd_store_pool=images | ||
| rbd_thin_provisioning=False | ||
| store_description={{ site.name }} rbd glance store | ||
| {% endfor %} | ||
|
|
||
| - name: Copy Ceph files from DCN sites to controllers | ||
| block: | ||
| - name: Ensure ceph config directory exists on controllers | ||
| delegate_to: "{{ item }}" | ||
| become: true | ||
| ansible.builtin.file: | ||
| path: "/var/lib/tripleo-config/ceph" | ||
| state: directory | ||
| owner: root | ||
| group: root | ||
| mode: "0755" | ||
| loop: "{{ _controller_nodes }}" | ||
|
|
||
| - name: Fetch Ceph config from DCN site | ||
| delegate_to: "{{ item.ceph_node }}" | ||
| become: true | ||
| ansible.builtin.fetch: | ||
| src: "/var/lib/tripleo-config/ceph/{{ item.name }}.conf" | ||
| dest: "/tmp/ceph_files/{{ item.name }}.conf" | ||
| flat: true | ||
| loop: "{{ _dcn_sites }}" | ||
| loop_control: | ||
| label: "{{ item.name }}" | ||
|
|
||
| - name: Fetch Ceph keyring from DCN site | ||
| delegate_to: "{{ item.ceph_node }}" | ||
| become: true | ||
| ansible.builtin.fetch: | ||
| src: "/var/lib/tripleo-config/ceph/{{ item.name }}.client.openstack.keyring" | ||
| dest: "/tmp/ceph_files/{{ item.name }}.client.openstack.keyring" | ||
| flat: true | ||
| loop: "{{ _dcn_sites }}" | ||
| loop_control: | ||
| label: "{{ item.name }}" | ||
|
|
||
| - name: Copy Ceph config to controllers | ||
| delegate_to: "{{ item.1 }}" | ||
| become: true | ||
| ansible.builtin.copy: | ||
| src: "/tmp/ceph_files/{{ item.0.name }}.conf" | ||
| dest: "/var/lib/tripleo-config/ceph/{{ item.0.name }}.conf" | ||
| owner: root | ||
| group: root | ||
| mode: "0644" | ||
| loop: "{{ _dcn_sites | product(_controller_nodes) | list }}" | ||
| loop_control: | ||
| label: "{{ item.0.name }} -> {{ item.1 }}" | ||
|
|
||
| - name: Copy Ceph keyring to controllers | ||
| delegate_to: "{{ item.1 }}" | ||
| become: true | ||
| ansible.builtin.copy: | ||
| src: "/tmp/ceph_files/{{ item.0.name }}.client.openstack.keyring" | ||
| dest: "/var/lib/tripleo-config/ceph/{{ item.0.name }}.client.openstack.keyring" | ||
| owner: root | ||
| group: root | ||
| mode: "0644" | ||
|
fultonj marked this conversation as resolved.
|
||
| loop: "{{ _dcn_sites | product(_controller_nodes) | list }}" | ||
| loop_control: | ||
| label: "{{ item.0.name }} -> {{ item.1 }}" | ||
|
|
||
| - name: Configure Glance with DCN stores | ||
| block: | ||
| - name: Check glance config status on each controller | ||
| delegate_to: "{{ controller }}" | ||
| become: true | ||
| ansible.builtin.stat: | ||
| path: "{{ _glance_config_file }}" | ||
| register: _glance_status | ||
| loop: "{{ _controller_nodes }}" | ||
| loop_control: | ||
| loop_var: controller | ||
|
|
||
| - name: Build list of controllers needing Glance update | ||
| ansible.builtin.set_fact: | ||
| _controllers_to_update: >- | ||
| {{ _glance_status.results | | ||
| selectattr('stat.exists') | | ||
| map(attribute='controller') | | ||
| list }} | ||
|
|
||
| - name: Display controllers to update | ||
| ansible.builtin.debug: | ||
| msg: "Controllers needing Glance update: {{ _controllers_to_update }}" | ||
|
|
||
| - name: Get current enabled_backends value | ||
| delegate_to: "{{ controller }}" | ||
| become: true | ||
| ansible.builtin.command: | ||
| cmd: awk -F'\s*=\s*' '/^enabled_backends\s*=/{print $2; exit}' "{{ _glance_config_file }}" | ||
| register: _current_backends | ||
| changed_when: false | ||
| loop: "{{ _controllers_to_update }}" | ||
| loop_control: | ||
| loop_var: controller | ||
|
|
||
| - name: Build DCN backends string | ||
| ansible.builtin.set_fact: | ||
| _dcn_backends_suffix: >- | ||
| {{ _dcn_sites | map(attribute='name') | map('regex_replace', '^(.*)$', ',\1:rbd') | join('') }} | ||
|
|
||
| - name: Update enabled_backends to include DCN stores | ||
| delegate_to: "{{ item.controller }}" | ||
| become: true | ||
| ansible.builtin.lineinfile: | ||
| path: "{{ _glance_config_file }}" | ||
| regexp: '^enabled_backends\s*=' | ||
| line: "enabled_backends={{ item.stdout }}{{ _dcn_backends_suffix }}" | ||
| backrefs: false | ||
| loop: "{{ _current_backends.results }}" | ||
| loop_control: | ||
| label: "{{ item.controller }}" | ||
| when: >- | ||
| _dcn_sites | map(attribute='name') | | ||
| map('regex_replace', '^(.*)$', '\1:rbd') | | ||
| reject('in', item.stdout) | list | length > 0 | ||
| notify: Restart Glance API service on updated controllers | ||
|
|
||
| - name: Enable copy-image import method for multistore | ||
| delegate_to: "{{ controller }}" | ||
| become: true | ||
| ansible.builtin.lineinfile: | ||
| path: "{{ _glance_config_file }}" | ||
| regexp: '^enabled_import_methods\s*=' | ||
| line: 'enabled_import_methods=["web-download","copy-image"]' | ||
| insertafter: '^\[DEFAULT\]' | ||
| loop: "{{ _controllers_to_update }}" | ||
| loop_control: | ||
| loop_var: controller | ||
| notify: Restart Glance API service on updated controllers | ||
|
|
||
| - name: Add DCN store configuration to glance-api.conf | ||
| delegate_to: "{{ controller }}" | ||
| become: true | ||
| ansible.builtin.blockinfile: | ||
| path: "{{ _glance_config_file }}" | ||
| block: "{{ _glance_dcn_config }}" | ||
| insertafter: EOF | ||
| loop: "{{ _controllers_to_update }}" | ||
| loop_control: | ||
| loop_var: controller | ||
| notify: Restart Glance API service on updated controllers | ||
|
|
||
| - name: Clean up temporary Ceph files | ||
| ansible.builtin.file: | ||
| path: /tmp/ceph_files | ||
| state: absent | ||
|
|
||
| handlers: | ||
| - name: Restart Glance API service on updated controllers | ||
| delegate_to: "{{ controller }}" | ||
| become: true | ||
| ansible.builtin.systemd: | ||
| name: tripleo_glance_api.service | ||
| state: restarted | ||
| loop: "{{ _controllers_to_update }}" | ||
| loop_control: | ||
| loop_var: controller | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.