]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
validate: improve error messages when config fails validation
authorAndrew Schoen <aschoen@redhat.com>
Tue, 1 May 2018 16:21:48 +0000 (11:21 -0500)
committerGuillaume Abrioux <gabrioux@redhat.com>
Fri, 18 May 2018 15:58:24 +0000 (17:58 +0200)
Signed-off-by: Andrew Schoen <aschoen@redhat.com>
plugins/actions/validate.py

index 744901ef07e499ba6795048189b295b5fc8957fe..40ff60dc811fbd7042acee8b5821d710ba5e3ca7 100644 (file)
@@ -75,13 +75,21 @@ class ActionModule(ActionBase):
 
         except Invalid as error:
             display.vvvv("Notario Failure: %s" % str(error))
-            display.warning("[%s] Validation failed for variable: %s" % (host, error.path[0]))
-            msg = "Invalid variable assignment in host: %s\n" % host
-            msg += "    %s = %s\n" % (error.path, error.path)
-            msg += "    %s   %s\n" % (" " * len(str(error.path)), "^" * len(str(error.path)))
-            msg += "Reason: %s" % error.reason
+            msg = "[{}] Validation failed for variable: {}".format(host, error.path[0])
+            display.error(msg)
+            reason = "[{}] Reason: {}".format(host, error.reason)
+            try:
+                if "schema is missing" not in error.message:
+                    given = "[{}] Given value for {}: {}".format(host, error.path[0], error.path[1])
+                    display.error(given)
+                else:
+                    given = ""
+                    reason = "[{}] Reason: {}".format(host, error.message)
+            except KeyError:
+                given = ""
+            display.error(reason)
             result['failed'] = mode == 'strict'
-            result['msg'] = msg
+            result['msg'] = "\n".join([msg, reason, given])
             result['stderr_lines'] = msg.split('\n')
 
         return result
@@ -199,8 +207,8 @@ collocated_osd_scenario = ("devices", iterables.AllItems(types.string))
 
 non_collocated_osd_scenario = (
     (optional("bluestore_wal_devices"), iterables.AllItems(types.string)),
-    ("devices", iterables.AllItems(types.string)),
     (optional("dedicated_devices"), iterables.AllItems(types.string)),
+    ("devices", iterables.AllItems(types.string)),
 )
 
 lvm_osd_scenario = ("lvm_volumes", iterables.AllItems((