更新时间:2023-08-25 08:54:16
实际上是.您需要引用整个数组:
Indeed it is. You need to quote the entire array though:
- name: set fact
set_fact: foo="[ 'one', 'two', 'three']"
- name: debug
debug: msg={{ item }}
with_items: foo
以上任务应生成以下输出:
The above tasks should generate the following output:
TASK: [set fact] **************************************************************
ok: [localhost]
TASK: [debug] *****************************************************************
ok: [localhost] => (item=one) => {
"item": "one",
"msg": "one"
}
ok: [localhost] => (item=two) => {
"item": "two",
"msg": "two"
}
ok: [localhost] => (item=three) => {
"item": "three",
"msg": "three"
}