Skip to content

Commit 7b64414

Browse files
authored
Merge pull request #8 from richm/richm-add_bootable
feat: some suggested fixes
2 parents 234f3d8 + 4127e4b commit 7b64414

File tree

4 files changed

+28
-33
lines changed

4 files changed

+28
-33
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ whose names start with `sql_db_`. This uses the Python `re.search`.
247247

248248
### snapshot_lvm_bootable
249249

250-
Boolean - default is unset. Only supported on operating systems that
250+
Boolean - default is false. Only supported on operating systems that
251251
support snapshot manager (snapm). When set to true, and passed to the
252252
'snapshot' command, the snapshot created will have a corresponding boot
253253
entry. The boot entry will be removed when the snapset is removed.

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ snapshot_lvm_mountpoint: ''
1717
snapshot_lvm_mount_options: ''
1818
snapshot_lvm_vg_include: ''
1919
snapshot_lvm_fstype: ''
20+
snapshot_lvm_bootable: false

tasks/main.yml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@
2828

2929
- name: Set snapm version
3030
set_fact:
31-
__snapshot_snapm_version: "{{ (__snapshot_snapm_version_output.stdout) }}"
32-
when:
33-
- __snapshot_snapm_available
31+
__snapshot_snapm_version: "{{ __snapshot_snapm_version_output.stdout }}"
32+
when: __snapshot_snapm_available
33+
34+
# Determine if bootable support is needed
35+
# If snapshot_lvm_bootable is set to true, or any of the volumes in snapshot_lvm_set
36+
# have bootable set to true, then bootable support is needed.
37+
- name: Set needs bootable support
38+
set_fact:
39+
__snapshot_needs_bootable_support: "{{ snapshot_lvm_bootable or (snapshot_lvm_set |
40+
selectattr('bootable', 'defined') |
41+
selectattr('bootable') | list | length > 0) }}"
3442

3543
- name: Package snapm version must be 0.4 or later
3644
fail:
@@ -41,23 +49,24 @@
4149
- __snapshot_snapm_available
4250
- __snapshot_snapm_version is version("0.4", "<")
4351

44-
- name: Package snapm required for bootable snapsets
45-
fail:
46-
msg: >
47-
Package snapm is required for bootable snapsets
48-
when:
49-
- not __snapshot_snapm_available
50-
- snapshot_lvm_bootable | d(false)
51-
52-
- name: Package snapm version must be 0.5 or later bootable snapsets
52+
- name: Package snapm must available and be version 0.5 or later for bootable snapsets
5353
fail:
5454
msg: >
5555
Package snapm version {{ __snapshot_snapm_version }} is too old -
5656
must be 0.5 or later to use bootable snapsets
5757
when:
58-
- __snapshot_snapm_available
59-
- __snapshot_snapm_version is version("0.5", "<")
60-
- snapshot_lvm_bootable | d(false)
58+
- not __snapshot_snapm_available or
59+
__snapshot_snapm_version is version("0.5", "<")
60+
- __snapshot_needs_bootable_support
61+
- snapshot_fail_if_too_old | d(true)
62+
63+
- name: Package snapm must available and be version 0.5 or later for bootable snapsets
64+
meta: end_host
65+
when:
66+
- not __snapshot_snapm_available or
67+
__snapshot_snapm_version is version("0.5", "<")
68+
- __snapshot_needs_bootable_support
69+
- not snapshot_fail_if_too_old | d(true)
6170

6271
- name: Run snapshot module and handle errors
6372
when: snapshot_lvm_action is defined

tests/tests_set_bootable.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,14 @@
4949
vg: test_vg3
5050
lv: lv7
5151
percent_space_required: 15
52+
snapshot_lvm_bootable: true
53+
snapshot_fail_if_too_old: false
5254
tasks:
5355
- name: Load test variables
5456
include_vars:
5557
file: vars/rh_distros_vars.yml
5658
when: __snapshot_is_ostree is not defined
5759

58-
- name: Run the snapshot role to define __snapshot_snapm_available
59-
include_role:
60-
name: linux-system-roles.snapshot
61-
62-
- name: Test is only supported on platforms with snapm support
63-
debug:
64-
msg: >
65-
This test is only supported on platforms with snapm support.
66-
when:
67-
- not __snapshot_snapm_available
68-
69-
- name: End test
70-
meta: end_play
71-
when:
72-
- not __snapshot_snapm_available
73-
7460
- name: Run tests
7561
block:
7662
- name: Setup
@@ -81,7 +67,6 @@
8167
name: linux-system-roles.snapshot
8268
vars:
8369
snapshot_lvm_action: snapshot
84-
snapshot_lvm_bootable: true
8570
snapshot_lvm_set: "{{ snapshot_test_set }}"
8671

8772
- name: Assert changes for create snapset

0 commit comments

Comments
 (0)