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.