when gets evaluated INSIDE the with loop, so it cannot condition the
executing of with, this is done so you can do when: item == 'blah' for
example to condition each iteration in the loop.

to deal with undeinfed with_ vars, do the following:

with_ : "{{ myvar|default([])}}"

^ the empty [] will skip the task as there is nothing to loop over.

some times you need more complex conditions, ternary filter can help:

with_ : "{{ unexisting is defined|ternary( groups['unexisting'], []) }}"


-- 
Brian Coca

-- 
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/CAJ5XC8%3DSMroeHAGR%3DqfGq8mOK6k4Q-8a6H5phsXja%3DqDRExRPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to