mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
check type to avoid typeerror tb
fixes #31290 by giving more meaningful message
This commit is contained in:
@@ -49,7 +49,6 @@ all: # keys must be unique, i.e. only one 'hosts' per group
|
||||
last_var: MYVALUE
|
||||
'''
|
||||
|
||||
import re
|
||||
import os
|
||||
from collections import MutableMapping
|
||||
|
||||
@@ -106,8 +105,14 @@ class InventoryModule(BaseFileInventoryPlugin):
|
||||
if isinstance(group_data, MutableMapping):
|
||||
# make sure they are dicts
|
||||
for section in ['vars', 'children', 'hosts']:
|
||||
if section in group_data and isinstance(group_data[section], string_types):
|
||||
group_data[section] = {group_data[section]: None}
|
||||
if section in group_data:
|
||||
# convert strings to dicts as these are allowed
|
||||
if isinstance(group_data[section], string_types):
|
||||
group_data[section] = {group_data[section]: None}
|
||||
|
||||
if not isinstance(group_data[section], MutableMapping):
|
||||
raise AnsibleParserError('Invalid %s entry for %s group, requires a dictionary, found %s instead.' %
|
||||
(section, group, type(group_data[section])))
|
||||
|
||||
if group_data.get('vars', False):
|
||||
for var in group_data['vars']:
|
||||
|
||||
Reference in New Issue
Block a user