Skip to content

Commit

Permalink
feat: add support for snapshot sets of volumes that are not in the sa…
Browse files Browse the repository at this point in the history
…me VG

Reason: MVP requirements call for managment of snapshots as sets

Result: Users can manage sets of snapshots

Signed-off-by: Todd Gill <[email protected]>
Co-authored-by: Richard Megginson <[email protected]>
  • Loading branch information
trgill and richm committed Jan 24, 2024
1 parent 53c6ffd commit d63a45f
Show file tree
Hide file tree
Showing 29 changed files with 1,735 additions and 645 deletions.
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,43 @@ This variable is required. It supports one of the following values:

- `clean`: Remove snapshots that conform to the specified prefix and pattern

### snapshot_lvm_set

The snapshot role supports sets of volumes. Sets may contain any number of volumes.
Sets are defined in the following format:

```text
snapshot_lvm_set:
name: snapset1
volumes:
- name: snapshot VG1 LV1
vg: test_vg1
lv: lv1
percent_space_required: 20
- name: snapshot VG1 LV1
vg: test_vg2
lv: lv1
percent_space_required: 25
- name: snapshot VG2 LV3
vg: test_vg2
lv: lv3
percent_space_required: 15
- name: snapshot VG3 LV7
vg: test_vg3
lv: lv7
percent_space_required: 15
```

If before running the role, with :

### snapshot_lvm_prefix

This variable is required. snapshot_lvm_prefix is a string that will be
This variable is required if not using sets. snapshot_lvm_prefix is a string that will be
prepended to the name of the LV when the snapshot is created.

### snapshot_lvm_suffix

This variable is required. snapshot_lvm_prefix is a string that will be
This variable is required if not using sets. snapshot_lvm_prefix is a string that will be
appended to the name of the LV when the snapshot is created.

If before running the role, the following LVs exist:
Expand Down Expand Up @@ -87,7 +116,7 @@ lv3_vg3 vg3 owi-a-s--- 120.00m

### snapshot_lvm_percent_space_required

This is required for check and snapshot actions.
This is required for check and snapshot actions if not using sets.

See the LVM man page for lvcreate with the -s (snapshot) and -L (size) options.
The snapshot role will ensure that there is at least snapshot_lvm_percent_space_required
Expand All @@ -98,13 +127,14 @@ Note: LVM will round up size to full physical extent
### snapshot_lvm_all_vgs

This is a boolean value with default false. If true the role will snapshot
all VGs on the target system.
all VGs on the target system. If false, the snapshot_lvm_vg must be set.

### snapshot_lvm_vg

If set, the role will create snapshots for all the logical volumes in the volume group.
If snapshot_lvm_lv is also set, a snapshot will be created for only that logical volume
in the volume group.
in the volume group. If neither snapshot_lvm_all_vgs or snapshot_lvm_set are set,
snapshot_lvm_vg is required.

### snapshot_lvm_lv

Expand Down
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ snapshot_lvm_all_vgs: false
snapshot_lvm_verify_only: false
snapshot_lvm_vg: ''
snapshot_lvm_lv: ''
snapshot_lvm_prefix: ''
snapshot_lvm_suffix: ''
snapshot_lvm_percent_space_required: ''
snapshot_lvm_set: ''
6 changes: 6 additions & 0 deletions tasks/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Check snapshots will work or are completed (verify)
ansible.builtin.script: "{{ __snapshot_cmd }}"
args:
executable: "{{ __snapshot_python }}"
register: snapshot_cmd
10 changes: 0 additions & 10 deletions tasks/check_space.yml

This file was deleted.

6 changes: 1 addition & 5 deletions tasks/cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# SPDX-License-Identifier: MIT
---
- name: Remove snapshots from previous runs
ansible.builtin.script: >-
snapshot.py clean -a -p {{ snapshot_lvm_prefix | quote }}
-s {{ snapshot_lvm_suffix | quote }}
ansible.builtin.script: "{{ __snapshot_cmd }}"
args:
executable: "{{ __snapshot_python }}"
register: snapshot_cmd
failed_when:
snapshot_cmd.rc != 0
Loading

0 comments on commit d63a45f

Please sign in to comment.