是否可以在 Ansible 中设置数组的事实? [英] Is it possible to set a fact of an array in Ansible?
本文介绍了是否可以在 Ansible 中设置数组的事实?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用 set_fact
在 ansible 中设置包含数组的事实?它的正确语法是什么?
Is it possible to set a fact containing an array in ansible using set_fact
? What's the correct syntax for it?
推荐答案
确实如此.不过,您需要引用整个数组:
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"
}
这篇关于是否可以在 Ansible 中设置数组的事实?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文