11# cifmw_block_device
22
3- Creates a virtual block device with logical volumes. Useful for
4- deploying Ceph on a virtual machine which does not have any
5- block devices except for root. Creates a systemd unit so the
6- virtual block device comes back online during reboot.
3+ Creates block devices with logical volumes for Ceph OSD testing.
4+ Supports two modes:
75
8- The target system must have 7 GB of available disk space at minimum.
6+ - ** Loop mode** (default): creates a loop-backed file with LVM on top
7+ and a systemd unit to restore it across reboots. Useful for VMs
8+ that have no spare block devices.
9+ - ** Thin-pool mode** : creates thin-provisioned LVs from an existing
10+ VG thin pool. Useful for bare-metal hosts that already have a
11+ thin pool with available space.
912
10- This role will recreate the block device on each run. Thus, if there
11- is data on the block device from the previous run it will delete it.
12- The assumption is that the block device exists for testing and that
13- rebuilding the environment quickly is more important preserving any
14- test data.
13+ The mode is selected by ` cifmw_block_device_thin_pool ` : when non-empty
14+ the role uses thin-pool mode, otherwise loop mode.
1515
1616## Privilege escalation
1717
18- Requires root on the remote system to create loop back device and
19- systemd unit.
18+ Requires root on the remote system to create devices and LVM objects.
2019
2120## Parameters
2221
22+ ### Common
23+
24+ * ` cifmw_block_device_thin_pool ` : VG/pool path for thin-pool mode,
25+ e.g. ` vg/lv_thinpool ` . When empty (default), loop mode is used.
26+
27+ ### Loop mode
28+
2329* ` cifmw_block_device_image_file ` : Name of the ` dd'd ` image file
2430 (default ` /var/lib/ceph-osd.img ` )
2531* ` cifmw_block_device_size ` : Size of the virtual block device (default
@@ -34,8 +40,25 @@ systemd unit.
3440 restores the device on system startup (default
3541 ` /etc/systemd/system/ceph-osd-losetup.service ` )
3642
43+ ### Thin-pool mode
44+
45+ * ` cifmw_block_device_thin_lv_size ` : Size of each thin LV (default
46+ ` 50G ` )
47+ * ` cifmw_block_device_thin_lv_name ` : Name of the thin LV to create
48+ (default ` ceph_osd ` )
49+
50+ ## Output
51+
52+ Both modes append to the ` cifmw_block_device_paths ` list fact.
53+ Each role invocation adds one entry, so when called in a loop
54+ the list accumulates all created device paths (e.g.
55+ ` ["/dev/ceph_vg0/ceph_lv0", "/dev/ceph_vg1/ceph_lv1"] ` or
56+ ` ["/dev/vg/ceph_osd_0", "/dev/vg/ceph_osd_1"] ` ).
57+
3758## Examples
3859
60+ ### Loop mode (default)
61+
3962The following will create a 7 GB block device on the target system
4063using the defaults above.
4164```
@@ -60,11 +83,30 @@ data_devices:
6083 paths:
6184 - /dev/ceph_vg/ceph_lv_data
6285```
63- The following will stop and disable the systemd unit file which starts
64- the virtual block device, remove the logical volume, volume group, and
65- physical volume, and delete the loopback device and its backing file.
86+
87+ ### Thin-pool mode
88+
89+ ``` yaml
90+ - include_role :
91+ name : cifmw_block_device
92+ vars :
93+ cifmw_block_device_thin_pool : " vg/lv_thinpool"
94+ cifmw_block_device_thin_lv_size : " 50G"
95+ cifmw_block_device_thin_lv_name : " ceph_osd_0"
96+ ` ` `
97+ Ceph spec entry:
98+ ` ` ` yaml
99+ data_devices :
100+ paths :
101+ - /dev/vg/ceph_osd_0
66102` ` `
103+
104+ ### Cleanup
105+
106+ ` ` ` yaml
67107- import_role :
68108 name : cifmw_block_device
69109 tasks_from : cleanup
70110` ` `
111+ For thin-pool mode, pass ` cifmw_block_device_thin_pool` and
112+ ` cifmw_block_device_thin_lv_name` so the correct cleanup path runs.
0 commit comments