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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fa919484-7538-4e7c-a2d6-1539fee001ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to