ansible - with_items - 组合字符串属性
问题描述
我想知道是否有办法将字符串组合在一起,为 with_items 循环创建一个新的项目字符串属性。
我试过了:
with_items:
- {first: 'one', second: '{{ item.first}}two'}
with_items:
- {first: 'one', second: '{{ first}}two'}
- hosts: localhost
connection: local
user: root
gather_facts: no
tasks:
- shell: "echo {{ item.second }}"
with_items:
- {first: 'one', second: '{{ item.first}}-two'}
item.first = be "one"
item.second = "one-two",取 item.first 并添加到它。
解决方案
递归将不起作用。测试递归是使它变得复杂的原因吗?
否则会很简单。
- shell: "echo {{ item.first }}-{{ item.second }}"
with_items:
- {first: 'one', second: 'two'}
推荐阅读
- cassandra - 以更高的吞吐量重新思考数据库?
- google-apps-script - Apps 脚本中的 XML 错误
- javascript - 使用对象时未初始化angularJS选择
- php - Bing Ads API:如何使用 CURL/SOAP 获取给定帐户的总支出金额
- matlab - MATLAB:辛普森的 1/3 法则
- php - 在 php mysql 中加入表时出错
- javascript - 当子 div 是多个父 div 时删除子 div
- jdbc - 来自 Airpal 的 JDBC 连接
- laravel - @can 指令问题 - laravel
- c# - 同义词在 C# elasticSearch 客户端中不起作用?