[chef] Re: Template Variable as a Hash


Chronological Thread 
  • From: Torben Knerr < >
  • To:
  • Subject: [chef] Re: Template Variable as a Hash
  • Date: Wed, 21 Aug 2013 18:33:27 +0200

Have you tried this?

...
params = <% @params.each...
...

HTH, Torben

On Aug 21, 2013 1:34 PM, "Michael L." < "> > wrote:
Greetings !
I am trying to pass a Hash as a variable to the Template like this:

==================================
params = {'key1' => 'val1', 'key2' => 'val2'}

template "/etc/test.conf" do
  mode 0640
  variables(
    :params => params
  )
end
==================================

My Template looks like this:

==================================
..
params =  <%= @params.each_pair {|k,v| print "#{k}=#{v} "} %>
..
==================================

But this doesn't work, giving the errors on the compile time:


==================================
..
(erubis):84: syntax error, unexpected tIDENTIFIER, expecting ')'
(erubis):90: syntax error, unexpected tIDENTIFIER, expecting ')'
 ..
==================================

Please advise.

Thanks !



Archive powered by MHonArc 2.6.16.

§