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') }}"