error: with_dict expects a dict

668 views
Skip to first unread message

Paul Angus

unread,
Oct 25, 2014, 4:50:32 PM10/25/14
to ansible...@googlegroups.com
I have this in my group_vars:

hotfixes-6_2_0: 
  XS62ESP1003: 
    dl_file: XS62ESP1003.zip
  XS62ESP1005: 
    dl_file: XS62E005.zip
  XS62ESP1009: 
    dl_file: XS62E009.zip

My play says:

---
- name: download xenserver hotfixes
  get_url: url="{{ item.value.dl_file }}{{ item.value.dl_path }}" dest="/tmp/{{ item.value.dl_path }}" mode=0440 force=no
  with_dict: hotfixes-6_2_0

but I get an error:

with_dict expects a dict


but it looks identical to the syntax in the example in the documentation http://docs.ansible.com/playbooks_loops.html#looping-over-hashes

what have I missed?


Many thanks


Paul Angus.
@cloudyangus




---
users:
  alice:
    name: Alice Appleworth
    telephone: 123-456-7890
  bob:
    name: Bob Bananarama
    telephone: 987-654-3210

And you want to print every user’s name and phone number. You can loop through the elements of a hash using with_dict like this:

tasks:
  - name: Print phone records
    debug: msg="User {{ item.key }} is {{ item.value.name }} ({{ item.value.telephone }})"
    with_dict: users

Brian Coca

unread,
Oct 27, 2014, 4:25:28 PM10/27/14
to ansible...@googlegroups.com

Can you rename hotfixes to avoid the dash?(-) and try again?

Reply all
Reply to author
Forward
0 new messages