use single erb template for different files in a single puppet manifest -
i use single erb template create different files. here erb.
# managed puppet # changes overwritten # <% if (@tanuki_ssl != nil) -%> # config include # ssl section trust , key stores # <% unless @tanuki_ssl['truststore_path'].nil? -%> wrapper.java.additional.940=-djavax.net.ssl.truststore=<%= @tanuki_ssl['truststore_path'] %> <% end -%> <% unless @tanuki_ssl['truststore_pass'].nil? -%> wrapper.java.additional.941=-djavax.net.ssl.truststorepassword=<%= @tanuki_ssl['truststore_pass'] %> <% end -%> <% end -%> <% if (@tanuki_proxy != nil) -%> # config include # proxy section # wrapper.java.additional.951=-dhttp.proxyset=true wrapper.java.additional.952=-dhttp.proxyhost=<%= @tanuki_proxy['host'] %> wrapper.java.additional.953=-dhttp.proxyport=<%= @tanuki_proxy['port'] %> wrapper.java.additional.954=-dhttp.nonproxyhosts=<%= @tanuki_proxy['exceptions'].join('|') %>|<%= @ipaddress %>|<%= @hostname %> wrapper.java.additional.955=-dhttps.proxyset=true wrapper.java.additional.956=-dhttps.proxyhost=<%= @tanuki_proxy['host'] %> wrapper.java.additional.957=-dhttps.proxyport=<%= @tanuki_proxy['port'] %> wrapper.java.additional.958=-dhttps.nonproxyhosts=<%= @tanuki_proxy['exceptions'].join('|') %>|<%= @ipaddress %>|<%= @hostname %> <% end -%>
in puppet manifest wrote 2 file resources:
if $tanuki_hash['ssl_enabled'] { $tanuki_ssl = $tanuki_hash['ssl'] file { "${tanuki_path}/${dirname}/conf/940-ssl.inc": content => template('profile/app/wrapper.inc.erb'), } } if $tanuki_hash['proxy_enabled'] { if $tanuki_hash['override_system_proxy'] { $tanuki_proxy=$tanuki_hash['proxy'] } else { $tanunki_proxy=$proxy_hash } file { "${tanuki_path}/${dirname}/conf/950-proxy.inc": content => template('profile/app/wrapper.inc.erb'), } }
i run puppet file 940-ssl.incl expected content. first if section interpretet.
but file 950-proxy.inc have ssl part too.
so, how can pass needed variable each file?
cheers
christian
it isn't possible pass different variables erb template()
function, think need either:
- use epp() function embedded puppet syntax instead of erb, lets pass different local variables template when calling it.
- use different templates or different scopes. rendering same template within same scope should typically render same result, you're trying work against.
Comments
Post a Comment