Thanks for the great tip!
with_items: "{{ databases.keys() }}"
also seems to work, but then you would have no access to the values :-)
On Sunday, May 19, 2013 at 1:34:14 AM UTC+2, Kahlil Hodgson wrote:
>
> Here's and example using the Jinja2's dictsort filter to turn a dictionary
> into a list of (key,value) pairs which you can than iterate over with
> with_items:
>
> vars:
> databases:
> service:
> user: service_app
> pass: 'secret'
>
> website:
> user: website_app
> pass: 'secret'
>
> brand_demo1:
> user: demo1_app
> pass: 'secret'
>
> tasks:
> - name: setup database users
> postgresql_user: name={{ item.1.user }} password={{ item.1.pass }}
> sudo_user: postgres
> with_items: databases|dictsort
>
>
> Hope this helps.
>
> Kal
>
>
> Kahlil (Kal) Hodgson GPG: C9A02289
> Head of Technology (m) +61 (0) 4 2573 0382
> DealMax Pty Ltd (w) +61 (0) 3 9008 5281
>
> Suite 1415
> 401 Docklands Drive
> Docklands VIC 3008 Australia
>
> "All parts should go together without forcing. You must remember that
> the parts you are reassembling were disassembled by you. Therefore,
> if you can't get them together again, there must be a reason. By all
> means, do not use a hammer." -- IBM maintenance manual, 1925
>
--
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/1ac10d2e-fb1f-4a93-8b64-bba575611b86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.