From 63aa1950d93f150362e41f5989d3a464ad73ce4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Knecht?= Date: Tue, 1 Sep 2020 13:06:57 +0200 Subject: [PATCH] library: Fix new-style modules check mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Running the `ceph_crush.py`, `ceph_key.py` or `ceph_volume.py` modules in check mode resulted in the following error: ``` New-style module did not handle its own exit ``` This was due to the fact that they simply returned a `dict` in that case, instead of calling `module.exit_json()`. Signed-off-by: BenoƮt Knecht (cherry picked from commit 85dd4058145436e86a12ad9f015f5228189437d5) --- library/ceph_crush.py | 4 ++-- library/ceph_key.py | 5 +++-- library/ceph_volume.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/library/ceph_crush.py b/library/ceph_crush.py index 7891b666a..6ada0b459 100644 --- a/library/ceph_crush.py +++ b/library/ceph_crush.py @@ -166,14 +166,14 @@ def run_module(): changed=False, stdout='', stderr='', - rc='', + rc=0, start='', end='', delta='', ) if module.check_mode: - return result + module.exit_json(**result) startd = datetime.datetime.now() diff --git a/library/ceph_key.py b/library/ceph_key.py index 59318fa8d..d2347698f 100644 --- a/library/ceph_key.py +++ b/library/ceph_key.py @@ -530,14 +530,15 @@ def run_module(): changed=changed, stdout='', stderr='', - rc='', + rc=0, start='', end='', delta='', ) if module.check_mode: - return result + module.exit_json(**result) + startd = datetime.datetime.now() # will return either the image name or None diff --git a/library/ceph_volume.py b/library/ceph_volume.py index 2e0d794ce..f21241fcf 100644 --- a/library/ceph_volume.py +++ b/library/ceph_volume.py @@ -566,14 +566,14 @@ def run_module(): changed=False, stdout='', stderr='', - rc='', + rc=0, start='', end='', delta='', ) if module.check_mode: - return result + module.exit_json(**result) # start execution startd = datetime.datetime.now()