warn on bad keys in group

pull/31633/merge
Brian Coca 7 years ago committed by Brian Coca
parent 8415d2e60a
commit 1bf09a7d84

@ -118,19 +118,22 @@ class InventoryModule(BaseFileInventoryPlugin):
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']:
self.inventory.set_variable(group, var, group_data['vars'][var])
if group_data.get('children', False):
for subgroup in group_data['children']:
self._parse_group(subgroup, group_data['children'][subgroup])
self.inventory.add_child(group, subgroup)
if group_data.get('hosts', False):
for host_pattern in group_data['hosts']:
hosts, port = self._parse_host(host_pattern)
self.populate_host_vars(hosts, group_data['hosts'][host_pattern] or {}, group, port)
for key in group_data:
if key == 'vars':
for var in group_data['vars']:
self.inventory.set_variable(group, var, group_data['vars'][var])
elif key == 'children':
for subgroup in group_data['children']:
self._parse_group(subgroup, group_data['children'][subgroup])
self.inventory.add_child(group, subgroup)
elif key == 'hosts':
for host_pattern in group_data['hosts']:
hosts, port = self._parse_host(host_pattern)
self.populate_host_vars(hosts, group_data['hosts'][host_pattern] or {}, group, port)
else:
self.display.warn('Skipping unexpected key (%s) in group (%s), only "vars", "children" and "hosts" are valid' % (key, group))
def _parse_host(self, host_pattern):
'''

Loading…
Cancel
Save