我有一个设置很多变量的 Ansible 剧本。其中一个剧本有这个任务:
- name: create config file
template:
src: 'templates/main_config.j2'
dest: "{{ tmp_dir }}/main_config.json"
模板main_config.j2
写入在父 Ansible playbook 和任务中定义为变量的字符串。
我想包含另一个基于 Ansible 变量值的 Jinja2 模板。
{% include "./templates/configurations.j2" %},
{% include "./templates/security.j2" %},
{% include './templates/' + {{ job }} + '_steps.j2' %}
job
是在父 playbook 中设置的 Ansible 变量。
这是行不通的。可能是什么问题呢?