Skip to content

Instantly share code, notes, and snippets.

@matmar10
Created April 1, 2015 12:49
Show Gist options
  • Save matmar10/d03e30170b32fb906076 to your computer and use it in GitHub Desktop.
Save matmar10/d03e30170b32fb906076 to your computer and use it in GitHub Desktop.
Wrong way to iterate over hash in ansible
---
good_things:
coffee: because you can sleep when you are dead
food: because you need calories to live
ansible: because devops
Things That Are Good
====
# wrong way
{% for key, value in good_things %}
- *{{ key }}*: {{ value.description }}
{% endfor %}
# right way!
{% for key, value in good_things.iteritems() %}
- *{{ key }}*: {{ value.description }}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment