summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2018-09-10 14:37:18 -0500
committerMatt Clay <matt@mystile.com>2018-09-25 15:30:32 -0700
commitc12f41907a6b0d08d00479d97b2f23fd4f04056d (patch)
tree5a08f344b67d2d4254f4f29f94dddc71c3376931
parente889001b3a33455c19d53b2511895a1f2ab1d2c0 (diff)
downloadansible-c12f41907a6b0d08d00479d97b2f23fd4f04056d.tar.gz
[stable-2.6] Don't pass file_name to DataLoader.load in script inventory plugin (#45428)
* 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 <matt@sivel.net>
-rw-r--r--changelogs/fragments/script-module-no-file-path.yaml2
-rw-r--r--lib/ansible/plugins/inventory/script.py2
2 files changed, 3 insertions, 1 deletions
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 0000000000..6df6aa45e1
--- /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 8bc1de7311..2912c9580a 100644
--- a/lib/ansible/plugins/inventory/script.py
+++ b/lib/ansible/plugins/inventory/script.py
@@ -120,7 +120,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))