Created
May 9, 2018 12:37
-
-
Save agaffney/9807fe04f4a19263392cb340b780dcaa to your computer and use it in GitHub Desktop.
Simple example for composing complex vars by generating YAML using an inline template
This file contains hidden or 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
--- | |
- hosts: localhost | |
gather_facts: no | |
tasks: | |
- name: do some stuff | |
vars: | |
temp_var: | | |
{% for i in range(1, 5) %} | |
- {{ i }} | |
{% endfor %} | |
debug: | |
msg: '{{ temp_var | from_yaml }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This playbook dynamically creates a list in YAML using jinja templating, and then uses
| from_yaml
to convert that YAML to native types. You could alternatively have the content of thetemp_var
variable in a separate.j2
file and then use