给定字符串列表
list:
- a
- b
和字符串
str: c
如何获得与具有以下结构的第一个列表具有相同元素数量的对象列表?:
new_list:
- list_key: a
str_key: c
- list_key: b
str_key: c
此外,我正在使用Ansible 2.8
例如
- set_fact:
new_list: "{{ list|
map('regex_replace', '^(.*)$', '{list_key: \1}')|
map('from_yaml')|
map('combine', {'str_key': str})|
list }}"