allow nontype configdata (#53365)

(cherry picked from commit 90bcff3d92)
pull/53657/head
Brian Coca 7 years ago committed by Toshio Kuratomi
parent 3944f51677
commit c93bfe9931

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

@ -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))

Loading…
Cancel
Save