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 <bknecht@protonmail.ch>
(cherry picked from commit 85dd405814)
4.2rc
Benoît Knecht 2020-09-01 13:06:57 +02:00 committed by Dimitri Savineau
parent 71f98531a9
commit 63aa1950d9
3 changed files with 7 additions and 6 deletions

View File

@ -166,14 +166,14 @@ def run_module():
changed=False, changed=False,
stdout='', stdout='',
stderr='', stderr='',
rc='', rc=0,
start='', start='',
end='', end='',
delta='', delta='',
) )
if module.check_mode: if module.check_mode:
return result module.exit_json(**result)
startd = datetime.datetime.now() startd = datetime.datetime.now()

View File

@ -530,14 +530,15 @@ def run_module():
changed=changed, changed=changed,
stdout='', stdout='',
stderr='', stderr='',
rc='', rc=0,
start='', start='',
end='', end='',
delta='', delta='',
) )
if module.check_mode: if module.check_mode:
return result module.exit_json(**result)
startd = datetime.datetime.now() startd = datetime.datetime.now()
# will return either the image name or None # will return either the image name or None

View File

@ -566,14 +566,14 @@ def run_module():
changed=False, changed=False,
stdout='', stdout='',
stderr='', stderr='',
rc='', rc=0,
start='', start='',
end='', end='',
delta='', delta='',
) )
if module.check_mode: if module.check_mode:
return result module.exit_json(**result)
# start execution # start execution
startd = datetime.datetime.now() startd = datetime.datetime.now()