Skip to content

Instantly share code, notes, and snippets.

@mozz100
Created December 4, 2014 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mozz100/ee3003191bc0d072b220 to your computer and use it in GitHub Desktop.
Save mozz100/ee3003191bc0d072b220 to your computer and use it in GitHub Desktop.
Ansible list syntax - apparently confusing behaviour
localhost ansible_connection=local
# 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