Skip to content

Instantly share code, notes, and snippets.

@GreyGnome
Last active April 30, 2021 20:36
Show Gist options
  • Save GreyGnome/f563342eab4e679dbc0769ae78aa1192 to your computer and use it in GitHub Desktop.
Save GreyGnome/f563342eab4e679dbc0769ae78aa1192 to your computer and use it in GitHub Desktop.
- hosts: localhost
gather_facts: false
tasks:
- debug:
msg:
- "ITEM ({{ item|type_debug }}): {{ item }}"
- "keys ( {{ _keys|type_debug }} ): {{ _keys }}"
loop: " {{ _keys }} "
vars:
_keys: [ 'bond0.160', 'bond0.197', 'bond1' ]
# END OF YML FILE ============================================================
output:
"msg": "Invalid data passed to 'loop', it requires a list, got this instead:
[u'bond0.160', u'bond0.197', u'bond1'] . Hint: If you passed a list/dict of just one element,
try adding wantlist=True to your lookup invocation or use q/query instead of lookup."
Just so I can get the loop to work, I change the loop: line to be:
loop: [ " {{ _keys }} " ]
output:
"msg": [
"ITEM (unicode): [u'bond0.160', u'bond0.197', u'bond1'] ",
"keys ( list ): [u'bond0.160', u'bond0.197', u'bond1']"
]
...So, _keys is already a list! What gives?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment