ansible - Ansible object list from merging a list and a value
问题描述
Given a string list
list:
- a
- b
and a string
str: c
How can be obtained an object list with the same number of elements as the first list with the following structure?:
new_list:
- list_key: a
str_key: c
- list_key: b
str_key: c
Also, I'm using Ansible 2.8
解决方案
For example
- set_fact:
new_list: "{{ list|
map('regex_replace', '^(.*)$', '{list_key: \\1}')|
map('from_yaml')|
map('combine', {'str_key': str})|
list }}"
推荐阅读
- javascript - Three.js - 在动画期间获取当前骨骼骨骼位置
- google-sheets - 如何检查几列的真值或“Y”值
- reactjs - Axios put request 工作很奇怪
- python - 从没有循环的数据框创建字典
- java - 'com.company.MotherBoard' 中的错误'MotherBoard(java.lang.String, java.lang.String, float, java.lang.String)' 不能应用于'()'
- ssl - 无法通过 Python 在 Keycloak 中创建 usr
- angular - 防止在按键上的 mat-list-option 上更改焦点
- proxy - 如何将 Cronet Native 与代理一起使用?
- arrays - 过滤对象中的数组时过滤器不起作用
- reactjs - 我可以在另一条私人路线中拥有其他私人路线吗?反应式