I have the following task in a playbook:
- name: task xyz
copy:
src="{{ item }}"
dest="/tmp/{{ item }}"
with_items: "{{ y.z }}"
when: y.z is defined
y.z is not defined, so I'm expecting the task to be skipped. Instead, I receive:
FAILED! => {"failed": true, "msg": "'dict object' has no attribute 'z'"
I have found: How to run a task when variable is undefined in ansible? but it seems I implemented just that. What am I doing wrong here?
zin theydict is the same asy.zbeing undefined. Undefined does not necessarily mean the same thing as, say, null, empty, nil, false, etc.'z' not in y(i know that does not answer yout question but it could keep you going.'z' in y? In any case, I tried both, but the result was the same.