- From: David Montgomery <
>
- To:
- Subject: [chef] If nil how to set attributes
- Date: Tue, 16 Sep 2014 11:09:03 +0800
Hi,
Why oh why is this happening?
If nil I need to set an attribute.
node['kafka']['broker_id']
Why do I get the below error? How do I resolve?
Thanks
[192.241.213.141] out: ================================================================================
[192.241.213.141] out: Recipe Compile Error in /var/feed-chef/chef-repo/cookbooks/kafka/recipes/default.rb
[192.241.213.141] out: ================================================================================
[192.241.213.141] out:
[192.241.213.141] out: NoMethodError
[192.241.213.141] out: -------------
[192.241.213.141] out: undefined method `[]' for nil:NilClass
[192.241.213.141] out:
[192.241.213.141] out: Cookbook Trace:
[192.241.213.141] out: ---------------
[192.241.213.141] out: /var/feed-chef/chef-repo/cookbooks/kafka/recipes/default.rb:88:in `from_file'
[192.241.213.141] out:
[192.241.213.141] out: Relevant File Content:
[192.241.213.141] out: ----------------------
[192.241.213.141] out: /var/feed-chef/chef-repo/cookbooks/kafka/recipes/default.rb:
[192.241.213.141] out:
[192.241.213.141] out: 81: PYCODE
[192.241.213.141] out: 82: end
[192.241.213.141] out: 83: if File.exists?("#{Chef::Config[:file_cache_path]}/zookeeper_hosts")
[192.241.213.141] out: 84: zookeeper_hosts = File.read("#{Chef::Config[:file_cache_path]}/zookeeper_hosts")
[192.241.213.141] out: 85: end
[192.241.213.141] out: 86:
[192.241.213.141] out: 87:
[192.241.213.141] out: 88>> if node['kafka']['broker_id'].nil?
[192.241.213.141] out: 89: node.set['kafka']['broker_id'] = Time.now.getutc.to_i
[192.241.213.141] out: 90: end
[192.241.213.141] out: 91: broker_id = node['kafka']['broker_id']
[192.241.213.141] out: 92: template "/var/kafka/config/server.properties" do
[192.241.213.141] out: 93: path "/var/config/server.properties"
[192.241.213.141] out: 94: source "server.properties.local.erb"
[192.241.213.141] out: 95: owner "root"
[192.241.213.141] out: 96: group "root"
[192.241.213.141] out: 97: mode "0644"
[192.241.213.141] out:
[192.241.213.141] out:
- [chef] If nil how to set attributes, David Montgomery, 09/15/2014
Archive powered by MHonArc 2.6.16.