diff --git a/changelogs/fragments/58436-include-correct-error.yml b/changelogs/fragments/58436-include-correct-error.yml new file mode 100644 index 0000000000..f662cd6e7e --- /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 6a38edc282..7141218b61 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)