我想用Ansible部署一些配置文件,方法如下:
- name: Deploying test configuration
template: src={{ item }}.j2 dest={{ basho_bench_home_dir }}/conf/{{ item }}
sudo: yes
with_items:
- http_fix_1min.conf.template
- http_max_1min.conf
文件的行如下:
^{pr2}$这最终会破坏J2渲染:
fatal: [192.168.99.135] => {'msg': "AnsibleError: file: roles/basho_bench/templates/http_fix_1min.conf.template.j2, line number: 24, error: expected token 'end of print statement', got 'Content'", 'failed': True}
fatal: [192.168.99.135] => {'msg': 'One or more items failed.', 'failed': True, 'changed': False, 'results': [{'msg': "AnsibleError: file: roles/basho_bench/templates/http_fix_1min.conf.template.j2, line number: 24, error: expected token 'end of print statement', got 'Content'", 'failed': True}]}
我不知道如何告诉J2将模板作为一个巨大的字符串来处理。我已经尝试了{{'}},正如文档所示。它现在起作用了。在
使用
{% raw %}
/{% endraw %}
块作为Jinja2文档suggests。在在你可以覆盖Jinja2环境设置之前
使
{{ }}
不被视为标记。由于一些安全问题,Ansible开发人员禁用了此功能。现在还没有。Gihub上的相关issie是here。关注参考问题,并在讨论特性时提出请求。在相关问题 更多 >
编程相关推荐