I was going to submit this as a bug but I decided to send email first in 
case I'm doing something wrong.

The session below should show all required information, but let me know 
whether something else is needed.

ansible$ cat playbooks/test_role_with_undefined_list.yml                   
                                                                            
        
---
- hosts: 127.0.0.1
  connection: local

  roles:
    - { role: ansible_tests/debug_loop_on_list, list_of_items: '{{ 
possibly_undefined_list }}' }
ansible$ cat roles/ansible_tests/debug_loop_on_list/tasks/main.yml 
- name: do something in a loop
  debug: msg="loop var is '{{ item }}'"
  with_items: list_of_items
ansible$ ansible-playbook -e '{ "possibly_undefined_list":[ "apple", 
"orange" ] }' playbooks/test_role_with_undefined_list.yml                   
             

PLAY [127.0.0.1] 
************************************************************** 

GATHERING FACTS 
*************************************************************** 
ok: [127.0.0.1]

TASK: [ansible_tests/debug_loop_on_list | do something in a loop] 
************* 
ok: [127.0.0.1] => (item=apple) => {
    "item": "apple", 
    "msg": "loop var is 'apple'"
}
ok: [127.0.0.1] => (item=orange) => {
    "item": "orange", 
    "msg": "loop var is 'orange'"
}

PLAY RECAP 
******************************************************************** 
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0 
  

ansible$ ansible-playbook playbooks/test_role_with_undefined_list.yml       
                        

PLAY [127.0.0.1] 
************************************************************** 

GATHERING FACTS 
*************************************************************** 
ok: [127.0.0.1]

TASK: [ansible_tests/debug_loop_on_list | do something in a loop] 
************* 
ok: [127.0.0.1] => (item=list_of_items) => {
    "item": "list_of_items", 
    "msg": "loop var is 'list_of_items'"
}

PLAY RECAP 
******************************************************************** 
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0 
  

ansible$ cat - >/dev/null
EXPECTED BEHAVIOR ABOVE WAS:

Error: list_of_items is undefined.

ansible$ ansible --version
ansible 1.8.4
  configured module search path = None
ansible$ grep error ansible.cfg 
# by default (as of 1.3), Ansible will raise errors when attempting to 
dereference 
#error_on_undefined_vars = False
ansible$ find roles/ansible_tests/debug_loop_on_list/ -type f               
                                                                            
      
roles/ansible_tests/debug_loop_on_list/tasks/main.yml
ansible$ 


-- 
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/5a3fac23-6cb3-4ab9-8c28-eaee42b2152c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to