Skip to content

Commit 4fdd89c

Browse files
authored
Merge branch 'main' into extra-var-files-pre-metal
2 parents 5eea3b0 + fc87553 commit 4fdd89c

21 files changed

Lines changed: 370 additions & 111 deletions

File tree

docs/dictionary/en-custom.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ IdP
1818
Idempotency
1919
LDAP
2020
LLM
21+
LVs
2122
MachineConfig
2223
Marjanovic
2324
MiB
@@ -236,6 +237,7 @@ fips
236237
firewalld
237238
flbxutz
238239
fmw
240+
frontend
239241
fqdn
240242
freefonts
241243
frmo

hooks/playbooks/ceph.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@
104104
gather_facts: false
105105
become: true
106106
tasks:
107+
- name: Gather network facts for IP-to-host mapping
108+
ansible.builtin.setup:
109+
gather_subset:
110+
- network
107111
# jq is normally installed by cifmw_block_device role, but when cifmw_ceph_spec_data_devices
108112
# is defined (indicating block devices are already present), the block device creation play
109113
# is skipped. Install jq explicitly here to ensure it's available for ceph operations.
@@ -159,6 +163,9 @@
159163
hostvars[_target]['ansible_ssh_private_key_file'] |
160164
default(lookup('env', 'ANSIBLE_SSH_PRIVATE_KEY'))
161165
}}
166+
cifmw_block_device_thin_pool: "{{ cifmw_ceph_thin_pool | default('') }}"
167+
cifmw_block_device_thin_lv_size: "{{ cifmw_ceph_thin_lv_size | default('50G') }}"
168+
cifmw_block_device_thin_lv_name: "ceph_osd_{{ i }}"
162169
cifmw_block_device_image_file: /var/lib/ceph-osd-{{ i }}.img
163170
cifmw_block_device_loop: /dev/loop{{ i + 3 }}
164171
cifmw_block_lv_name: ceph_lv{{ i }}
@@ -170,6 +177,17 @@
170177
loop_var: i
171178
loop: "{{ range(0, cifmw_num_osds_perhost|int) }}"
172179

180+
- name: Build data_devices for ceph spec from cifmw_block_device outputs
181+
ansible.builtin.set_fact:
182+
cifmw_ceph_spec_data_devices: |
183+
data_devices:
184+
paths:
185+
{% for p in cifmw_block_device_paths %}
186+
- {{ p }}
187+
{% endfor %}
188+
delegate_to: localhost
189+
delegate_facts: true
190+
173191
- name: Build Ceph spec and conf from gathered IPs of the target inventory group
174192
tags: spec
175193
hosts: localhost
@@ -186,9 +204,12 @@
186204
when:
187205
- not cifmw_ceph_ipv6 | default(false)
188206
ansible.builtin.set_fact:
189-
ssh_network_range: 192.168.122.0/24
190-
# storage_network_range: 172.18.0.0/24
191-
storage_mgmt_network_range: 172.20.0.0/24
207+
ssh_network_range: >-
208+
{{ cifmw_ceph_ssh_network_range | default('192.168.122.0/24') }}
209+
storage_network_range: >-
210+
{{ cifmw_ceph_storage_network_range | default('172.18.0.0/24') }}
211+
storage_mgmt_network_range: >-
212+
{{ cifmw_ceph_storage_mgmt_network_range | default('172.20.0.0/24') }}
192213
all_addresses: ansible_all_ipv4_addresses
193214
ms_bind_ipv4: true
194215
ms_bind_ipv6: false
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
# source: nova05epsilon/edpm-nodeset-values-post-ceph/values.yaml.j2
3+
# Auto-populates ceph_conf from files written by ceph.yml hook.
4+
# The ceph.yml post_stage_run hook (via cifmw_ceph_client role) writes
5+
# Ceph config files to cifmw_ceph_client_fetch_dir (default /tmp/).
6+
# This template reads those files and provides them as base64-encoded
7+
# values under data.ceph_conf (DCN convention).
8+
# When running in generate-CRs-only mode (mock validation), the files
9+
# won't exist; emit placeholders so kustomize can still build.
10+
{% set _fetch_dir = cifmw_ceph_client_fetch_dir | default('/tmp') %}
11+
{% set _cluster = cifmw_ceph_client_cluster | default('ceph') %}
12+
{% set _conf_file = (_fetch_dir, _cluster ~ '.conf') | path_join %}
13+
{% set _keyring_file = (_fetch_dir, _cluster ~ '.client.openstack.keyring') | path_join %}
14+
{% set _mock = cifmw_kustomize_deploy_generate_crs_only | default(false) | bool %}
15+
data:
16+
ceph_conf:
17+
{% if not _mock and _keyring_file is file and _conf_file is file %}
18+
{{ _cluster }}.client.openstack.keyring: {{ lookup('file', _keyring_file, rstrip=False) | b64encode }}
19+
{{ _cluster }}.conf: {{ lookup('file', _conf_file, rstrip=False) | b64encode }}
20+
{% else %}
21+
{{ _cluster }}.client.openstack.keyring: CHANGEME_CEPH_KEYRING
22+
{{ _cluster }}.conf: CHANGEME_CEPH_CONF
23+
{% endif %}

