- From: Adam Jacob <
>
- To:
- Cc: WEINHAPL Andreas <
>
- Subject: [chef] Re: RE: Re: Data-Bag how to use in templates
- Date: Wed, 23 Mar 2011 12:17:57 -0700
On Wed, Mar 23, 2011 at 2: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']}"
You don't need to have this as a constant, which is what you're doing
here, most likely. Rather, you might want to do something like set the
value for the NTP server in a role default, and have the value appear
directly on each node.
Conversely, you might want to just change "GLOBAL" to 'global', and
make it a local variable.
Best,
Adam
--
Opscode, Inc.
Adam Jacob, Chief Product Officer
T: (206) 619-7151 E:
Archive powered by MHonArc 2.6.16.