Browse code

catch bad extra vars data earlier

Bad extra early (#22322)
(cherry picked from commit c71b15a696990dd4163fde087fe444f26b526e61)

Brian Coca authored on 2017/03/08 03:44:36
Showing 1 changed files
... ...
@@ -26,7 +26,7 @@ from collections import MutableMapping
26 26
 from ansible.compat.six import iteritems, string_types
27 27
 
28 28
 from ansible import constants as C
29
-from ansible.errors import AnsibleError
29
+from ansible.errors import AnsibleError, AnsibleOptionsError
30 30
 from ansible.parsing.splitter import parse_kv
31 31
 from ansible.module_utils._text import to_native, to_text
32 32
 
... ...
@@ -111,7 +111,12 @@ def load_extra_vars(loader, options):
111 111
         else:
112 112
             # Arguments as Key-value
113 113
             data = parse_kv(extra_vars_opt)
114
-        extra_vars = combine_vars(extra_vars, data)
114
+
115
+        if isinstance(data, MutableMapping):
116
+            extra_vars = combine_vars(extra_vars, data)
117
+        else:
118
+            raise AnsibleOptionsError("Invalid extra vars data supplied. '%s' could not be made into a dictionary" % extra_vars_opt)
119
+
115 120
     return extra_vars
116 121
 
117 122