On Tuesday, June 25, 2013 at 8:10 AM, wrote:
Hello,I'm creating simple test recipe with a template and data bag. What I'm tryingto do is creating a config file from data bag that has simple nestedinformation, but I receive error "can't convert String into Integer" and Ican't find how to get data bag item "part.name"Here are my setting files.1) recipe/default.rbdata1 = data_bag_item( 'mytest', 'qa' )['test']data2 = data_bag_item( 'mytest', 'qa' )template "/opt/env/test.cfg" dosource "test.erb"action :create_if_missingmode 0664owner "root"group "root"variables({:pepe1 => data1['part.name'],:pepe2 => data2['transport.tcp.ip2']})end2)my data bag named "mytest"test.json{"test":[{"part.name": "L12","transport.tcp.ip": "111.111.111.111","transport.tcp.port": "9199"}],"transport.tcp.ip2": "222.222.222.222","id": "qa"}$knife data bag show mytest qaid: qatest:part.name: L12transport.tcp.ip: 111.111.111.111transport.tcp.port: 9199transport.tcp.ip2: 222.222.222.2223)template file test.erbpart.name=<%= @pepe1 %>transport.tcp.binding=<%= @pepe2 %>Error returns when I run chef-client on my server,[2013-06-24T19:50:38+00:00] DEBUG: filtered backtrace of compile error:/var/chef/cache/cookbooks/config_test/recipes/default.rb:19:in[]',/var/chef/cache/cookbooks/config_test/recipes/default.rb:19:inblock infrom_file',/var/chef/cache/cookbooks/config_test/recipes/default.rb:12:infrom_file' [2013-06-24T19:50:38+00:00] DEBUG: filtered backtrace of compileerror:/var/chef/cache/cookbooks/config_test/recipes/default.rb:19:in[]',/var/chef/cache/cookbooks/config_test/recipes/default.rb:19:inblock infrom_file',/var/chef/cache/cookbooks/config_test/recipes/default.rb:12:infrom_file'[2013-06-24T19:50:38+00:00] DEBUG: backtrace entry for compile error:'/var/chef/cache/cookbooks/config_test/recipes/default.rb:19:in `[]''[2013-06-24T19:50:38+00:00] DEBUG: Line number of compile error: '19'Recipe Compile Error in/var/chef/cache/cookbooks/config_test/recipes/default.rbTypeErrorcan't convert String into IntegerCookbook Trace:/var/chef/cache/cookbooks/config_test/recipes/default.rb:19:in []'/var/chef/cache/cookbooks/config_test/recipes/default.rb:19:inblock infrom_file' /var/chef/cache/cookbooks/config_test/recipes/default.rb:12:in`from_file'Relevant File Content:/var/chef/cache/cookbooks/config_test/recipes/default.rb:12: template "/opt/env/test.cfg" do13: source "test.erb"14: action :create_if_missing15: mode 066416: owner "root"17: group "root"18: variables({19>> :pepe1 => data1['part.name'],20: :pepe2 => data2['transport.tcp.ip2']21: })22: end 23:I tried many things and if I comment out "pepe1 => data1['part.name'],", then:pepe2 => data2['transport.tcp.ip2'] works fine. only nested data "part.name"cannot be set to @pepe1.Does anyone knows why I receive the errors?thanks,
Archive powered by MHonArc 2.6.16.