Ansible with_dict expects a dict

Looks like Ansible's documentation needs updated or you've found a bug. http://docs.ansible.com/ansible/latest/playbooks_loops.html#looping-over-hashes uses your with_dict syntax but it seems like that doesn't work anymore. The dictionary needs to be on the same line as with_dict.

- name: "test2"
  debug: var="item"
  with_dict: "{{ zones_hash }}"

with_dict:
  - "{{ zones_hash }}"

declares a list with a dict as the first index, and Ansible rightfully complains since it expects a dict.

The solution kfreezy mentioned works since it actually gives a dictionary to with_dict and not a list:

with_dict: "{{ zones_hash }}"

This question is already answered, however I have solved my problem another way. It might be helpful for others.

Name of the dictionary could be a problem also. I named my dictionary name hdfs_dirs, and I was seeing with_dict expects a dict error. Apparently the same name is defined in the common vars and using the same name is not okay.

When I changed the dictionary name to hdfs_paths, it worked.

Double check the name of your dictionary also.:)