- From: Sean OMeara <
>
- To:
- Cc: WEINHAPL Andreas <
>
- Subject: [chef] Re: RE: Re: Data-Bag how to use in templates
- Date: Wed, 23 Mar 2011 10:06:19 -0400
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=Mc5qWr3yu4SKYqrs2IVuJQo+Pv1DU0oFIG6WTzjYYqG82ORYG8rk3aBh5lWmoN67Bp f4yRhb1BQmUeUuvO+dzPg6MlVzk+DILOScQbmN7NWb8/fSscf3dj0qQPONp4cx6U9dbM WcznmjiCLPbxivRUsBbrSKBluM0zMsvTfefgo=
I wrote a tutorial that uses NTP as an example, you may want to take a
peek at it:
http://goo.gl/STfRn
-s
On Wed, Mar 23, 2011 at 5:20 AM, WEINHAPL Andreas
<
>
wrote:
>
Hi Jonathan & Charles,
>
>
Thanks for the great hint. I really made a mistake in using the data-bag
>
information directly in a template. Here is the code which will work:
>
>
DataBag:
>
intChef:~/chef-repo$ knife data bag show GLOBAL NTP
>
{
>
"id": "NTP",
>
"ntp_1_for_testing": "xxx.xxx.xxx.xxx",
>
}
>
>
Recipe:
>
GLOBAL = data_bag_item('GLOBAL','NTP')
>
node[:ntp1] = "#{GLOBAL['ntp_1_for_testing']}"
>
>
Template:
>
NTP1 for DOMAIN <%= node[:ntp1] %>
>
>
Maybe it's not the correct way to do that but it works!
>
>
Regards
>
Andreas
>
-----Original Message-----
>
From:
>
>
>
[mailto:
>
On Behalf
>
Of Jonathan Matthews
>
Sent: Mittwoch, 23. März 2011 09:22
>
To:
>
>
Subject: [chef] Re: Data-Bag how to use in templates
>
>
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.