From d1ef02c714931f28703a831168fe086930b7fef4 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 25 Sep 2018 11:06:32 -0500 Subject: [PATCH] [stable-2.5] Don't pass file_name to DataLoader.load in script inventory plugin (#45428) (#45441) * Don't pass file_name to DataLoader.load in script inventory plugin. Fixes #34164 * Add changelog fragment (cherry picked from commit 263b9fa) Co-authored-by: Matt Martz --- changelogs/fragments/script-module-no-file-path.yaml | 2 ++ lib/ansible/plugins/inventory/script.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/script-module-no-file-path.yaml diff --git a/changelogs/fragments/script-module-no-file-path.yaml b/changelogs/fragments/script-module-no-file-path.yaml new file mode 100644 index 00000000000..6df6aa45e1a --- /dev/null +++ b/changelogs/fragments/script-module-no-file-path.yaml @@ -0,0 +1,2 @@ +bugfixes: +- script inventory plugin - Don't pass file_name to DataLoader.load, which will prevent misleading error messages (https://github.com/ansible/ansible/issues/34164) diff --git a/lib/ansible/plugins/inventory/script.py b/lib/ansible/plugins/inventory/script.py index c9e4709fc82..698415a413d 100644 --- a/lib/ansible/plugins/inventory/script.py +++ b/lib/ansible/plugins/inventory/script.py @@ -119,7 +119,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable): raise AnsibleError("Inventory {0} contained characters that cannot be interpreted as UTF-8: {1}".format(path, to_native(e))) try: - self._cache[cache_key] = self.loader.load(data, file_name=path) + self._cache[cache_key] = self.loader.load(data) except Exception as e: raise AnsibleError("failed to parse executable inventory script results from {0}: {1}\n{2}".format(path, to_native(e), err))