When loading the json, if invalid, we should fail with a meaningful
error.
Signed-off-by: Sébastien Han <seb@redhat.com>
# see: http://tracker.ceph.com/issues/36329
# FIXME: it's probably less confusing to check for rc
- # convert out to json, ansible return a string...
- out_dict = json.loads(out)
+ # convert out to json, ansible returns a string...
+ try:
+ out_dict = json.loads(out)
+ except ValueError:
+ fatal("Could not decode json output: {} from the command {}".format(out, cmd), module) # noqa E501
+
if out_dict:
data = module.params['data']
result['stdout'] = 'skipped, since {0} is already used for an osd'.format( # noqa E501