From: Benoît Knecht Date: Tue, 1 Sep 2020 11:06:57 +0000 (+0200) Subject: library: Fix new-style modules check mode X-Git-Tag: v5.0.2~28 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ab458a959252f595bdd4a96db1b4af486e9a9de4;p=ceph-ansible.git library: Fix new-style modules check mode 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) --- 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()