如何使用带有 Python J2 模板的 Erlang 配置文件?
How to use Erlang configuration files with Python J2 template?
我想通过以下方式使用 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
这些文件有这样的行:
{mode, max}.
{duration, 1}.
{concurrent, 32}.
这最终破坏了 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 将模板作为一个巨大的字符串来处理。我已经按照文档的建议尝试了 {{' '}} 。现在它确实起作用了。
我想通过以下方式使用 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
这些文件有这样的行:
{mode, max}.
{duration, 1}.
{concurrent, 32}.
这最终破坏了 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 将模板作为一个巨大的字符串来处理。我已经按照文档的建议尝试了 {{' '}} 。现在它确实起作用了。