Dictionary 在ansible playbook中嵌套循环中的字典列表上循环
我需要在嵌套循环中的另一组dict列表上循环dict列表,以读取我得到的输出中的所有值。我是ansible新手,尝试过with_项、循环、with_子元素和with_嵌套。没有什么能满足我从输出中读取所有值的需要。有人能解释一下我们如何做嵌套循环吗?非常感谢你的帮助Dictionary 在ansible playbook中嵌套循环中的字典列表上循环,dictionary,ansible,nested-loops,Dictionary,Ansible,Nested Loops,我需要在嵌套循环中的另一组dict列表上循环dict列表,以读取我得到的输出中的所有值。我是ansible新手,尝试过with_项、循环、with_子元素和with_嵌套。没有什么能满足我从输出中读取所有值的需要。有人能解释一下我们如何做嵌套循环吗?非常感谢你的帮助 Outer-List: [ { Key1: value1 Key2: value2 Inner-List: [ { Key31
Outer-List: [
{
Key1: value1
Key2: value2
Inner-List: [
{
Key31: value-A
Key32: value-B
}
{
Key33: value-C
Key34: value-D
}
],
}, ====> OuterList[0] ends here
{ ====> OuterList[1] starts here
Key1: value1
Key2: value2
Inner-List: [
{
Key31: value-E
Key32: value-F
}
{
Key33: value-G
Key34: value-H
}
],
} ====> OuterList[1] ends here
] ====> OuterList ends here
问:“循环记录目录列表。”
A:给定一个有效的
外部列表:
-内部列表:
-关键词31:价值A
键32:value-B
-键33:值-C
关键词34:价值-D
键1:值1
键2:值2
-内部列表:
-关键词31:价值E
键32:value-F
-键33:value-G
关键字34:value-H
键1:值1
键2:值2
使用。例如,下面的任务
-调试:
msg:“{item.0.Key1}}{{item.0.Key2}}{{{item.1}”
带_子元素:
-“{{Outer_List}}”
-内部列表
给出(节略)
msg:'value1 value2{'Key31':'value-A','Key32':'value-B'}
msg:'value1 value2{'Key33':'value-C','Key34':'value-D'}
msg:'value1 value2{'Key31':'value-E','Key32':'value-F'}
msg:'value1 value2{'Key33':'value-G','Key34':'value-H'}
如果需要,以下内容有效
{
“外部列表”:
[
{
“内部列表”:[
{
“键31”:“A值”,
“键32”:“值B”
},
{
“键33”:“value-C”,
“Key34”:“value-D”
}
],
“键1”:“值1”,
“键2”:“值2”
},
{
“内部列表”:[
{
“Key31”:“value-E”,
“键32”:“值-F”
},
{
“Key33”:“value-G”,
“键34”:“值-H”
}
],
“键1”:“值1”,
“键2”:“值2”
}
]
}