improve error on invalid vars file (if its a list instead of a dict)

This commit is contained in:
Michael Vogt 2013-12-12 09:23:51 +01:00
parent 85d8587cc0
commit bef5ee2c3b

View file

@ -188,6 +188,8 @@ class Play(object):
if os.path.isfile(vars): if os.path.isfile(vars):
vars_data = utils.parse_yaml_from_file(vars) vars_data = utils.parse_yaml_from_file(vars)
if vars_data: if vars_data:
if not isinstance(vars_data, dict):
raise errors.AnsibleError("vars from '%s' are not a dict" % vars)
role_vars = utils.combine_vars(vars_data, role_vars) role_vars = utils.combine_vars(vars_data, role_vars)
defaults = self._resolve_main(utils.path_dwim(self.basedir, os.path.join(role_path, 'defaults'))) defaults = self._resolve_main(utils.path_dwim(self.basedir, os.path.join(role_path, 'defaults')))
defaults_data = {} defaults_data = {}