Skip to content

Commit b924edb

Browse files
stuggiclaude
andcommitted
[b/r] Add OADP pre-flight checks to backup and restore playbooks
Fail early with a clear error message if OADP is not installed. Backup playbook also checks for a VolumeSnapshotClass with the Velero label. Also adds .splitlines() to backup playbook template lookups for pretty-printed debug output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3994109 commit b924edb

2 files changed

Lines changed: 47 additions & 2 deletions

File tree

docs/dev/backup-restore/backup/backup-openstack.yaml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,37 @@
4848
auto_ack: false
4949

5050
tasks:
51+
# ========================================
52+
# Pre-flight checks
53+
# ========================================
54+
- name: Verify OADP operator is installed
55+
ansible.builtin.shell: |
56+
oc get crd backups.velero.io -o name
57+
register: oadp_crd_check
58+
changed_when: false
59+
failed_when: false
60+
61+
- name: Fail if OADP is not installed
62+
ansible.builtin.fail:
63+
msg: |
64+
OADP operator is not installed (Velero Backup CRD not found).
65+
Install OADP first - see docs/dev/backup-restore/setup-oadp-minio.md
66+
when: oadp_crd_check.rc != 0
67+
68+
- name: Verify VolumeSnapshotClass with Velero label exists
69+
ansible.builtin.shell: |
70+
oc get volumesnapshotclass -l velero.io/csi-volumesnapshot-class=true -o name
71+
register: vsc_check
72+
changed_when: false
73+
failed_when: false
74+
75+
- name: Fail if no VolumeSnapshotClass with Velero label
76+
ansible.builtin.fail:
77+
msg: |
78+
No VolumeSnapshotClass found with label velero.io/csi-volumesnapshot-class=true.
79+
Label your VolumeSnapshotClass for Velero CSI snapshots.
80+
when: vsc_check.rc != 0 or vsc_check.stdout == ""
81+
5182
- name: Set backup timestamp
5283
ansible.builtin.set_fact:
5384
backup_name_suffix: "{{ lookup('pipe', 'date +%Y%m%d-%H%M%S') }}"
@@ -146,7 +177,7 @@
146177

147178
- name: "Next: Create PVC backup CR"
148179
ansible.builtin.debug:
149-
msg: "{{ lookup('file', rendered_dir.path + '/backup-pvcs.yaml') }}"
180+
msg: "{{ lookup('file', rendered_dir.path + '/backup-pvcs.yaml').splitlines() }}"
150181

151182
- name: Pause before PVC backup
152183
ansible.builtin.pause:
@@ -197,7 +228,7 @@
197228

198229
- name: "Next: Create resources backup CR"
199230
ansible.builtin.debug:
200-
msg: "{{ lookup('file', rendered_dir.path + '/backup-resources.yaml') }}"
231+
msg: "{{ lookup('file', rendered_dir.path + '/backup-resources.yaml').splitlines() }}"
201232

202233
- name: Pause before resources backup
203234
ansible.builtin.pause:

docs/dev/backup-restore/restore/restore-openstack.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@
9999
# ========================================
100100
# Pre-flight checks
101101
# ========================================
102+
- name: Verify OADP operator is installed
103+
ansible.builtin.shell: |
104+
oc get crd backups.velero.io -o name
105+
register: oadp_crd_check
106+
changed_when: false
107+
failed_when: false
108+
109+
- name: Fail if OADP is not installed
110+
ansible.builtin.fail:
111+
msg: |
112+
OADP operator is not installed (Velero Backup CRD not found).
113+
Install OADP first - see docs/dev/backup-restore/setup-oadp-minio.md
114+
when: oadp_crd_check.rc != 0
115+
102116
- name: Ensure target namespace exists
103117
ansible.builtin.shell: |
104118
oc create namespace {{ openstack_namespace }} --dry-run=client -o yaml | oc apply -f -

0 commit comments

Comments
 (0)