Last active
September 27, 2018 21:22
-
-
Save jhriv/cc3da73f4abf37d488eaadc960234eaa to your computer and use it in GitHub Desktop.
Sample Ansible Playbook template+iteritems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The following should be: | |
SAMPLE: | |
one -> first | |
two -> second | |
three -> third | |
ACTUAL: | |
{% for k, v in d.iteritems() %} | |
{{ k }} -> {{ v }} | |
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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