From 5802ec04bf98ec37200d33544b7dd7a0f0ffae2d Mon Sep 17 00:00:00 2001 From: Julien Palard Date: Sat, 30 Sep 2017 00:51:27 +0200 Subject: [PATCH] yaml inventory: Better error reporting on typo. fixes (#31118) --- lib/ansible/plugins/inventory/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/inventory/__init__.py b/lib/ansible/plugins/inventory/__init__.py index 72c33006ca..9b63c74c76 100644 --- a/lib/ansible/plugins/inventory/__init__.py +++ b/lib/ansible/plugins/inventory/__init__.py @@ -19,12 +19,13 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +from collections import MutableMapping import hashlib import os import re import string -from ansible.errors import AnsibleError, AnsibleOptionsError +from ansible.errors import AnsibleError, AnsibleOptionsError, AnsibleParserError from ansible.module_utils._text import to_bytes, to_native from ansible.module_utils.parsing.convert_bool import boolean from ansible.module_utils.six import string_types @@ -80,6 +81,9 @@ class BaseInventoryPlugin(object): pass def populate_host_vars(self, hosts, variables, group=None, port=None): + if not isinstance(variables, MutableMapping): + raise AnsibleParserError("Invalid data from file, expected dictionary and got:\n\n%s" % to_native(variables)) + for host in hosts: self.inventory.add_host(host, group=group, port=port) for k in variables: