From 2e7c09e96787f91042c751e933dd3d54684bd3eb Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 6 Jun 2018 11:58:04 -0400 Subject: [PATCH] only add group if properly defined also corrected skip message as this has to do with type, not name fixes #40850 (cherry picked from commit 8e4c56d773a40769aa221c772d1b0cb3cf738225) --- lib/ansible/plugins/inventory/yaml.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ansible/plugins/inventory/yaml.py b/lib/ansible/plugins/inventory/yaml.py index d6e6d623ca1..38d24fe0cef 100644 --- a/lib/ansible/plugins/inventory/yaml.py +++ b/lib/ansible/plugins/inventory/yaml.py @@ -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