From b3d79d728e587350eeb8c5022ef48d341d46781f Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 3 Dec 2023 09:49:15 +0100 Subject: [PATCH] [PR #7601/32558558 backport][stable-7] lvol: check return message in both stderr and stdout (#7673) lvol: check return message in both stderr and stdout (#7601) * lvol: check return message in both stderr and stdout * add changelog frag (cherry picked from commit 32558558c00ee6c59db3a4f7e4decbf70a19ba8c) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/7601-lvol-fix.yml | 2 ++ plugins/modules/lvol.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/7601-lvol-fix.yml diff --git a/changelogs/fragments/7601-lvol-fix.yml b/changelogs/fragments/7601-lvol-fix.yml new file mode 100644 index 0000000000..b83fe15683 --- /dev/null +++ b/changelogs/fragments/7601-lvol-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - lvol - test for output messages in both ``stdout`` and ``stderr`` (https://github.com/ansible-collections/community.general/pull/7601, https://github.com/ansible-collections/community.general/issues/7182). diff --git a/plugins/modules/lvol.py b/plugins/modules/lvol.py index 043dbb5928..8a029e7711 100644 --- a/plugins/modules/lvol.py +++ b/plugins/modules/lvol.py @@ -552,9 +552,9 @@ def main(): elif rc == 0: changed = True msg = "Volume %s resized to %s%s" % (this_lv['name'], size_requested, unit) - elif "matches existing size" in err: + elif "matches existing size" in err or "matches existing size" in out: module.exit_json(changed=False, vg=vg, lv=this_lv['name'], size=this_lv['size']) - elif "not larger than existing size" in err: + elif "not larger than existing size" in err or "not larger than existing size" in out: module.exit_json(changed=False, vg=vg, lv=this_lv['name'], size=this_lv['size'], msg="Original size is larger than requested size", err=err) else: module.fail_json(msg="Unable to resize %s to %s%s" % (lv, size, size_unit), rc=rc, err=err) @@ -585,9 +585,9 @@ def main(): module.fail_json(msg="Unable to resize %s to %s%s" % (lv, size, size_unit), rc=rc, err=err, out=out) elif rc == 0: changed = True - elif "matches existing size" in err: + elif "matches existing size" in err or "matches existing size" in out: module.exit_json(changed=False, vg=vg, lv=this_lv['name'], size=this_lv['size']) - elif "not larger than existing size" in err: + elif "not larger than existing size" in err or "not larger than existing size" in out: module.exit_json(changed=False, vg=vg, lv=this_lv['name'], size=this_lv['size'], msg="Original size is larger than requested size", err=err) else: module.fail_json(msg="Unable to resize %s to %s%s" % (lv, size, size_unit), rc=rc, err=err)