[chef] Re: Template Variable as a Hash


Chronological Thread 
  • From: "Michael L." < >
  • To:
  • Subject: [chef] Re: Template Variable as a Hash
  • Date: Wed, 21 Aug 2013 21:05:46 +0300

It was my fault, 
the error was caused by a stupid typo which was hard to spot ..
thanks !

On Aug 21, 2013, at 7:48 PM, Daniel DeLeo < "> > wrote:


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.

§