Re: Re: Data bag usage in recipe. Failure. HTTP Request Returned 404 Object Not Found

Thanks Jeff,

It does make sense.

Everything works and clear now



19 груд. 2014 23:35, користувач Jeff Byrnes <> написав:

body{font-family:Helvetica,Arial;font-size:13px}The confusion here is that the data bag item is what you refer as the data bag. In your case, the data bag is `db_databag`, and the data bag item is `tenant`.

That is, this is the data bag item:

{ "id": "tenant", "tenant_name": "db_test1", "db_name": "db_name1", "path": "path1", "any_other_stuff": "some_stuff1"}

So you want to query for it like so:

tenant_data_bag = data_bag_item ‘db_databag’, ‘tenant’tenant_name = tenant_data_bag[‘tenant_name’]path = tenant_data_bag[‘path’]

Does that make more sense?

-- Jeff Byrnes


Lead DevOps EngineerEverTrue704.516.4628

On December 19, 2014 at 9:49:16 AM, ( wrote:

Hi guys,

I am really struggle with getting
data bags data into my recipe:

Here is recipe:val1 = data_bag_item('db_databag',
'tenant_name')val2 = data_bag_item('db_databag',
'path')val3 = data_bag_item('db_databag',
'db_name')val4 = data_bag_item('db_databag',

template 'c:\test_template.txt'
do source
'test.txt.erb' variables({ :value1 => "this
is FIRST #{val1}", :value2 => "this
is SECOND #{val2}", :value3 => "this
is THIRD #{val3}", :value4 => "this
is FORTH #{val4}" })end

Here is Data bag:{ "id": "tenant", "tenant_name":
"db_test1", "db_name":
"db_name1", "path":
"path1", "any_other_stuff":

Here is Template file:some text will be: <%= @value1
%>some text will be: <%=
@value2 %>some text will be: <%=
@value3 %>some text will be: <%=
@value4 %>

Chef-client version I have on a
client side:C:\Users\tklym>chef-client

Chef: 11.16.4

Client's platform is windows 2008 R2.

And here what I get when I run
[2014-12-19T14:43:47+00:00] INFO: Loading cookbooks
[2014-12-19T14:43:47+00:00] INFO: Storing updated
cookbooks/hello/recipes/templates_with_data_bags.rb in the
cache. [2014-12-19T14:43:47+00:00] INFO: HTTP Request
Returned 404 Object Not Found:
Cannot load data bag item tenant_name for data bag
db_databag172.26.3.36 [2014-12-19T14:43:47+00:00] ERROR: Failed to load
data bag item: "db_databag"
================================================================================ Recipe Compile Error in
================================================================================ Net::HTTPServerException172.26.3.36 ------------------------ 404 "Object Not Found" Cookbook Trace: ---------------
`from_file' Relevant File Content: ----------------------
c:/chef/cache/cookbooks/hello/recipes/templates_with_data_bags.rb: 1>> val1 =
data_bag_item('db_databag', 'tenant_name') 2: val2 = data_bag_item('db_databag',
'path') 3: val3 = data_bag_item('db_databag',
'db_name') 4: val4 = data_bag_item('db_databag',
'any_other_stuff') 5: 6: template 'c:\test_template.txt'
do172.26.3.36 7: source 'test.txt.erb' 8: variables({ 9: :value1 => "this
is FIRST #{val1}", 10: :value2 => "this
is SECOND #{val2}", [2014-12-19T14:43:47+00:00] ERROR: Running
exception handlers172.26.3.36 [2014-12-19T14:43:47+00:00] ERROR: Exception
handlers complete172.26.3.36 [2014-12-19T14:43:47+00:00] FATAL: Stacktrace
dumped to c:/chef/cache/chef-stacktrace.out172.26.3.36 [2014-12-19T14:43:47+00:00] INFO: Sending resource
update report (run-id:
7a567034-e647-4681-a2e5-494e04dbff81) [2014-12-19T14:43:47+00:00] FATAL:
Net::HTTPServerException: 404 "Object Not Found"ERROR: Failed to execute command on
return code 1

Have no idea how to get access to data bag data... :frowning:

Thank you in advance for your help.


Is this issue still open? The following is confusing