Hi all,

I'm trying to figure out why the expression "false and (var is undefined)", 
when 'var' has the value of an undefined variable, returns true. Here it is 
an example:

- hosts: localhost
  vars:
  g: "{{ z }}"
  is_false_var: false
  tasks:

  - debug: "msg='this must not be shown'"
    when: (is_false_var) and (b is undefined)
    ignore_errors: yes

  - debug: "msg='this must not be shown'"
    when:* (is_false_var) and (g is undefined)*
    ignore_errors: yes

  - debug: "msg='this must not be shown'"
    when: (is_false_var) and false
    ignore_errors: yes

  - debug: "msg='this must not be shown'"
    when: (is_false_var) and true
    ignore_errors: yes

  - debug: "msg={{ is_false_var and g is undefined }}"
    ignore_errors: yes

That returns:

PLAY [localhost] 
***************************************************************

TASK [setup] 
*******************************************************************
ok: [localhost]

TASK [debug] 
*******************************************************************
skipping: [localhost]




*TASK [debug] 
*******************************************************************ok: 
[localhost] => { "msg": "this must not be shown"}*

TASK [debug] 
*******************************************************************
skipping: [localhost]

TASK [debug] 
*******************************************************************
skipping: [localhost]

TASK [debug] 
*******************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "{{ z }}: 'z' is 
undefined"}
...ignoring

PLAY RECAP 
*********************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0 

Any ideas or thoughts about the avobe?

Thanks!

-- 
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/71882ba5-b853-443f-b44d-5236f2a13097%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to