Hello list,
I'm having a problem with adding a condition before a lookup plugin.
A simplified example that everyone can reproduce is this:
- debug: msg="This debug message should not be triggerd since some_dict is not defined"
when: some_dict is defined
with_dict: some_dict
That doesn't work because with_dict is processed before the condition is checked. That's not wrong, that's a good feature, because it enables you to do things like this:
- debug: msg="Only process item a"
when: item == "a"
with_items:
- a
- b
How could I solve my problem with having a condition before the task fails, because some_dict is not defined in my first example?
Not even an ignore_errors: yes helps in this case. I guess because it is a fatal error raised by the plugin and not simply a failed task.
TASK: [debug msg="This debug message should not be triggerd since some_dict is not defined"] ***
fatal: [test1.local] => with_dict expects a dict
FATAL: all hosts have already failed -- aborting
Thanks,
Daniel