我有这本Ansible剧本:
vars:
a: "key"
b: "value"
something:
"{{ a }}": "{{ b }}"
tasks:
- name: debug
debug:
msg: "{{ something | to_nice_yaml }}"
输出结果为:
ok: [localhost] => {
"msg": "'{{ a }}': value\n"
}
如何将其设为key: value
而不是{{ a }}: value
?
答案 0 :(得分:1)
您可以尝试set_fact:
tasks:
- set_fact: something="{{ a }}:{{ b }}"