only add group if properly defined

also corrected skip message as this has to do with type, not name

fixes #40850
This commit is contained in:
Brian Coca 2018-06-06 11:58:04 -04:00 committed by Brian Coca
parent ad8e13e9f8
commit 8e4c56d773

View file

@ -112,9 +112,10 @@ class InventoryModule(BaseFileInventoryPlugin):
def _parse_group(self, group, group_data):
self.inventory.add_group(group)
if isinstance(group_data, MutableMapping):
self.inventory.add_group(group)
# make sure they are dicts
for section in ['vars', 'children', 'hosts']:
if section in group_data:
@ -144,7 +145,7 @@ class InventoryModule(BaseFileInventoryPlugin):
self.display.warning('Skipping unexpected key (%s) in group (%s), only "vars", "children" and "hosts" are valid' % (key, group))
else:
self.display.warning("Skipping '%s' as this is not a valid group name" % group)
self.display.warning("Skipping '%s' as this is not a valid group definition" % group)
def _parse_host(self, host_pattern):
'''
@ -164,7 +165,7 @@ class InventoryModule(BaseFileInventoryPlugin):
try:
(pattern, port) = parse_address(hostpattern, allow_ranges=True)
except:
except Exception:
# not a recognizable host pattern
pattern = hostpattern
port = None