fix 'return false' from parse

this was abandoned early on the manger side  but seems like we left behind on plugin side.
more flexible extensions with yaml plugin
validate data correctly for yaml/constructed
fixed issue with only adding one child to keyed, the group only got the host that forced it's creation

fixes #31382
fixes #31365
This commit is contained in:
Brian Coca 2017-10-06 00:10:41 -04:00 committed by Brian Coca
parent f2ade09dce
commit e4c61ea9a1
5 changed files with 28 additions and 19 deletions

View file

@ -129,21 +129,18 @@ class InventoryModule(BaseInventoryPlugin):
except Exception as e:
raise AnsibleParserError(e)
msg = ''
if not self._config_data:
# empty. this is not my config file
return False
if 'plugin' in self._config_data and self._config_data['plugin'] != self.NAME:
# plugin config file, but not for us
return False
msg = 'File empty. this is not my config file'
elif 'plugin' in self._config_data and self._config_data['plugin'] != self.NAME:
msg = 'plugin config file, but not for us: %s' % self._config_data['plugin']
elif 'plugin' not in self._config_data and 'clouds' not in self._config_data:
# it's not a clouds.yaml file either
return False
msg = "it's not a plugin configuration nor a clouds.yaml file"
elif not HAS_SHADE:
msg = "shade is required for the OpenStack inventory plugin. OpenStack inventory sources will be skipped."
if not HAS_SHADE:
self.display.warning(
'shade is required for the OpenStack inventory plugin.'
' OpenStack inventory sources will be skipped.')
return False
if msg:
raise AnsibleParserError(msg)
# The user has pointed us at a clouds.yaml file. Use defaults for
# everything.