[chef] Re: Data-Bag how to use in templates


Chronological Thread 
  • From: Jonathan Matthews < >
  • To:
  • Subject: [chef] Re: Data-Bag how to use in templates
  • Date: Wed, 23 Mar 2011 08:21:40 +0000
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=jpluscplusm.com; s=google; h=mime-version:sender:x-originating-ip:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=MtzforbrG7JZT/sEjVFf+G59+7g+U4e/T2HA2Yo3rqtEaZ4pRn0Aso/6ZRo06CJPkI yCSHS9BT2x3PLyVvXOD4iprCK9s199lBHNAenoZN76rO1tzAMUhvhism3TotqpFg9nZL p3u9Feo0WHLTo+ISB5577+Q4tkuM8IPBGeWYc=

On 23 March 2011 07:21, WEINHAPL Andreas
< >
 wrote:
> HI,
>
> Yesterday I tested the Data-Bag! But I’m not able to use the Information
> from the DataBag in Templates.
>
> My recipe is:
> GLOBAL = data_bag_item('GLOBAL', 'NTP') and just use a template-function
> (create a file from file.erb)
> In my file.erb:
>
> <%= node[:GLOBAL][:ntp_2_thalesgroup.at] %>

Irrespective of your problem, already addressed by Charles, take a
look at the Resources wiki page Template section. I believe the
canonical way to reference data in a template, especially when it's
global/data-bag driven and not node-specific, is to use the fact that
it shows up as instance variables inside your template when it's been
passed in correctly. Not node[:blah] values.

I may be wrong, but it WFM :-)
Jonathan
-- 
Jonathan Matthews
London, UK
http://www.jpluscplusm.com/contact.html



Archive powered by MHonArc 2.6.16.

§