In the case of using `when` and `loop`, the `when` statements is applied to
each iteration of the `loop`, and not before it.
As such, you cannot prevent a loop from happening using a when statement.
Instead you want to do this in loop, like:
loop: '{{ virtual_machine|default({})|dict2items }}'
On Mon, Jun 15, 2020 at 2:39 PM Rafael Tomelin <[email protected]>
wrote:
>
> Hi guys,
>
> I have a task with equal below, but when I validate it is defined it not
> recognized.
> - name: include vars virtual_machine
> include_tasks: virtual_machine.yml
> when:
> - gms_az_vm_action == 'create_virtual_machine'
> - virtual_machine is defined
> loop: "{{ virtual_machine|dict2items }}"
>
>
>
> How I do for doesn't read loop and not stop playbook when virtual_machine
> not defined?
>
> --
> Atenciosamente,
>
> Rafael Tomelin
> Tel.: 51-984104084
> Skype: rafael.tomelin
>
> LPI ID: LPI000191271
> Red Hat Certified Engineer
> Puppet Professional 2017 Certification
>
> --
> 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/CAGEUqbAv4tEJoSWWU7TR9YP3x%2B5BzVDO6NmS7rZCGYhEHN_ocg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAGEUqbAv4tEJoSWWU7TR9YP3x%2B5BzVDO6NmS7rZCGYhEHN_ocg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
Matt Martz
@sivel
sivel.net
--
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/CAD8N0v_A15vdx3waWE%3DH5ztveN-W6MdNz%2BP_WGAFOpEbRsFprg%40mail.gmail.com.