mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user