From 227f6e333ec0fe9f4b018799be5bd0f1f1e63631 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 13 Nov 2021 15:27:35 +0100 Subject: [PATCH] Rework safety check on size arguments for when LV doesn't exist (#3681) (#3720) * Rework safety check on size arguments for when LV doesn't exist * Update changelogs/fragments/3681-lvol-fix-create.yml Co-authored-by: Felix Fontein Co-authored-by: Jake Reynolds Co-authored-by: Felix Fontein (cherry picked from commit 352047314b7de0b410b6131e89f90b7aaaaaf142) Co-authored-by: jake2184 --- changelogs/fragments/3681-lvol-fix-create.yml | 2 ++ plugins/modules/system/lvol.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/3681-lvol-fix-create.yml diff --git a/changelogs/fragments/3681-lvol-fix-create.yml b/changelogs/fragments/3681-lvol-fix-create.yml new file mode 100644 index 0000000000..d04ec5460b --- /dev/null +++ b/changelogs/fragments/3681-lvol-fix-create.yml @@ -0,0 +1,2 @@ +bugfixes: + - lvol - allows logical volumes to be created with certain size arguments prefixed with ``+`` to preserve behavior of older versions of this module (https://github.com/ansible-collections/community.general/issues/3665). diff --git a/plugins/modules/system/lvol.py b/plugins/modules/system/lvol.py index e8b0ab838b..b1b9dcb739 100644 --- a/plugins/modules/system/lvol.py +++ b/plugins/modules/system/lvol.py @@ -451,7 +451,8 @@ def main(): if this_lv is None: if state == 'present': if size_operator is not None: - module.fail_json(msg="Bad size specification of '%s%s' for creating LV" % (size_operator, size)) + if size_operator == "-" or (size_whole not in ["VG", "PVS", "FREE", "ORIGIN", None]): + module.fail_json(msg="Bad size specification of '%s%s' for creating LV" % (size_operator, size)) # Require size argument except for snapshot of thin volumes if (lv or thinpool) and not size: for test_lv in lvs: