From 85dd4058145436e86a12ad9f015f5228189437d5 Mon Sep 17 00:00:00 2001 From: =?utf8?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=utf8 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 --- library/ceph_crush.py | 4 ++-- library/ceph_key.py | 5 +++-- library/ceph_pool.py | 5 ++--- library/ceph_volume.py | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/library/ceph_crush.py b/library/ceph_crush.py index f9e90d685..e9b500c98 100644 --- a/library/ceph_crush.py +++ b/library/ceph_crush.py @@ -169,14 +169,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 e54b0df7f..5b57c2634 100644 --- a/library/ceph_key.py +++ b/library/ceph_key.py @@ -528,14 +528,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_pool.py b/library/ceph_pool.py index 8da6b2a98..70a0bd20a 100644 --- a/library/ceph_pool.py +++ b/library/ceph_pool.py @@ -526,11 +526,11 @@ def run_module(): } if module.check_mode: - return dict( + module.exit_json( changed=False, stdout='', stderr='', - rc='', + rc=0, start='', end='', delta='', @@ -614,4 +614,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/library/ceph_volume.py b/library/ceph_volume.py index 55faac003..2e8e50d49 100644 --- a/library/ceph_volume.py +++ b/library/ceph_volume.py @@ -574,14 +574,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() -- 2.39.5