Monday, March 17, 2014

Puppet. generate a property file from a YAML hash

the YAML:

acmev2_properties:
  acmev2_env : DEV
  acmev2_loadbalancerurl : http://hqchacme102.acme.com:8001/



The file/template statenent:
  file { "${acmescripts_rootfolder}config/acmeconfig.properties":
    ensure  => present,
    content => template('acmev2/acmescripts/acmeconfig.properties.erb'),
    mode    => 0775,
  }


The acmeconfig.properties.erb template file:

<% @acmev2_properties.each do |key, value| -%>
<%= key %>=<%= value %>
<% end -%>



The generated property file:

acmev2_env=DEV
acmev2_loadbalancerurl=http://hqchacme102.acme.com:8001/


No comments: