1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

allow nontype configdata (#53365)

This commit is contained in:
Brian Coca 2019-03-08 13:03:46 -05:00 committed by GitHub
parent 25a8e47783
commit 90bcff3d92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- allow nice error to work when auto plugin reads file w/o `plugin` field

View file

@ -39,7 +39,10 @@ class InventoryModule(BaseInventoryPlugin):
def parse(self, inventory, loader, path, cache=True): def parse(self, inventory, loader, path, cache=True):
config_data = loader.load_from_file(path, cache=False) config_data = loader.load_from_file(path, cache=False)
plugin_name = config_data.get('plugin') try:
plugin_name = config_data.get('plugin', None)
except AttributeError:
plugin_name = None
if not plugin_name: if not plugin_name:
raise AnsibleParserError("no root 'plugin' key found, '{0}' is not a valid YAML inventory plugin config file".format(path)) raise AnsibleParserError("no root 'plugin' key found, '{0}' is not a valid YAML inventory plugin config file".format(path))