我的recipes/default.rb
中有以下命令:
data = data_bag_item('config','info')
bash "setup_hadoop" do
user "#{node[:cluster][:user]}"
group "#{node[:cluster][:user]}"
cwd "#{node[:cluster][:home]}"
code <<-EOF
wget http://apache.mirror.gtcomm.net/hadoop/common/hadoop-1.2.1/hadoop-1.2.1.tar.gz
tar -xzvf hadoop-1.2.1.tar.gz
mv hadoop-1.2.1 hadoop
EOF
template "#{node[:cluster][:hadoop]}/hadoop-env.sh" do
source "hadoop-env.sh.erb"
mode 0755
owner "#{node[:cluster][:user]}"
group "#{node[:cluster][:user]}"
variables( :cluster_size => data['cluster_size'] )
end
我在info.json
中有json文件/data_bag/config/
:
{
"id": "info",
"cluster_size": 2
}
但是,当我尝试使用数据包时,出现以下错误:
[2014-05-05T14:35:45+00:00] INFO: Running start handlers
[2014-05-05T14:35:45+00:00] INFO: Start handlers complete.
[2014-05-05T14:35:45+00:00] ERROR: Failed to load data bag item: "config" "info"
================================================================================
Recipe Compile Error in /tmp/vagrant-chef-6/chef-solo-1/cookbooks/cluster/recipes/default.rb
================================================================================
TypeError
---------
can't convert Array into String
Cookbook Trace:
---------------
/tmp/vagrant-chef-6/chef-solo-1/cookbooks/cluster/recipes/default.rb:10:in `from_file'
Relevant File Content:
----------------------
/tmp/vagrant-chef-6/chef-solo-1/cookbooks/cluster/recipes/default.rb:
TypeError
---------
can't convert Array into String
10>> data = data_bag_item('config','info')
11:
12: bash "setup_hadoop" do
13: user "#{node[:cluster][:user]}"
14: group "#{node[:cluster][:user]}"
15: cwd "#{node[:cluster][:home]}"
16: code <<-EOF
17: wget http://apache.mirror.gtcomm.net/hadoop/common/hadoop-1.2.1/hadoop-1.2.1.tar.gz
18: tar -xzvf hadoop-1.2.1.tar.gz
19: mv hadoop-1.2.1 hadoop
20: variables( :cluster_size => data['cluster_size'] )
为确保正确加载数据包,我跑了:
knife data bag show config info
cluster_size: 2
id: info
这似乎是正确的。有人可以帮帮我吗?我按照this教程创建了数据包。