I'm trying to use with_items
to specify a list of key/value pairs to be passed to a custom ansible module.
Problem arises when key or value string has list-like format. E.g., "[('a', 'b'), ('c', 'd')]"
. In such a case with_items
presumably converts a string to a list and wrecks a havoc on my configuration.
Minimal example to reproduce (I'm using debug
module, but with custom module the behavior is the same):
- name: with_items_test
debug:
msg: "{{ item.value }}"
with_items:
- { value: "[('a', 'b'), ('c', 'd')]" }
TASK [with_items_test] ********************************************************* ok: [localhost] => (item={u'value': u"[('a', 'b'), ('c', 'd')]"}) => { "item": { "value": "[('a', 'b'), ('c', 'd')]" }, "msg": [ [ "a", "b" ], [ "c", "d" ] ] }
Without with_items
such a string is passed just fine:
- name: with_items_test
debug:
msg: "[('a', 'b'), ('c', 'd')]"
TASK [with_items_test] ********************************************************* ok: [localhost] => { "msg": "[('a', 'b'), ('c', 'd')]" }