So this still works and we know because we have an integration test for it, but what you have with the “when: file is defined” has NEVER worked.
What happens with an include is the conditional is applied to all tasks in the include, it cannot be used to decide to include something or not, because the same tasks (with different variable contexts of course) get applied to all hosts.
It’s funny you say that, since I’ve been running this playbook for a while and ever since the update it started failing; it might very well be that the ‘when’ never did what I expected it to do though.
However, there is a clear change in behavior, further investigation shows that previously:
roles/x/tasks/main.yml:
include: …/…/y/tasks/main.yml name=“sometask”
roles/y/tasks/main.yml
include: “{{ name }}.yml”
would evaluate to “sometask.yml”, however now it evaluates to “sometask”.yml (Mind the quoting)
When you remove the quotes around variable passed in (name=sometask) it does seem to work again.