mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
lvol: Fix pct of origin (#7053)
* add support for percentage of origin size for creating snapshot volumes * add changelog fragment * add pull request link Co-authored-by: Felix Fontein <felix@fontein.de> * fix what's not idempotent --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
5988b9acea
commit
a0c67a8894
5 changed files with 28 additions and 16 deletions
2
changelogs/fragments/lvol-pct-of-origin.yml
Normal file
2
changelogs/fragments/lvol-pct-of-origin.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- lvol - add support for percentage of origin size specification when creating snapshot volumes (https://github.com/ansible-collections/community.general/issues/1630, https://github.com/ansible-collections/community.general/pull/7053).
|
|
@ -41,13 +41,13 @@ options:
|
||||||
description:
|
description:
|
||||||
- The size of the logical volume, according to lvcreate(8) --size, by
|
- The size of the logical volume, according to lvcreate(8) --size, by
|
||||||
default in megabytes or optionally with one of [bBsSkKmMgGtTpPeE] units; or
|
default in megabytes or optionally with one of [bBsSkKmMgGtTpPeE] units; or
|
||||||
according to lvcreate(8) --extents as a percentage of [VG|PVS|FREE];
|
according to lvcreate(8) --extents as a percentage of [VG|PVS|FREE|ORIGIN];
|
||||||
Float values must begin with a digit.
|
Float values must begin with a digit.
|
||||||
- When resizing, apart from specifying an absolute size you may, according to
|
- When resizing, apart from specifying an absolute size you may, according to
|
||||||
lvextend(8)|lvreduce(8) C(--size), specify the amount to extend the logical volume with
|
lvextend(8)|lvreduce(8) C(--size), specify the amount to extend the logical volume with
|
||||||
the prefix V(+) or the amount to reduce the logical volume by with prefix V(-).
|
the prefix V(+) or the amount to reduce the logical volume by with prefix V(-).
|
||||||
- Resizing using V(+) or V(-) was not supported prior to community.general 3.0.0.
|
- Resizing using V(+) or V(-) was not supported prior to community.general 3.0.0.
|
||||||
- Please note that when using V(+) or V(-), the module is B(not idempotent).
|
- Please note that when using V(+), V(-), or percentage of FREE, the module is B(not idempotent).
|
||||||
state:
|
state:
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
|
@ -73,7 +73,7 @@ options:
|
||||||
snapshot:
|
snapshot:
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
- The name of the snapshot volume
|
- The name of a snapshot volume to be configured. When creating a snapshot volume, the O(lv) parameter specifies the origin volume.
|
||||||
pvs:
|
pvs:
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
|
@ -368,10 +368,10 @@ def main():
|
||||||
if size_percent > 100:
|
if size_percent > 100:
|
||||||
module.fail_json(msg="Size percentage cannot be larger than 100%")
|
module.fail_json(msg="Size percentage cannot be larger than 100%")
|
||||||
size_whole = size_parts[1]
|
size_whole = size_parts[1]
|
||||||
if size_whole == 'ORIGIN':
|
if size_whole == 'ORIGIN' and snapshot is None:
|
||||||
module.fail_json(msg="Snapshot Volumes are not supported")
|
module.fail_json(msg="Percentage of ORIGIN supported only for snapshot volumes")
|
||||||
elif size_whole not in ['VG', 'PVS', 'FREE']:
|
elif size_whole not in ['VG', 'PVS', 'FREE', 'ORIGIN']:
|
||||||
module.fail_json(msg="Specify extents as a percentage of VG|PVS|FREE")
|
module.fail_json(msg="Specify extents as a percentage of VG|PVS|FREE|ORIGIN")
|
||||||
size_opt = 'l'
|
size_opt = 'l'
|
||||||
size_unit = ''
|
size_unit = ''
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
- name: "Create files to use as a disk devices"
|
- name: "Create files to use as a disk devices"
|
||||||
command: "dd if=/dev/zero of={{ remote_tmp_dir }}/img{{ item }} bs=1M count=10"
|
command: "dd if=/dev/zero of={{ remote_tmp_dir }}/img{{ item }} bs=1M count=36"
|
||||||
with_sequence: 'count=4'
|
with_sequence: 'count=4'
|
||||||
|
|
||||||
- name: "Show next free loop device"
|
- name: "Show next free loop device"
|
||||||
|
|
|
@ -17,6 +17,16 @@
|
||||||
lv: "{{ item }}"
|
lv: "{{ item }}"
|
||||||
size: 2m
|
size: 2m
|
||||||
|
|
||||||
|
- name: Create snapshot volumes of origin logical volumes
|
||||||
|
loop:
|
||||||
|
- lv1
|
||||||
|
- lv2
|
||||||
|
lvol:
|
||||||
|
vg: testvg
|
||||||
|
lv: "{{ item }}"
|
||||||
|
snapshot: "{{ item }}_snap"
|
||||||
|
size: 50%ORIGIN
|
||||||
|
|
||||||
- name: Collect all lv active status in testvg
|
- name: Collect all lv active status in testvg
|
||||||
shell: vgs -olv_active --noheadings testvg | xargs -n1
|
shell: vgs -olv_active --noheadings testvg | xargs -n1
|
||||||
register: initial_lv_status_result
|
register: initial_lv_status_result
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
shell: vgs -v testvg -o pv_size --noheading --units b | xargs
|
shell: vgs -v testvg -o pv_size --noheading --units b | xargs
|
||||||
register: cmd_result
|
register: cmd_result
|
||||||
|
|
||||||
- name: Assert the testvg size is 8388608B
|
- name: Assert the testvg size is 33554432B
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'8388608B' == cmd_result.stdout"
|
- "'33554432B' == cmd_result.stdout"
|
||||||
|
|
||||||
- name: Increases size in file
|
- name: Increases size in file
|
||||||
command: "dd if=/dev/zero bs=8MiB count=1 of={{ remote_tmp_dir }}/img1 conv=notrunc oflag=append"
|
command: "dd if=/dev/zero bs=8MiB count=1 of={{ remote_tmp_dir }}/img1 conv=notrunc oflag=append"
|
||||||
|
@ -38,10 +38,10 @@
|
||||||
shell: vgs -v testvg -o pv_size --noheading --units b | xargs
|
shell: vgs -v testvg -o pv_size --noheading --units b | xargs
|
||||||
register: cmd_result
|
register: cmd_result
|
||||||
|
|
||||||
- name: Assert the testvg size is still 8388608B
|
- name: Assert the testvg size is still 33554432B
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'8388608B' == cmd_result.stdout"
|
- "'33554432B' == cmd_result.stdout"
|
||||||
|
|
||||||
- name: "Reruns lvg with pvresize:yes and check_mode:yes"
|
- name: "Reruns lvg with pvresize:yes and check_mode:yes"
|
||||||
lvg:
|
lvg:
|
||||||
|
@ -60,10 +60,10 @@
|
||||||
shell: vgs -v testvg -o pv_size --noheading --units b | xargs
|
shell: vgs -v testvg -o pv_size --noheading --units b | xargs
|
||||||
register: cmd_result
|
register: cmd_result
|
||||||
|
|
||||||
- name: Assert the testvg size is still 8388608B
|
- name: Assert the testvg size is still 33554432B
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'8388608B' == cmd_result.stdout"
|
- "'33554432B' == cmd_result.stdout"
|
||||||
|
|
||||||
- name: "Reruns lvg with pvresize:yes"
|
- name: "Reruns lvg with pvresize:yes"
|
||||||
lvg:
|
lvg:
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
shell: vgs -v testvg -o pv_size --noheading --units b | xargs
|
shell: vgs -v testvg -o pv_size --noheading --units b | xargs
|
||||||
register: cmd_result
|
register: cmd_result
|
||||||
|
|
||||||
- name: Assert the testvg size is now 16777216B
|
- name: Assert the testvg size is now 41943040B
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'16777216B' == cmd_result.stdout"
|
- "'41943040B' == cmd_result.stdout"
|
||||||
|
|
Loading…
Reference in a new issue