You're getting an error because both the left and right value need to be
quoted due to the extra template evaluation you had requested, which is why
Ansible is giving the warning about this.

This is simplified if you leave off the unneccessary {{ foo }} and just say
"foo".


On Tue, May 13, 2014 at 12:45 PM, Matt Martz <m...@sivel.net> wrote:

> You when line need to be manipulated just a bit to look like:
>
> when: ansible_lo.ipv4.address == "127.0.0.1"
>
> You don't need {{}} in a when statement, you don't need to quote the whole
> line and you need to individually quote the IP address.
> --
> Matt Martz
> m...@sivel.net
>
> On May 13, 2014 at 11:17:24 AM, Julien Tognazzi (julien.togna...@gmail.com)
> wrote:
>
> Hello,
>
> Running this test playbook, I have the following error:
>
>  - hosts: localhost
>
>   tasks:
>   - name: Test IP address
>     debug: msg="ok"
>     when: "{{ ansible_lo.ipv4.address }} == 127.0.0.1"
>
>  [WARNING]: It is unneccessary to use '{{' in conditionals, leave
> variables in
> loop expressions bare.
>
>  PLAY [localhost]
> **************************************************************
>
> GATHERING FACTS
> ***************************************************************
> ok: [localhost]
>
> TASK: [Test IP address]
> *******************************************************
> fatal: [localhost] => error while evaluating conditional: 127.0.0.1 ==
> 127.0.0.1
>
> FATAL: all hosts have already failed -- aborting
>
> PLAY RECAP
> ********************************************************************
>            to retry, use: --limit @/home/admin/test.retry
>
> localhost                  : ok=1    changed=0    unreachable=1    failed=0
>
>
> I also tested without the quotes, and got the same error ?
>
> I eventually change the test to be
>       when: ansible_lo.ipv4.address.find('127.0.0.1') != -1
>
> But I don't understand why the first one always give an error.
>
> Any explanation ?
> Is is a bug ?
>
> My ansible version is 1.5.5 on centos6
>
> Thanks,
>
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/09552c1a-7c58-4049-ac68-e5934f75c520%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/09552c1a-7c58-4049-ac68-e5934f75c520%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>  --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/etPan.53724c1a.6b8b4567.6d03%40mobiletuvix.rackspace.corp<https://groups.google.com/d/msgid/ansible-project/etPan.53724c1a.6b8b4567.6d03%40mobiletuvix.rackspace.corp?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgxDPGyKpxhAThGQZM8uL1uiYccD5R1nqjwX2SwNsucpHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to