From ce84d3157d73fd15de45ec1b1bcfb680d5cb41a3 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 19 Nov 2025 10:16:45 -0800 Subject: [PATCH] Fix first_found example (#86224) --- changelogs/fragments/first-found-example.yml | 2 ++ lib/ansible/plugins/lookup/first_found.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/first-found-example.yml diff --git a/changelogs/fragments/first-found-example.yml b/changelogs/fragments/first-found-example.yml new file mode 100644 index 00000000000..38ba268013d --- /dev/null +++ b/changelogs/fragments/first-found-example.yml @@ -0,0 +1,2 @@ +bugfixes: + - first_found - Correct the "Include tasks only if one of the files exists, otherwise skip" example. diff --git a/lib/ansible/plugins/lookup/first_found.py b/lib/ansible/plugins/lookup/first_found.py index 49239765b9c..c2fa2877476 100644 --- a/lib/ansible/plugins/lookup/first_found.py +++ b/lib/ansible/plugins/lookup/first_found.py @@ -79,7 +79,7 @@ EXAMPLES = """ - name: Include tasks only if one of the files exists, otherwise skip ansible.builtin.include_tasks: '{{ tasks_file }}' - when: tasks_file != "" + when: tasks_file is not none vars: tasks_file: "{{ lookup('ansible.builtin.first_found', files=['tasks.yaml', 'other_tasks.yaml'], errors='ignore') }}"