roles/cifmw_backup_restore/tasks/e2e.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,34 @@
7878
# ========================================
7979
# Step 2.5: Upload Swift test data
8080
# ========================================
81-
- name: Upload Swift test data before backup
82-
ansible.builtin.include_tasks: swift_data_upload.yml
81+
- name: Detect Swift and upload test data
8382
when: cifmw_backup_restore_test_swift_data | bool
83+
block:
84+
- name: Check if Swift is enabled in the control plane
85+
ansible.builtin.shell: |
86+
set -o pipefail
87+
oc get openstackcontrolplane -n {{ cifmw_backup_restore_namespace }} \
88+
-o jsonpath='{.items[0].spec.swift.enabled}'
89+
register: _swift_enabled_result
90+
changed_when: false
91+
failed_when: false
92+
93+
- name: Set Swift availability fact
94+
ansible.builtin.set_fact:
95+
_cifmw_backup_restore_swift_available: >-
96+
{{ (_swift_enabled_result.rc == 0) and
97+
(_swift_enabled_result.stdout | default('false') | bool) }}
98+
99+
- name: Skip Swift tests — Swift is not enabled
100+
ansible.builtin.debug:
101+
msg: >-
102+
Swift is not enabled in the OpenStackControlPlane CR.
103+
Skipping Swift data upload/verify steps.
104+
when: not (_cifmw_backup_restore_swift_available | bool)
105+
106+
- name: Upload Swift test data before backup
107+
ansible.builtin.include_tasks: swift_data_upload.yml
108+
when: _cifmw_backup_restore_swift_available | bool
84109

85110
# ========================================
86111
# Step 3: Create backup
@@ -275,6 +300,7 @@
275300
ansible.builtin.include_tasks: swift_data_verify.yml
276301
when:
277302
- cifmw_backup_restore_test_swift_data | bool
303+
- _cifmw_backup_restore_swift_available | default(false) | bool
278304
- cifmw_backup_restore_run_restore | bool
279305

280306
# ========================================

roles/cifmw_backup_restore/templates/00-resource-modifiers-configmap.yaml.j2

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ data:
1111
resourceModifierRules:
1212
- conditions:
1313
groupResource: "*"
14-
namespaces:
15-
- {{ cifmw_backup_restore_namespace }}
1614
mergePatches:
1715
- patchData: |
1816
metadata:
@@ -21,8 +19,6 @@ data:
2119
kubectl.kubernetes.io/last-applied-configuration: null
2220
- conditions:
2321
groupResource: openstackcontrolplanes.core.openstack.org
24-
namespaces:
25-
- {{ cifmw_backup_restore_namespace }}
2622
mergePatches:
2723
- patchData: |
2824
metadata:
@@ -31,8 +27,6 @@ data:
3127
core.openstack.org/deployment-stage: "infrastructure-only"
3228
- conditions:
3329
groupResource: instancehas.instanceha.openstack.org
34-
namespaces:
35-
- {{ cifmw_backup_restore_namespace }}
3630
mergePatches:
3731
- patchData: |
3832
spec:

roles/cifmw_backup_restore/templates/backup-pvcs.yaml.j2

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ spec:
2727
hooks:
2828
resources:
2929
- name: swift-xattr-backup
30-
includedNamespaces:
31-
- {{ cifmw_backup_restore_namespace }}
3230
labelSelector:
3331
matchLabels:
3432
component: swift-storage

