Directory files/tmp/bar/ contains yaml files for host bar.
Directory files/tmp/foo/ doesn’t exist because host foo should not receive any files with this task.
If I run this task on hosts bar and foo, I always get a warning:
[WARNING]: Unable to find ‘files/tmp/foo’ in expected paths (use -vvvvv to see paths)
I added a condition:
when: inventory_hostname == “bar”
and even wrapped the above task in a block with the above mentioned when condition,
but I always get the warning.
The above task is just a minimal example that shows my problem.
This is actually used in my “one playbook to rule them all” and it doesn’t make sense to split this playbook in multiple ones.
I already know some not so nice workaround that maybe will suppress the warning.
I actually look for someone who shows me that I’m maybe missing something or telling me that this is a bug.
Especially when wrapping the task in a block which still triggers the fileglob for hosts which doesn’t met the when condition sounds line a bug to me.
It's not a bug it's by design. In a loop, the condition is evaluated
on each iteration. In your case, *with_fileglob* must evaluate the
list before the condition is applied.
*block* is irrelevant here. The condition is applied to all tasks.
Try for example