From 939e2b4c799b60bac4ceaea649737912a2c9a115 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 27 Jun 2019 14:05:43 -0500 Subject: [PATCH] Use the filename from AnsibleFileNotFound instead of the included file. Fixes #58436 (#58464) --- changelogs/fragments/58436-include-correct-error.yml | 3 +++ lib/ansible/plugins/strategy/__init__.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/58436-include-correct-error.yml diff --git a/changelogs/fragments/58436-include-correct-error.yml b/changelogs/fragments/58436-include-correct-error.yml new file mode 100644 index 00000000000..f662cd6e7eb --- /dev/null +++ b/changelogs/fragments/58436-include-correct-error.yml @@ -0,0 +1,3 @@ +bugfixes: +- includes - Ensure to use the correct filename when AnsibleFileNotFound is + encountered (https://github.com/ansible/ansible/issues/58436) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 6a38edc2828..7141218b61d 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -814,7 +814,7 @@ class StrategyBase: except AnsibleError as e: if isinstance(e, AnsibleFileNotFound): - reason = "Could not find or access '%s' on the Ansible Controller." % to_text(included_file._filename) + reason = "Could not find or access '%s' on the Ansible Controller." % to_text(e.file_name) else: reason = to_text(e)