[chef] Re: Re: Template Variable as a Hash


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Re: Template Variable as a Hash
  • Date: Wed, 21 Aug 2013 09:48:57 -0700


On Wednesday, August 21, 2013 at 9:33 AM, Torben Knerr wrote:

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 !

You have a syntax error elsewhere in your template. Ruby is expecting a ')' character, which means you have an open-paren "(" without a matching ")".


-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§