可以在Ansible中设置列表的事实吗? [英] Is it possible to set a fact of a list in Ansible?
本文介绍了可以在Ansible中设置列表的事实吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
set_fact
在Ansible中设置包含列表的事实?它的正确语法是什么?
推荐答案
确实如此。不过,您需要引用整个列表:
- name: set fact
set_fact: foo="[ 'one', 'two', 'three' ]"
- name: debug
debug: msg={{ item }}
with_items: foo
上述任务应生成以下输出:
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屋!
查看全文