]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
library: Fix new-style modules check mode
authorBenoît Knecht <bknecht@protonmail.ch>
Tue, 1 Sep 2020 11:06:57 +0000 (13:06 +0200)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Tue, 1 Dec 2020 14:53:26 +0000 (09:53 -0500)
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 <bknecht@protonmail.ch>
(cherry picked from commit 85dd4058145436e86a12ad9f015f5228189437d5)

library/ceph_crush.py
library/ceph_key.py
library/ceph_volume.py

index 7891b666aa085d88649904c6d55fc39d43db0b42..6ada0b45985e2a966ed8c9b46c6d4e5b39fb2a09 100644 (file)
@@ -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()
 
index 59318fa8d446d209377406b56ffad25ed44e5c13..d2347698fad4dd16c2636fe50babafe646812ad5 100644 (file)
@@ -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
index 2e0d794ce4b7bd87ced467c71cc5ba430509e535..f21241fcfc01705e40beb7a7908d8f51ddef7f33 100644 (file)
@@ -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()