From b39b2abbf24b1aa729e4118c819fe685d83b3e87 Mon Sep 17 00:00:00 2001 From: Todd Gill Date: Fri, 2 Feb 2024 19:32:18 -0500 Subject: [PATCH] fix: remove prefix parameter and change suffix to snapset name Use snapshot_lvm_snapset_name to identify a set of snapshots. The snapset name is appended to the LV name to indicate membership in the set. Using a set name will map more easily to how snapm is being implemented. If/when we decide to back the role with snapm, it will be easier to keep the current interface if we use only a snapset name and drop the prefix. See : https://github.com/snapshotmanager/snapm/ Signed-off-by: Todd Gill --- README.md | 52 ++++---- defaults/main.yml | 3 +- examples/check_space.yml | 3 +- examples/remove_all.yml | 3 +- examples/snapshot_all.yml | 3 +- tasks/files/snapshot.py | 35 ++--- tests/tests_basic.yml | 12 +- tests/tests_check_no_lv_fail.yml | 3 +- tests/tests_check_no_vg_fail.yml | 3 +- tests/tests_default.yml | 3 +- tests/tests_extend_basic.yml | 12 +- tests/tests_include_vars_from_parent.yml | 3 +- tests/tests_multi_snapsets.yml | 156 +++++++++++++++++++++++ tests/tests_no_space_fail.yml | 3 +- tests/tests_revert_basic.yml | 12 +- tests/tests_single_lv.yml | 12 +- tests/tests_single_vg.yml | 12 +- tests/verify-role-failed.yml | 7 +- vars/main.yml | 9 +- 19 files changed, 228 insertions(+), 118 deletions(-) create mode 100644 tests/tests_multi_snapsets.yml diff --git a/README.md b/README.md index d54a0ae..5854086 100644 --- a/README.md +++ b/README.md @@ -69,15 +69,11 @@ Sets are defined in the following format: If before running the role, with : -### snapshot_lvm_prefix +### snapshot_lvm_snapset_name -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 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. +This variable is required. snapshot_lvm_snapset_name is a string that will be +appended to the name of the LV when the snapshot set is created. It will be used +to identify members of the set. If before running the role, the following LVs exist: @@ -94,29 +90,29 @@ lv1_vg3 vg3 -wi-a----- 1.00g lv3_vg3 vg3 -wi-a----- 120.00m ``` -If the prefix is set to "a_" and the suffix is set to "_z", running the role will result +If snapshot_lvm_snapset_name is set to "_snapset1", running the role will result in the following: ```text -LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert -a_home_z rhel swi-a-s--- 104.00m home 0.00 -a_root_z rhel swi-a-s--- 3.50g root 0.01 -a_swap_z rhel swi-a-s--- 400.00m swap 0.00 -home rhel owi-aos--- 1.00g -root rhel owi-aos--- 35.00g -swap rhel owi-aos--- <3.88g -a_lv1_vg1_z vg1 swi-a-s--- 104.00m lv1_vg1 0.00 -a_lv2_vg1_z vg1 swi-a-s--- 8.00m lv2_vg1 0.00 -lv1_vg1 vg1 owi-a-s--- 1.00g -lv2_vg1 vg1 owi-a-s--- 40.00m -a_lv1_vg2_z vg2 swi-a-s--- 104.00m lv1_vg2 0.00 -a_lv2_vg2_z vg2 swi-a-s--- 12.00m lv2_vg2 0.00 -lv1_vg2 vg2 owi-a-s--- 1.00g -lv2_vg2 vg2 owi-a-s--- 80.00m -a_lv1_vg3_z vg3 swi-a-s--- 104.00m lv1_vg3 0.00 -a_lv3_vg3_z vg3 swi-a-s--- 16.00m lv3_vg3 0.00 -lv1_vg3 vg3 owi-a-s--- 1.00g -lv3_vg3 vg3 owi-a-s--- 120.00m +LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert +home_snapset1 rhel swi-a-s--- 104.00m home 0.00 +root_snapset1 rhel swi-a-s--- 3.50g root 0.01 +swap_snapset1 rhel swi-a-s--- 400.00m swap 0.00 +home rhel owi-aos--- 1.00g +root rhel owi-aos--- 35.00g +swap rhel owi-aos--- <3.88g +lv1_vg1_snapset1 vg1 swi-a-s--- 104.00m lv1_vg1 0.00 +lv2_vg1_snapset1 vg1 swi-a-s--- 8.00m lv2_vg1 0.00 +lv1_vg1 vg1 owi-a-s--- 1.00g +lv2_vg1 vg1 owi-a-s--- 40.00m +lv1_vg2_snapset1 vg2 swi-a-s--- 104.00m lv1_vg2 0.00 +lv2_vg2_snapset1 vg2 swi-a-s--- 12.00m lv2_vg2 0.00 +lv1_vg2 vg2 owi-a-s--- 1.00g +lv2_vg2 vg2 owi-a-s--- 80.00m +lv1_vg3_snapset1 vg3 swi-a-s--- 104.00m lv1_vg3 0.00 +lv3_vg3_snapset1 vg3 swi-a-s--- 16.00m lv3_vg3 0.00 +lv1_vg3 vg3 owi-a-s--- 1.00g +lv3_vg3 vg3 owi-a-s--- 120.00m ``` ### snapshot_lvm_percent_space_required diff --git a/defaults/main.yml b/defaults/main.yml index a21704c..9f00763 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,7 +7,6 @@ snapshot_lvm_all_vgs: false snapshot_lvm_verify_only: false snapshot_lvm_vg: '' snapshot_lvm_lv: '' -snapshot_lvm_prefix: '' -snapshot_lvm_suffix: '' +snapshot_lvm_snapset_name: '' snapshot_lvm_percent_space_required: '' snapshot_lvm_set: '' diff --git a/examples/check_space.yml b/examples/check_space.yml index de371f0..c745441 100644 --- a/examples/check_space.yml +++ b/examples/check_space.yml @@ -4,8 +4,7 @@ hosts: all vars: snapshot_lvm_action: check - snapshot_lvm_prefix: a_ - snapshot_lvm_suffix: _z + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_percent_space_required: 20 snapshot_lvm_all_vgs: true roles: diff --git a/examples/remove_all.yml b/examples/remove_all.yml index 5210310..5669f26 100644 --- a/examples/remove_all.yml +++ b/examples/remove_all.yml @@ -4,8 +4,7 @@ hosts: all vars: snapshot_lvm_action: remove - snapshot_lvm_prefix: a_ - snapshot_lvm_suffix: _z + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_all_vgs: true roles: - linux-system-roles.snapshot diff --git a/examples/snapshot_all.yml b/examples/snapshot_all.yml index f2b50f7..58cd678 100644 --- a/examples/snapshot_all.yml +++ b/examples/snapshot_all.yml @@ -4,8 +4,7 @@ hosts: all vars: snapshot_lvm_action: snapshot - snapshot_lvm_prefix: a_ - snapshot_lvm_suffix: _z + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_percent_space_required: 20 snapshot_lvm_all_vgs: true roles: diff --git a/tasks/files/snapshot.py b/tasks/files/snapshot.py index 5403df3..4e2c562 100644 --- a/tasks/files/snapshot.py +++ b/tasks/files/snapshot.py @@ -213,7 +213,7 @@ def get_snapshot_name(lv_name, prefix, suffix): else: suffix_str = "" - return prefix_str + lv_name + suffix_str + return prefix_str + lv_name + "_" + suffix_str def lvm_lv_exists(vg_name, lv_name): @@ -493,7 +493,7 @@ def extend_snapshot_set(snapset_json): percent_space_required = list_item["percent_space_required"] rc, message = extend_lv_snapshot( - vg, lv, None, get_snapset_suffix(snapset_name), percent_space_required + vg, lv, None, snapset_name, percent_space_required ) if rc != SnapshotStatus.SNAPSHOT_OK: @@ -513,7 +513,7 @@ def extend_verify_snapshot_set(snapset_json): lv = list_item["lv"] percent_space_required = list_item["percent_space_required"] - snapshot_name = get_snapshot_name(lv, None, get_snapset_suffix(snapset_name)) + snapshot_name = get_snapshot_name(lv, None, snapset_name) rc, _vg_exists, lv_exists = lvm_lv_exists(vg, snapshot_name) if rc != SnapshotStatus.SNAPSHOT_OK: @@ -815,7 +815,7 @@ def check_verify_lvs_set(snapset_json): vg = list_item["vg"] lv = list_item["lv"] - snapshot_name = get_snapshot_name(lv, None, get_snapset_suffix(snapset_name)) + snapshot_name = get_snapshot_name(lv, None, snapset_name) rc, _vg_exists, lv_exists = lvm_lv_exists(vg, snapshot_name) if rc != SnapshotStatus.SNAPSHOT_OK: @@ -933,7 +933,8 @@ def revert_snapshot_set(snapset_json): vg = list_item["vg"] lv = list_item["lv"] - rc, message = revert_lv(vg, lv, None, get_snapset_suffix(snapset_name)) + rc, message = revert_lv( + vg, lv, None, get_snapshot_name(lv, None, snapset_name)) if rc != SnapshotStatus.SNAPSHOT_OK: return rc, message @@ -950,7 +951,7 @@ def remove_snapshot_set(snapset_json): for list_item in volume_list: vg = list_item["vg"] lv = list_item["lv"] - snapshot_name = get_snapshot_name(lv, None, get_snapset_suffix(snapset_name)) + snapshot_name = get_snapshot_name(lv, None, snapset_name) rc, vg_exists, lv_exists = lvm_lv_exists(vg, snapshot_name) @@ -973,7 +974,7 @@ def remove_snapshot_set(snapset_json): vg = list_item["vg"] lv = list_item["lv"] - snapshot_name = get_snapshot_name(lv, None, get_snapset_suffix(snapset_name)) + snapshot_name = get_snapshot_name(lv, None, snapset_name) rc, vg_exists, lv_exists = lvm_lv_exists(vg, snapshot_name) if rc != SnapshotStatus.SNAPSHOT_OK: @@ -1001,7 +1002,7 @@ def remove_verify_snapshot_set(snapset_json): vg = list_item["vg"] lv = list_item["lv"] - snapshot_name = get_snapshot_name(lv, None, get_snapset_suffix(snapset_name)) + snapshot_name = get_snapshot_name(lv, None, snapset_name) rc, _vg_exists, lv_exists = lvm_lv_exists(vg, snapshot_name) if rc != SnapshotStatus.SNAPSHOT_OK: @@ -1211,7 +1212,7 @@ def verify_snapset_target_no_existing(snapset_json): vg = list_item["vg"] lv = list_item["lv"] - snapshot_name = get_snapshot_name(lv, None, get_snapset_suffix(snapset_name)) + snapshot_name = get_snapshot_name(lv, None, snapset_name) rc, _vg_exists, lv_exists = lvm_lv_exists(vg, snapshot_name) if rc != SnapshotStatus.SNAPSHOT_OK: @@ -1259,10 +1260,6 @@ def verify_snapset_source_lvs_exist(snapset_json): return SnapshotStatus.SNAPSHOT_OK, "" -def get_snapset_suffix(snapset_name): - return "_" + snapset_name - - def verify_snapset_names(snapset_json): snapset_name = snapset_json["name"] volume_list = snapset_json["volumes"] @@ -1270,9 +1267,7 @@ def verify_snapset_names(snapset_json): for list_item in volume_list: lv = list_item["lv"] - rc, message = check_name_for_snapshot( - lv, None, get_snapset_suffix(snapset_name) - ) + rc, message = check_name_for_snapshot(lv, None, snapset_name) if rc != SnapshotStatus.SNAPSHOT_OK: return rc, message @@ -1379,9 +1374,7 @@ def snapshot_create_set(snapset_json): vg, lv, percent_space_required, current_space_dict ) - rc, message = snapshot_lv( - vg, lv, None, get_snapset_suffix(snapset_name), required_size - ) + rc, message = snapshot_lv(vg, lv, None, snapset_name, required_size) if rc != SnapshotStatus.SNAPSHOT_OK: return rc, message @@ -1861,10 +1854,10 @@ def extend_cmd(args): ) common_parser.add_argument( "-s", - "--suffix", + "--snapset", dest="suffix", type=str, - help="suffix to add to volume name for snapshot", + help="name for snapshot set", ) common_parser.add_argument( "-p", diff --git a/tests/tests_basic.yml b/tests/tests_basic.yml index 8306c29..c109016 100644 --- a/tests/tests_basic.yml +++ b/tests/tests_basic.yml @@ -60,8 +60,7 @@ vars: snapshot_lvm_percent_space_required: 15 snapshot_lvm_all_vgs: true - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_action: snapshot - name: Verify the snapshot LVs are created @@ -69,8 +68,7 @@ name: linux-system-roles.snapshot vars: snapshot_lvm_all_vgs: true - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_verify_only: true snapshot_lvm_action: check @@ -78,16 +76,14 @@ include_role: name: linux-system-roles.snapshot vars: - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_action: remove - name: Use the snapshot_lvm_verify option to make sure remove is done include_role: name: linux-system-roles.snapshot vars: - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_verify_only: true snapshot_lvm_action: remove always: diff --git a/tests/tests_check_no_lv_fail.yml b/tests/tests_check_no_lv_fail.yml index a3e21dd..e170210 100644 --- a/tests/tests_check_no_lv_fail.yml +++ b/tests/tests_check_no_lv_fail.yml @@ -39,8 +39,7 @@ __snapshot_failed_params: snapshot_lvm_vg: test_vg1 snapshot_lvm_lv: xxxxx - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_verify_only: true snapshot_lvm_action: check always: diff --git a/tests/tests_check_no_vg_fail.yml b/tests/tests_check_no_vg_fail.yml index cd8cf5f..b807513 100644 --- a/tests/tests_check_no_vg_fail.yml +++ b/tests/tests_check_no_vg_fail.yml @@ -37,8 +37,7 @@ __snapshot_failed_msg: Role check did not fail with wrong VG __snapshot_failed_params: snapshot_lvm_vg: xxxxxx - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_verify_only: true snapshot_lvm_action: check always: diff --git a/tests/tests_default.yml b/tests/tests_default.yml index 21942d6..bb3a557 100644 --- a/tests/tests_default.yml +++ b/tests/tests_default.yml @@ -6,8 +6,7 @@ vars: snapshot_lvm_action: check snapshot_lvm_percent_space_required: 2 - snapshot_lvm_prefix: a_ - snapshot_lvm_suffix: _z + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_all_vgs: true roles: - linux-system-roles.snapshot diff --git a/tests/tests_extend_basic.yml b/tests/tests_extend_basic.yml index 5bc481f..e3f2e9c 100644 --- a/tests/tests_extend_basic.yml +++ b/tests/tests_extend_basic.yml @@ -60,8 +60,7 @@ vars: snapshot_lvm_percent_space_required: 15 snapshot_lvm_all_vgs: true - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_action: snapshot - name: Verify the snapshot LVs are created @@ -69,8 +68,7 @@ name: linux-system-roles.snapshot vars: snapshot_lvm_all_vgs: true - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_verify_only: true snapshot_lvm_action: check @@ -80,8 +78,7 @@ vars: snapshot_lvm_percent_space_required: 40 snapshot_lvm_all_vgs: true - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_action: extend - name: Use the snapshot_lvm_verify option to make sure extend is done @@ -90,8 +87,7 @@ vars: snapshot_lvm_percent_space_required: 40 snapshot_lvm_all_vgs: true - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_verify_only: true snapshot_lvm_action: extend always: diff --git a/tests/tests_include_vars_from_parent.yml b/tests/tests_include_vars_from_parent.yml index c034f98..3e9a68e 100644 --- a/tests/tests_include_vars_from_parent.yml +++ b/tests/tests_include_vars_from_parent.yml @@ -5,8 +5,7 @@ vars: snapshot_lvm_action: check snapshot_lvm_percent_space_required: 2 - snapshot_lvm_prefix: a_ - snapshot_lvm_suffix: _z + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_all_vgs: true tasks: - name: Run test in a block to clean up in always diff --git a/tests/tests_multi_snapsets.yml b/tests/tests_multi_snapsets.yml new file mode 100644 index 0000000..9962916 --- /dev/null +++ b/tests/tests_multi_snapsets.yml @@ -0,0 +1,156 @@ +--- +- name: Basic snapshot test + hosts: all + tasks: + - name: Run tests + block: + - name: Run the storage role to create test LVs + include_role: + name: fedora.linux_system_roles.storage + + - name: Get unused disks + include_tasks: get_unused_disk.yml + vars: + min_size: "1g" + min_return: 10 + + - name: Set disk lists + set_fact: + disk_list_1: "{{ range(0, 3) | map('extract', unused_disks) | + list }}" + disk_list_2: "{{ range(3, 6) | map('extract', unused_disks) | + list }}" + disk_list_3: "{{ range(6, 10) | map('extract', unused_disks) | + list }}" + + - name: Create LVM logical volumes under volume groups + include_role: + name: fedora.linux_system_roles.storage + vars: + storage_pools: + - name: test_vg1 + disks: "{{ disk_list_1 }}" + volumes: + - name: lv1 + size: "15%" + - name: lv2 + size: "50%" + - name: test_vg2 + disks: "{{ disk_list_2 }}" + volumes: + - name: lv3 + size: "10%" + - name: lv4 + size: "20%" + - name: test_vg3 + disks: "{{ disk_list_3 }}" + volumes: + - name: lv5 + size: "30%" + - name: lv6 + size: "25%" + - name: lv7 + size: "10%" + - name: lv8 + size: "10%" + + - name: Run the snapshot role to create snapshot LVs for snapset1 + include_role: + name: linux-system-roles.snapshot + vars: + snapshot_lvm_percent_space_required: 15 + snapshot_lvm_vg: test_vg1 + snapshot_lvm_snapset_name: snapset1 + snapshot_lvm_action: snapshot + + - name: Verify the snapshot LVs are createdf or snapset1 + include_role: + name: linux-system-roles.snapshot + vars: + snapshot_lvm_vg: test_vg1 + snapshot_lvm_snapset_name: snapset1 + snapshot_lvm_verify_only: true + snapshot_lvm_action: check + + - name: Run the snapshot role to create snapshot LVs for snapset2 + include_role: + name: linux-system-roles.snapshot + vars: + snapshot_lvm_percent_space_required: 15 + snapshot_lvm_vg: test_vg2 + snapshot_lvm_snapset_name: snapset2 + snapshot_lvm_action: snapshot + + - name: Verify the snapshot LVs are createdf or snapset2 + include_role: + name: linux-system-roles.snapshot + vars: + snapshot_lvm_vg: test_vg2 + snapshot_lvm_snapset_name: snapset2 + snapshot_lvm_verify_only: true + snapshot_lvm_action: check + + - name: Run the snapshot role remove the snapshot LVs for snapset1 + include_role: + name: linux-system-roles.snapshot + vars: + snapshot_lvm_snapset_name: snapset1 + snapshot_lvm_action: remove + + - name: Use the snapshot_lvm_verify option to make sure remove is done + include_role: + name: linux-system-roles.snapshot + vars: + snapshot_lvm_snapset_name: snapset1 + snapshot_lvm_verify_only: true + snapshot_lvm_action: remove + + - name: Run the snapshot role remove the snapshot LVs for snapset2 + include_role: + name: linux-system-roles.snapshot + vars: + snapshot_lvm_snapset_name: snapset2 + snapshot_lvm_action: remove + + - name: Use the snapshot_lvm_verify option to make sure remove is done + include_role: + name: linux-system-roles.snapshot + vars: + snapshot_lvm_snapset_name: snapset2 + snapshot_lvm_verify_only: true + snapshot_lvm_action: remove + always: + - name: Remove storage volumes + include_role: + name: fedora.linux_system_roles.storage + vars: + storage_safe_mode: false + storage_pools: + - name: test_vg1 + disks: "{{ disk_list_1 }}" + state: absent + volumes: + - name: lv1 + state: absent + - name: lv2 + state: absent + - name: test_vg2 + disks: "{{ disk_list_2 }}" + state: absent + volumes: + - name: lv3 + state: absent + - name: lv4 + state: absent + - name: test_vg3 + disks: "{{ disk_list_3 }}" + state: absent + volumes: + - name: lv5 + state: absent + - name: lv6 + state: absent + - name: lv7 + state: absent + - name: lv8 + state: absent diff --git a/tests/tests_no_space_fail.yml b/tests/tests_no_space_fail.yml index 5cd581d..e36c654 100644 --- a/tests/tests_no_space_fail.yml +++ b/tests/tests_no_space_fail.yml @@ -38,8 +38,7 @@ __snapshot_failed_params: snapshot_lvm_percent_space_required: 15 snapshot_all: true - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_action: snapshot always: - name: Remove storage volumes diff --git a/tests/tests_revert_basic.yml b/tests/tests_revert_basic.yml index 7e98a9b..faf8643 100644 --- a/tests/tests_revert_basic.yml +++ b/tests/tests_revert_basic.yml @@ -60,8 +60,7 @@ vars: snapshot_lvm_percent_space_required: 15 snapshot_lvm_all_vgs: true - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_action: snapshot - name: Verify the snapshot LVs are created @@ -69,8 +68,7 @@ name: linux-system-roles.snapshot vars: snapshot_lvm_all_vgs: true - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_verify_only: true snapshot_lvm_action: check @@ -79,8 +77,7 @@ name: linux-system-roles.snapshot vars: snapshot_lvm_all_vgs: true - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_action: revert - name: Use the snapshot_lvm_verify option to make sure revert is done @@ -88,8 +85,7 @@ name: linux-system-roles.snapshot vars: snapshot_lvm_all_vgs: true - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_verify_only: true snapshot_lvm_action: revert always: diff --git a/tests/tests_single_lv.yml b/tests/tests_single_lv.yml index ea2c108..d140de2 100644 --- a/tests/tests_single_lv.yml +++ b/tests/tests_single_lv.yml @@ -59,8 +59,7 @@ name: linux-system-roles.snapshot vars: snapshot_lvm_percent_space_required: 15 - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_vg: test_vg1 snapshot_lvm_lv: lv1 snapshot_lvm_action: snapshot @@ -69,8 +68,7 @@ include_role: name: linux-system-roles.snapshot vars: - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_vg: test_vg1 snapshot_lvm_lv: lv1 snapshot_lvm_verify_only: true @@ -80,8 +78,7 @@ include_role: name: linux-system-roles.snapshot vars: - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_vg: test_vg1 snapshot_lvm_lv: lv1 snapshot_lvm_action: remove @@ -91,8 +88,7 @@ include_role: name: linux-system-roles.snapshot vars: - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_verify_only: true snapshot_lvm_vg: test_vg1 snapshot_lvm_lv: lv1 diff --git a/tests/tests_single_vg.yml b/tests/tests_single_vg.yml index 835e494..245188c 100644 --- a/tests/tests_single_vg.yml +++ b/tests/tests_single_vg.yml @@ -59,8 +59,7 @@ name: linux-system-roles.snapshot vars: snapshot_lvm_percent_space_required: 15 - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_vg: test_vg2 snapshot_lvm_action: snapshot @@ -68,8 +67,7 @@ include_role: name: linux-system-roles.snapshot vars: - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_vg: test_vg2 snapshot_lvm_verify_only: true snapshot_lvm_action: check @@ -78,8 +76,7 @@ include_role: name: linux-system-roles.snapshot vars: - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_vg: test_vg1 snapshot_lvm_action: remove @@ -88,8 +85,7 @@ include_role: name: linux-system-roles.snapshot vars: - snapshot_lvm_suffix: _z - snapshot_lvm_prefix: a_ + snapshot_lvm_snapset_name: snapset1 snapshot_lvm_verify_only: true snapshot_lvm_vg: test_vg1 snapshot_lvm_action: remove diff --git a/tests/verify-role-failed.yml b/tests/verify-role-failed.yml index cc581b3..c772c9c 100644 --- a/tests/verify-role-failed.yml +++ b/tests/verify-role-failed.yml @@ -16,11 +16,8 @@ snapshot_lvm_all_vgs: "{{ __snapshot_failed_params.get('snapshot_all') }}" - snapshot_lvm_suffix: "{{ - __snapshot_failed_params.get('snapshot_lvm_suffix') - }}" - snapshot_lvm_prefix: "{{ - __snapshot_failed_params.get('snapshot_lvm_prefix') + snapshot_lvm_snapset_name: "{{ + __snapshot_failed_params.get('snapshot_lvm_snapset_name') }}" snapshot_lvm_action: "{{ __snapshot_failed_params.get('snapshot_lvm_action') diff --git a/vars/main.yml b/vars/main.yml index d6e3d5d..f88b54a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -23,18 +23,15 @@ __snapshot_cmd: "{{ 'snapshot.py ' ~ snapshot_lvm_action ~ ' ' ~ ('-r ' if snapshot_lvm_percent_space_required else '') ~ ' ' ~ (snapshot_lvm_percent_space_required | quote if snapshot_lvm_percent_space_required else '') ~ ' ' ~ - ('-p ' if snapshot_lvm_prefix else '') ~ ' ' ~ - (snapshot_lvm_prefix | quote - if snapshot_lvm_prefix else '') ~ ' ' ~ ('-vg ' if snapshot_lvm_vg else '') ~ ' ' ~ (snapshot_lvm_vg | quote if snapshot_lvm_vg else '') ~ ' ' ~ ('-lv ' if snapshot_lvm_lv else '') ~ ' ' ~ (snapshot_lvm_lv | quote if snapshot_lvm_lv else '') ~ ' ' ~ - ('-s ' if snapshot_lvm_suffix else '') ~ ' ' ~ - (snapshot_lvm_suffix | quote - if snapshot_lvm_suffix else '') ~ ' ' ~ + ('-s ' if snapshot_lvm_snapset_name else '') ~ ' ' ~ + (snapshot_lvm_snapset_name | quote + if snapshot_lvm_snapset_name else '') ~ ' ' ~ ('-g ' if snapshot_lvm_set else '') ~ ' ' ~ (snapshot_lvm_set | to_json | quote if snapshot_lvm_set else '') }}"