我想这可能适用于任何键/值存储类型,但我主要使用 Consul 进行存储。我需要一种将列表保存在键值中的方法。但是,元素周围的引号被删除。
我已经尝试了所有这些,问题是我需要它们作为有效列表返回,以便我可以通过 Ansible w/ 运行它with_flattened
curl -X PUT -d '['ui','dashboard']' http://localhost:8500/v1/kv/deploylist
curl -X PUT -d '[\'ui\',\'dashboard']' http://localhost:8500/v1/kv/deploylist
Ansible 任务:
- debug: msg="{{ deploylist_vars.value | map(attribute='Value') | first }}"
register: module_id
# Output
"msg": "[ui,dashboard]"
我需要遍历列表并执行进一步的操作。但是,我似乎无法正确解析元素。
- debug: msg="{{ item }}"
with_flattened:
- "{{ module_id }}"