Re: [ansible-project] Conditional with dict2item is falied

2020-06-15 Thread Stefan Hornburg (Racke)
On 6/15/20 9:39 PM, Rafael Tomelin 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' > -

Re: [ansible-project] Conditional with dict2item is falied

2020-06-15 Thread Rafael Tomelin
OK, thanks! On Mon, Jun 15, 2020 at 4:42 PM Matt Martz wrote: > 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

Re: [ansible-project] Conditional with dict2item is falied

2020-06-15 Thread Matt Martz
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 }}'

[ansible-project] Conditional with dict2item is falied

2020-06-15 Thread Rafael Tomelin
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