[chef] Re: Fwd: help with erb templates


Chronological Thread 
  • From: "Joshua Miller" < >
  • To:
  • Subject: [chef] Re: Fwd: help with erb templates
  • Date: Wed, 29 May 2013 12:14:29 -0700 (PDT)

Not in front of a computer right now but have a look at the haproxy cookbook.

​ 


http://community.opscode.com/cookbooks/haproxy/source
Joshua


On Wed, May 29, 2013 at 12:10 PM, Azul < ="mailto: ">> wrote:
It has been a long day, How can I pass an array as symbol in chef ? I want to build a list of all the FQDNs containing my role 'web', and pass that list to my erb template. Tried to do it directly from the template, but it looks it only supports ruby code and not exactly chef code. my recipe, 44 template "#{node[:apache][:dir]}/httpd.conf" do 45 source "httpd.erb" 49 variables({ 50 :list_of_nodes => [], 51 :list_of_nodes => search(:node, "role:web" ) 52 }) 53 notifies :restart, resources(:service =>"httpd") 54 end my httpd.erb template 60 <% count=0 %> 61 <% @list_of_nodes.each do |result| %> 62 <% puts "hostname#{count} = #{result['fqdn']}"%> 67 <% count = count + 1 %> 68 <% end %> the result should be: hostname0 = asdfsdf.sdfdsf.com hostname1 = asdfkjew.com . . . Right now I simply get a no method .each for you, [2013-05-29T18:54:18+00:00] FATAL: Chef::Mixin::Template::TemplateError: undefined method `each' for nil:NilClass



Archive powered by MHonArc 2.6.16.

§