【发布时间】:2021-06-11 21:00:47
【问题描述】:
我想遍历字典列表以及其他字典。它们都具有相同的架构。
- set_fact:
my_list:
- { foo: 1, bar: 2, baz: 3 }
- { foo: 4, bar: 5, baz: 6 }
- { foo: 7, bar: 8, baz: 9 }
- debug:
msg: "{{item.foo}} {{item.bar}} {{item.baz}}"
loop:
- "{{ my_list }}"
- { foo: 10, bar: 11, baz: 12 }
- { foo: 13, bar: 14, baz: 15 }
但这给出了:
失败了! => {"msg": "该任务包含一个带有未定义变量的选项。错误是:'list object' has no attribute 'foo'
我该怎么做?
【问题讨论】:
标签: loops dictionary ansible yaml jinja2