[chef] Any way to reference chef DSL in erb templates?


Chronological Thread 
  • From: Geoff Meakin Acid < >
  • To:
  • Subject: [chef] Any way to reference chef DSL in erb templates?
  • Date: Wed, 7 Sep 2011 16:02:30 +0100

Hi all,

In one of my cookbook template .erb files I am trying to do this:

<%
appservers=search(:node, 'roles:appserver')
appservers.each do |appserver| 
%>

server <%= appserver.automatic_attrs["fqdn"] %>

<% end %>

This works when I use 'shef' on the chef-client node

But when I run chef-client, the following fatal error is being produced:

Chef::Mixin::Template::TemplateError (undefined method `search' for 
#<Erubis::Context:0x7f294e418830>) on line #3


What am I doing wrong? Do I need to somehow import the chef DSL? Thanks

--
Geoff




Archive powered by MHonArc 2.6.16.

§