From 41614fd8e68c9da1d038c85185f1329dc84255da Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Wed, 7 Dec 2016 19:35:10 +0100 Subject: [PATCH] Display proper error on group_vars syntax error This fix ensures a proper error is shown when a group_vars files cannot be parsed correctly. Without this patch you get: ``` [dag@moria ansible.testing]$ ansible-playbook test132.yml ERROR! Unexpected Exception: dictionary update sequence element #0 has length 1; 2 is required to see the full traceback, use -vvv ``` With this patch you get: ``` [dag@moria ansible.testing]$ ansible-playbook test132.yml ERROR! Problem parsing file '/home/dag/home-made/ansible.testing/group_vars/test135': line 1, column 1 ``` This fixes #18843 --- lib/ansible/vars/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ansible/vars/__init__.py b/lib/ansible/vars/__init__.py index b3369af2ca..dfa3131c66 100644 --- a/lib/ansible/vars/__init__.py +++ b/lib/ansible/vars/__init__.py @@ -583,8 +583,13 @@ class VariableManager: rval = AnsibleInventoryVarsData() rval.path = path + if data is not None: - rval.update(data) + if not isinstance(data, dict): + raise AnsibleError("Problem parsing file '%s': line %d, column %d" % data.ansible_pos) + else: + rval.update(data) + return rval def add_host_vars_file(self, path, loader):