Ruby on rails Ansible-预处理ERB模板
我正在使用Ansible为我的Ruby on Rails应用程序提供环境 我想知道是否有可能在ansible copy之前预处理我的ERB模板?解决这个问题的最好办法是什么 最终目标是获得如下模板: my_template.conf.erbRuby on rails Ansible-预处理ERB模板,ruby-on-rails,ruby,erb,ansible,Ruby On Rails,Ruby,Erb,Ansible,我正在使用Ansible为我的Ruby on Rails应用程序提供环境 我想知道是否有可能在ansible copy之前预处理我的ERB模板?解决这个问题的最好办法是什么 最终目标是获得如下模板: my_template.conf.erb timeout: 2000 secret_key: <%= ENV['THE_SECRET_KEY'] %> 超时:2000 密钥: 任何提示都将不胜感激。是的 您必须使用与erb模板非常相似的jinja2模板 my_template.con
timeout: 2000
secret_key: <%= ENV['THE_SECRET_KEY'] %>
超时:2000
密钥:
任何提示都将不胜感激。是的
您必须使用与erb模板非常相似的jinja2模板
my_template.conf.j2
timeout: 2000
secret_key: {{ secret_key }}
在你的剧本中,它会是这样的:
- name: Template config
hosts: all
user: myuser
sudo: True
tags: mytag
vars:
- secret_key: "{{ lookup('env','THE_SECRET_KEY') }}"
tasks:
- name: Do template substitution
template: src=templates/my_template.conf.j2 dest=/etc/myapp/myconf.conf owner=root group=root mode=0644