From a7dd425620e0a40911908a41e1b378183ae690f4 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 19 Jan 2016 12:07:45 -0500 Subject: [PATCH] Catch INI section parsing misses and raise an appropriate error Fixes #13917 --- lib/ansible/inventory/ini.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/inventory/ini.py b/lib/ansible/inventory/ini.py index 9224ef2d23..4d43977004 100644 --- a/lib/ansible/inventory/ini.py +++ b/lib/ansible/inventory/ini.py @@ -23,7 +23,7 @@ import ast import re from ansible import constants as C -from ansible.errors import AnsibleError, AnsibleParserError +from ansible.errors import AnsibleError from ansible.inventory.host import Host from ansible.inventory.group import Group from ansible.inventory.expand_hosts import detect_range @@ -124,6 +124,9 @@ class InventoryParser(object): del pending_declarations[groupname] continue + elif line.startswith('['): + self._raise_error("Invalid section entry: '%s'. Please make sure that there are no spaces" % line + \ + "in the section entry, and that there are no other invalid characters") # It's not a section, so the current state tells us what kind of # definition it must be. The individual parsers will raise an