Created
December 4, 2014 10:59
-
-
Save mozz100/ee3003191bc0d072b220 to your computer and use it in GitHub Desktop.
Ansible list syntax - apparently confusing behaviour
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
localhost ansible_connection=local |
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
# Run this with >$ ansible-playbook playbook.yml -i hosts | |
- hosts: all | |
vars: | |
simple_list: [one, two, three] # lists like this are fine in yaml | |
derived_list: "[{% for thing in simple_list %}{{ thing }},{% endfor %}]" | |
# Single quotes below should be unecessary accoring to my understanding | |
derived_list2: "[{% for thing in simple_list %}'{{ thing }}',{% endfor %}]" | |
tasks: | |
- debug: var=simple_list # a list, as expected. | |
- debug: var=derived_list # a string. Eh? | |
- debug: var=derived_list2 # a list. The single quotes must be important somehow. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment