Skip to content

Commit

Permalink
feat: add support mounting/unmounting snapshots and origins
Browse files Browse the repository at this point in the history
support the following role variables:

snapshot_lvm_mount_origin
snapshot_lvm_mountpoint_create
snapshot_lvm_unmount_multiple
snapshot_lvm_mountpoint
snapshot_lvm_mount_options

add mount/umount commands to the snapshot CLI.

add basic tests for functionallity

Signed-off-by: Todd Gill <[email protected]>
  • Loading branch information
trgill committed Feb 12, 2024
1 parent 3c2518d commit 6b79b9e
Show file tree
Hide file tree
Showing 17 changed files with 2,117 additions and 59 deletions.
70 changes: 65 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,69 @@ This variable is required. It supports one of the following values:
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:
```yaml
snapshot_test_set:
name: snapset1
volumes:
- name: snapshot VG1 LV1
vg: test_vg1
lv: lv1
percent_space_required: 20
- name: snapshot VG1 LV1
percent_space_required: 15
mountpoint: /mnt/lv1_mp
- name: snapshot VG2 LV3
vg: test_vg2
lv: lv3
mountpoint: /mnt/lv3_mp
percent_space_required: 15
- name: snapshot VG2 LV4
vg: test_vg2
lv: lv4
mountpoint: /mnt/lv4_mp
percent_space_required: 15
- name: snapshot VG3 LV7
vg: test_vg3
lv: lv7
mountpoint: /mnt/lv7_mp
percent_space_required: 15
```
If the user is indicating the mount action and wants the origin of the snapshot to be mounted rather
than the snapshot, the set would be defined with the additional field "mount_origin" for any entry
that it applies, for example:
```yaml
snapshot_test_set:
name: snapset1
volumes:
- name: snapshot VG1 LV1
vg: test_vg1
lv: lv1
percent_space_required: 25
percent_space_required: 15
mountpoint: /mnt/lv1_mp
mount_origin: false
- name: snapshot VG2 LV3
vg: test_vg2
lv: lv3
mountpoint: /mnt/lv3_mp
percent_space_required: 15
mount_origin: true
- name: snapshot VG2 LV4
vg: test_vg2
lv: lv4
mountpoint: /mnt/lv4_mp
percent_space_required: 15
mount_origin: false
- name: snapshot VG3 LV7
vg: test_vg3
lv: lv7
mountpoint: /mnt/lv7_mp
percent_space_required: 15
mount_origin: true
```
The mount_origin flag defaults to false, so it is not necessary when the user is mounting the
snapshot rather than the origin.
If before running the role, with :
### snapshot_lvm_snapset_name
Expand Down Expand Up @@ -154,6 +195,25 @@ be removed by the remove command without snapshot_lvm_verify_only.
snapshot_lvm_verify_only is intended to be used to double check that the snapshot or
remove command have completed the operation correctly.

### snapshot_lvm_mountpoint_create

If the mount point specified doesn't currently exist, create the mount point and any
parent directories necessary for the mount point.

### snapshot_lvm_mountpoint

The provide mount target for the block device

### snapshot_lvm_mount_origin

If set to true, mount the origin of the snapshot rather than the snapshot.

### snapshot_lvm_unmount_multiple

If set to true, unmount all mountpoint for the resulting blockdevice.
Linux allows filesytems to be mounted in multiple locations. Setting
this flag will unmount all locations.

### Variables Exported by the Role

#### snapshot_facts
Expand Down
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@

snapshot_lvm_all_vgs: false
snapshot_lvm_verify_only: false
snapshot_lvm_mount_origin: false
snapshot_lvm_mountpoint_create: false
snapshot_lvm_unmount_multiple: false
snapshot_lvm_vg: ''
snapshot_lvm_lv: ''
snapshot_lvm_snapset_name: ''
snapshot_lvm_percent_space_required: ''
snapshot_lvm_set: ''
snapshot_lvm_mountpoint: ''
snapshot_lvm_mount_options: ''
Loading

0 comments on commit 6b79b9e

Please sign in to comment.