Selaa lähdekoodia

Merge pull request #9618 from cwilkers/patch-1

Provide better error message for json sanity check
OpenShift Merge Robot 6 vuotta sitten
vanhempi
commit
ab622119d3
1 muutettua tiedostoa jossa 3 lisäystä ja 3 poistoa
  1. 3 3
      roles/lib_utils/action_plugins/sanity_checks.py

+ 3 - 3
roles/lib_utils/action_plugins/sanity_checks.py

@@ -424,15 +424,15 @@ class ActionModule(ActionBase):
                 json_var = self.template_var(hostvars, host, var)
                 try:
                     json.loads(json_var)
-                except ValueError:
-                    found_invalid_json.append([var, json_var])
+                except ValueError as json_err:
+                    found_invalid_json.append([var, json_var, json_err])
                 except BaseException:
                     pass
 
         if found_invalid_json:
             msg = "Found invalid json format variables:\n"
             for item in found_invalid_json:
-                msg += "    {} specified in {} is invalid json format\n".format(item[1], item[0])
+                msg += "    {} specified in {} is invalid json format\n    {}".format(item[1], item[0], item[2])
             raise errors.AnsibleModuleError(msg)
         return None