Hello,

I have a doubt regarding loops and conditionals that maybe someone can make
it clear to me.
In the documentation is stated that:

"When combining Conditionals
<https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#playbooks-conditionals>
with
a loop, the when: statement is processed separately for each item."

But if I do this:

    - name: "test loop"
      debug:
        msg: "test"
      loop: "{{nulo}}"
      when: nulo is defined

where "nulo" is an undefined variable. Here the task skips instead of
failing. If I read the documentation to the letter it should fail as it
would only do the test inside the loop.
Also, this issue:
https://github.com/ansible/ansible/issues/45976

has a slightly different variation of my loop which fails instead of
skipping.

My observed behaviour is of course the better one as allows to test the
list before running loop, but should I trust it? It is the same in all
versions of Ansible?

Thank you for your help. Regards,

Nuno Jordão

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEAA%3Dts5OMuUg535jFC0xwx2V6YiJ%3DoHAuW-XGKneejDC4QfkA%40mail.gmail.com.

Reply via email to