Skip to content

Instantly share code, notes, and snippets.

@canit00
Forked from jhriv/in.j2
Created September 27, 2018 21:22
Show Gist options
  • Save canit00/7d0be3e5cf793d162c4975468d2f4544 to your computer and use it in GitHub Desktop.
Save canit00/7d0be3e5cf793d162c4975468d2f4544 to your computer and use it in GitHub Desktop.
Sample Ansible Playbook template+iteritems
The following should be:
SAMPLE:
one -> first
two -> second
three -> third
ACTUAL:
{% for k, v in d.iteritems() %}
{{ k }} -> {{ v }}
{% endfor %}
- name: 'Simple Test of iteritems()'
hosts: localhost
gather_facts: false
vars:
d:
one: 'first'
two: 'second'
three: 'third'
tasks:
- name: '(optional) debug output'
debug:
msg: '{{ d.iteritems() }}'
when: debug |d(false)
- name: 'Iterate over template'
template:
src: in.j2
dest: /tmp/out.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment