Skip to content

Commit 1152ae8

Browse files
committed
[ceph] Add thin-provisioned LV support for Ceph OSDs
When cifmw_ceph_thin_pool is defined, create thin LVs from an existing VG thin pool instead of loop-backed files. This supports baremetal hosts where the disk is fully consumed by a thin pool with no raw devices available for cephadm. The new play runs before the existing loop device play and sets cifmw_ceph_spec_data_devices with explicit LV paths, which also causes the loop device play to be skipped. Signed-off-by: Bohdan Dobrelia <bdobreli@redhat.com>
1 parent 7bd0b77 commit 1152ae8

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

hooks/playbooks/ceph.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,60 @@
124124
name: cifmw_cephadm
125125
tasks_from: install_cephadm
126126

127+
- name: Create thin-provisioned LVs for Ceph OSDs
128+
tags: block
129+
hosts: "{{ cifmw_ceph_target | default('computes') }}"
130+
gather_facts: true
131+
become: true
132+
pre_tasks:
133+
- name: Skip when thin pool is not configured
134+
when:
135+
- cifmw_ceph_thin_pool is not defined or
136+
not _deploy_ceph | default(true)
137+
ansible.builtin.meta: end_play
138+
tasks:
139+
- name: Compute OSD count per host
140+
ansible.builtin.set_fact:
141+
cifmw_num_osds_perhost: >-
142+
{% if groups[cifmw_ceph_target | default('computes')] | length == 1 %}3{% else %}1{% endif %}
143+
144+
- name: Install LVM prerequisite packages
145+
ansible.builtin.dnf:
146+
name:
147+
- lvm2
148+
- jq
149+
state: present
150+
151+
- name: Create thin LVs from existing thin pool
152+
ansible.builtin.command:
153+
cmd: >-
154+
lvcreate -V {{ cifmw_ceph_thin_lv_size | default('50G') }}
155+
--thin -n ceph_osd_{{ item }}
156+
{{ cifmw_ceph_thin_pool }}
157+
creates: "/dev/{{ cifmw_ceph_thin_pool.split('/')[0] }}/ceph_osd_{{ item }}"
158+
loop: "{{ range(0, cifmw_num_osds_perhost | int) | list }}"
159+
160+
- name: Build data_devices paths list
161+
ansible.builtin.set_fact:
162+
_ceph_thin_lv_paths: >-
163+
{{ range(0, cifmw_num_osds_perhost | int) | map('regex_replace', '^(.*)$',
164+
'/dev/' ~ cifmw_ceph_thin_pool.split('/')[0] ~ '/ceph_osd_\1') | list }}
165+
166+
- name: Set cifmw_ceph_spec_data_devices on compute hosts
167+
ansible.builtin.set_fact:
168+
cifmw_ceph_spec_data_devices: |
169+
data_devices:
170+
paths:
171+
{% for p in _ceph_thin_lv_paths %}
172+
- {{ p }}
173+
{% endfor %}
174+
175+
- name: Propagate cifmw_ceph_spec_data_devices to localhost
176+
ansible.builtin.set_fact:
177+
cifmw_ceph_spec_data_devices: "{{ cifmw_ceph_spec_data_devices }}"
178+
delegate_to: localhost
179+
delegate_facts: true
180+
127181
- name: Create Block Device on target nodes
128182
tags: block
129183
hosts: "{{ cifmw_ceph_target | default('computes') }}"

0 commit comments

Comments
 (0)