roles/cifmw_block_device/README.md

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
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+
3962
The following will create a 7 GB block device on the target system
4063
using 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.

roles/cifmw_block_device/defaults/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@
1818
# All variables intended for modification should be placed in this file.
1919
# All variables within this role should have a prefix of "cifmw_block_device"
2020

21+
# --- Loop-device mode (default) ---
2122
cifmw_block_device_image_file: /var/lib/ceph-osd.img
2223
cifmw_block_device_size: 7G
2324
cifmw_block_device_loop: /dev/loop3
2425
cifmw_block_vg_name: ceph_vg
2526
cifmw_block_lv_name: ceph_lv_data
2627
cifmw_block_systemd_unit_file: /etc/systemd/system/ceph-osd-losetup.service
28+
29+
# --- Thin-pool mode ---
30+
# When non-empty, create thin-provisioned LVs from this existing thin pool
31+
# instead of loop-backed files. Value is "VG/pool", e.g. "vg/lv_thinpool".
32+
cifmw_block_device_thin_pool: ""
33+
cifmw_block_device_thin_lv_size: "50G"
34+
cifmw_block_device_thin_lv_name: "ceph_osd"

roles/cifmw_block_device/tasks/cleanup.yml

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,47 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17-
- name: Ensure ceph-osd-losetup is not running and disabled
18-
tags: systemd
17+
- name: Clean up thin-provisioned LV
18+
when: cifmw_block_device_thin_pool | length > 0
1919
become: true
20-
ansible.builtin.systemd:
21-
state: stopped
22-
enabled: false
23-
name: "{{ cifmw_block_systemd_unit_file | basename }}"
20+
ansible.builtin.command:
21+
cmd: >-
22+
lvremove --force
23+
/dev/{{ cifmw_block_device_thin_pool.split('/')[0] }}/{{ cifmw_block_device_thin_lv_name }}
24+
register: _thin_cleanup
25+
failed_when:
26+
- _thin_cleanup.rc != 0
27+
- "'not found' not in (_thin_cleanup.stderr | default(''))"
2428

25-
- name: Remove unit file
26-
become: true
27-
ansible.builtin.file:
28-
path: "{{ cifmw_block_systemd_unit_file }}"
29-
state: absent
29+
- name: Clean up loop-backed block device
30+
when: cifmw_block_device_thin_pool | default('') | length == 0
31+
block:
32+
- name: Ensure ceph-osd-losetup is not running and disabled
33+
tags: systemd
34+
become: true
35+
ansible.builtin.systemd:
36+
state: stopped
37+
enabled: false
38+
name: "{{ cifmw_block_systemd_unit_file | basename }}"
3039

31-
- name: Use {pv,vg,lv}remove to remove logical volume on loop device
32-
become: true
33-
ansible.builtin.shell:
34-
cmd: |-
35-
lvremove --force /dev/{{ cifmw_block_vg_name }}/{{ cifmw_block_lv_name }}
36-
vgremove --force {{ cifmw_block_vg_name }}
37-
pvremove --force {{ cifmw_block_device_loop }}
38-
lvs
40+
- name: Remove unit file
41+
become: true
42+
ansible.builtin.file:
43+
path: "{{ cifmw_block_systemd_unit_file }}"
44+
state: absent
45+
46+
- name: Use {pv,vg,lv}remove to remove logical volume on loop device
47+
become: true
48+
ansible.builtin.shell:
49+
cmd: |-
50+
lvremove --force /dev/{{ cifmw_block_vg_name }}/{{ cifmw_block_lv_name }}
51+
vgremove --force {{ cifmw_block_vg_name }}
52+
pvremove --force {{ cifmw_block_device_loop }}
53+
lvs
3954
40-
- name: Use losetup and rm to cremove the loop device and backing image file
55+
- name: Use losetup and rm to remove the loop device and backing image file
4156
become: true
57+
when: cifmw_block_device_thin_pool | length > 0
4258
ansible.builtin.shell:
4359
cmd: |-
4460
losetup -d {{ cifmw_block_device_loop }}

0 commit comments

Comments
 (0)