Skip to content

Instantly share code, notes, and snippets.

@halberom
Created August 20, 2014 14:12
Show Gist options
  • Save halberom/594c015b95f1279b01ea to your computer and use it in GitHub Desktop.
Save halberom/594c015b95f1279b01ea to your computer and use it in GitHub Desktop.
ansible - example of dict with array of arrays
PLAY [foo] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [role1 | debug var=redis] ***********************************************
ok: [localhost] => {
"redis": {
"database_save_times": [
[
900,
1
],
[
300,
10
],
[
60,
10000
]
]
}
}
TASK: [role1 | template dest=/tmp/foo src=foo.j2] *****************************
changed: [localhost]
PLAY RECAP ********************************************************************
localhost : ok=3 changed=1 unreachable=0 failed=0
[root@foo ansible]# cat /tmp/foo
save 900 1
save 300 10
save 60 10000
---
- hosts: foo
roles:
- role1
redis:
database_save_times:
- [900, 1]
- [300, 10]
- [60, 10000]
---
- debug: var=redis
- template: dest=/tmp/foo src=foo.j2
{% for i in redis.database_save_times %}
save {{ i[0] }} {{ i[1] }}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment