Thanks for the pointer. I was missing the vars section. The following works
as expected:
---
- hosts: all
vars:
users:
alice:
name: Alice Appleworth
telephone: 123-456-7890
bob:
name: Bob Bananarama
telephone: 987-654-3210
remote_user: root
tasks:
- name: Print phone records
debug: msg="User {{ item.key }} is {{ item.value.name }} ({{
item.value.telephone }})"
with_dict: users
On Tuesday, April 1, 2014 10:25:49 AM UTC-4, Serge van Ginderachter wrote:
>
>
> On 1 April 2014 00:25, Premanand Chandrasekaran
> <[email protected]<javascript:>
> > wrote:
>
>> *ERROR: parse error: playbooks must be formatted as a YAML list, got
>> <type 'dict'>*
>>
>> And here is the playbook (used from the ansible documentation) at
>> http://docs.ansible.com/playbooks_loops.html#looping-over-hashes:
>
>
> This is not a playbook, but two distinct snippets, the first from a vars
> file, the second is just a tasks list.
> Better have a look here http://docs.ansible.com/playbooks_intro.html to
> understand how a playbook is structured.
>
>
>>
>> ---
>> users:
>> alice:
>> name: Alice Appleworth
>> telephone: 123-456-7890
>> bob:
>> name: Bob Bananarama
>> telephone: 987-654-3210
>>
>> tasks:
>> - name: Print phone records
>> debug: msg="User {{ item.key }} is {{ item.value.name }} ({{
>> item.value.telephone }})"
>> *with_dict*: users
>
>
>
>
--
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/a4e90c08-2f2e-4ff3-a879-5906145a20ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.