`when` statements run for every iteration of the `with_` loop, not before the loop is evaluated.
On Thursday, April 21, 2016, Julien Tognazzi <[email protected]> wrote: > Hi, > > running the following play generate this not so useful DEPRECATION WARNING > --- > - hosts: localhost > > > vars: > # - mounts: > # - '1' > # - '2' > > > tasks: > - name: "Tasks generating fatal error" > debug: var=mounts > with_items: > - "{{ mounts }}" > when: mounts is defined > tags: "mounts" > > $ ansible --version > ansible 2.0.1.0 > config file = /vagrant/sysadmin/ansible/coremedia7/ansible.cfg > configured module search path = Default w/o overrides > > > $ ansible-playbook fatal.yml > [WARNING]: provided hosts list is empty, only localhost is available > > > > > PLAY > *************************************************************************** > > > TASK [Tasks generating fatal error] > ******************************************** > Thursday 21 April 2016 13:47:46 +0200 (0:00:00.034) 0:00:00.034 > ******** > [DEPRECATION WARNING]: Skipping task due to undefined Error, in the > future this will be a fatal > error.. This feature will be removed in a future release. Deprecation > warnings can be disabled by > setting deprecation_warnings=False in ansible.cfg. > > It only happen if the mount variable is undefined... > But the when clause should prevent it to run, isn't it ? > What am I missing ? > > Should I file an issue for this ? > > thanks for any tips. > > Julien. > > -- > 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] > <javascript:_e(%7B%7D,'cvml','ansible-project%[email protected]');> > . > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/e458e63d-2b4f-4f51-b941-e1be33697ad7%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/e458e63d-2b4f-4f51-b941-e1be33697ad7%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 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/CAD8N0v_dAdguEcZ7TAMBianXVLjnPY%2BnvHt_WmZsPHwvfUTF8A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
