yaml inventory: Better error reporting on typo. fixes (#31118)
This commit is contained in:
parent
6b6a145027
commit
5802ec04bf
1 changed files with 5 additions and 1 deletions
|
@ -19,12 +19,13 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
from collections import MutableMapping
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import string
|
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._text import to_bytes, to_native
|
||||||
from ansible.module_utils.parsing.convert_bool import boolean
|
from ansible.module_utils.parsing.convert_bool import boolean
|
||||||
from ansible.module_utils.six import string_types
|
from ansible.module_utils.six import string_types
|
||||||
|
@ -80,6 +81,9 @@ class BaseInventoryPlugin(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def populate_host_vars(self, hosts, variables, group=None, port=None):
|
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:
|
for host in hosts:
|
||||||
self.inventory.add_host(host, group=group, port=port)
|
self.inventory.add_host(host, group=group, port=port)
|
||||||
for k in variables:
|
for k in variables:
|
||||||
|
|
Loading…
Reference in a new issue