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',
'any_other_stuff')
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
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
--version
Chef: 11.16.4
Client's platform is windows 2008 R2.
And here what I get when I run
chef-client:
172.26.3.36
[2014-12-19T14:43:47+00:00] INFO: Loading cookbooks
172.26.3.36
[2014-12-19T14:43:47+00:00] INFO: Storing updated
cookbooks/hello/recipes/templates_with_data_bags.rb in the
cache.
172.26.3.36 [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_databag
172.26.3.36 [2014-12-19T14:43:47+00:00] ERROR: Failed to load
data bag item: "db_databag"
"tenant_name"
172.26.3.36
172.26.3.36
====================================================================
============
172.26.3.36 Recipe Compile Error in
c:/chef/cache/cookbooks/hello/recipes/templates_with_data_bags.rb
172.26.3.36
================================================================================
172.26.3.36
172.26.3.36 Net::HTTPServerException
172.26.3.36 ------------------------
172.26.3.36 404 "Object Not Found"
172.26.3.36
172.26.3.36 Cookbook Trace:
172.26.3.36 ---------------
172.26.3.36
c:/chef/cache/cookbooks/hello/recipes/templates_with_data_bags.rb:1:in
`from_file'
172.26.3.36
172.26.3.36 Relevant File Content:
172.26.3.36 ----------------------
172.26.3.36
c:/chef/cache/cookbooks/hello/recipes/templates_with_data_bags.rb:
172.26.3.36
172.26.3.36 1>> val1 =
data_bag_item('db_databag', 'tenant_name')
172.26.3.36 2: val2 = data_bag_item('db_databag',
'path')
172.26.3.36 3: val3 = data_bag_item('db_databag',
'db_name')
172.26.3.36 4: val4 = data_bag_item('db_databag',
'any_other_stuff')
172.26.3.36 5:
172.26.3.36 6: template 'c:\test_template.txt'
do
172.26.3.36 7: source 'test.txt.erb'
172.26.3.36 8: variables({
172.26.3.36 9: :value1 => "this
is FIRST #{val1}",
172.26.3.36 10: :value2 => "this
is SECOND #{val2}",
172.26.3.36
172.26.3.36 [2014-12-19T14:43:47+00:00] ERROR: Running
exception handlers
172.26.3.36 [2014-12-19T14:43:47+00:00] ERROR: Exception
handlers complete
172.26.3.36 [2014-12-19T14:43:47+00:00] FATAL: Stacktrace
dumped to c:/chef/cache/chef-stacktrace.out
172.26.3.36 [2014-12-19T14:43:47+00:00] INFO: Sending resource
update report (run-id:
7a567034-e647-4681-a2e5-494e04dbff81)
172.26.3.36 [2014-12-19T14:43:47+00:00] FATAL:
Net::HTTPServerException: 404 "Object Not Found"ERROR: Failed to execute command on 172.26.3.36
return code 1
Have no idea how to get access to data bag data... :(
Thank you in advance for your help.
Regards,
Taras.