假设我有一个
的默认/ main.yml文件---
var1: my_value1
var2: my_value2
现在我想在调试中打印我的变种
---
- debug: ??? what to put here ???
with_items:
- "{{ var1 }}"
- "{{ var2 }}"
所以我展示了
The value of var1 is my_value1
The value of var2 is my_value2
var和msg只显示值,而不是变量名称?这似乎很简单,但我无法在Ansible文档中找到。
答案 0 :(得分:1)
您可以使用with_dict
来显示var名称,但必须以不同方式定义变量:
---
vars:
var1:
my_value1
var2:
my_value2
然后你可以这样做:
---
debug:
msg: "The value of {{item.key}} is {{item.value}}"
with_dict: "{{ vars }}"
答案 1 :(得分:0)
这对我有用。这不是我想要的消息,但它至少向我显示了项目名称及其值
Separator: ,
a3a
|~|
sssss!6
Separator: \|~\|
a3a,
, sssss!6
Separator: s{0,10}!
a3a,|~|,
6
Separator: ([0369]|([258][0369]*[147])|([147]|[258]{2})([0369]|([147][0369]*[258]))*([258]|[147]{2}))+
Exception in thread "main" java.util.regex.PatternSyntaxException: Look-behind group does not have an obvious maximum length near index 98
(?<=(([0369]|([258][0369]*[147])|([147]|[258]{2})([0369]|([147][0369]*[258]))*([258]|[147]{2}))+)|^).*?(?=(([0369]|([258][0369]*[147])|([147]|[258]{2})([0369]|([147][0369]*[258]))*([258]|[147]{2}))+)|$)
^
我得到了
- debug: var="{{item}}"
with_items:
- var1
- var2