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
[email protected]
On May 13, 2014 at 11:17:24 AM, Julien Tognazzi ([email protected])
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 [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/09552c1a-7c58-4049-ac68-e5934f75c520%40googlegroups.com.
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 [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/etPan.53724c1a.6b8b4567.6d03%40mobiletuvix.rackspace.corp.
For more options, visit https://groups.google.com/d/optout.