From 90bcff3d92a7ec289d25896ff120e15bf7dace38 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 8 Mar 2019 13:03:46 -0500 Subject: [PATCH] allow nontype configdata (#53365) --- changelogs/fragments/auto_nice_error.yml | 2 ++ lib/ansible/plugins/inventory/auto.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/auto_nice_error.yml 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))