diff --git a/changelogs/fragments/auto_nice_error.yml b/changelogs/fragments/auto_nice_error.yml new file mode 100644 index 00000000000..4e97c53d926 --- /dev/null +++ b/changelogs/fragments/auto_nice_error.yml @@ -0,0 +1,2 @@ +bugfixes: + - allow nice error to work when auto plugin reads file w/o `plugin` field diff --git a/lib/ansible/plugins/inventory/auto.py b/lib/ansible/plugins/inventory/auto.py index fce5207437e..9abaaef737b 100644 --- a/lib/ansible/plugins/inventory/auto.py +++ b/lib/ansible/plugins/inventory/auto.py @@ -39,7 +39,10 @@ class InventoryModule(BaseInventoryPlugin): def parse(self, inventory, loader, path, cache=True): 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: raise AnsibleParserError("no root 'plugin' key found, '{0}' is not a valid YAML inventory plugin config file".format(path))