【发布时间】:2020-12-07 20:46:07
【问题描述】:
我想在 ansible yaml 中迭代一个变量并在 jinja 模板中添加键和值
变量:
my:
variable:
- name: test
path: /etc/apt
cert: key.crt
我的模板
{% for key, value in item() %}
{{key}}: {{value}}
{% endfor %}
ansible yaml
- name: test
template:
force: yes
src: test.conf.j2
dest: /tmp/test.conf"
become: yes
with_items:
- "{{ my.variable }}"
我的 yaml 应该是什么样子:
path: /etc/apt
cert: key.crt
【问题讨论】:
-
"msg": "ValueError: 要解压的值太多(预期为 2)"}
-
same... "msg": "ValueError: too many values to unpack (expected 2)"}