Look into Chef::Log; you may want to leave a lot of debug messages in even once this is resolved.
Also, that monitor_server executes every time (during the compilation phase) even if location isn't set in the above if block. Where does the db hash come from?
> On Feb 17, 2014, at 1:05 AM, David Montgomery < "> > wrote:
>
> Hi,
>
> I am gettng the below error. I need to debug.
>
>
> I should have values in the json object: monitor_server = db[node.environment][location]['monitor']['ip_address']
>
> How do I print to the scren values so i can see why chef is not working. undefined method `[]' for nil:NilClass is useless for me. Is it because of location? because of node.environment?
>
> I would to print to screen e.g, print node.environment
>
>
>
> ================================================================================
> Recipe Compile Error in /var/chef/cache/cookbooks/environment/recipes/remote_meta.rb
> ================================================================================
>
>
> NoMethodError
> -------------
> undefined method `[]' for nil:NilClass
>
>
> Cookbook Trace:
> ---------------
> /var/chef/cache/cookbooks/environment/recipes/remote_meta.rb:18:in `from_file'
>
>
> Relevant File Content:
> ----------------------
> /var/chef/cache/cookbooks/environment/recipes/remote_meta.rb:
>
> 11: end
> 12: if node.name.include? "X"
> 13: datacenter = node.name.split('X')[0]
> 14: server_type = node.name.split('X')[1]
> 15: location = node.name.split('X')[2]
> 16: end
> 17:
> 18>> monitor_server = db[node.environment][location]['monitor']['ip_address']
> 19:
> 20:
> 21: if datacenter != "aws"
> 22: directory "/home/ubuntu" do
> 23: owner "root"
> 24: group "root"
> 25: mode "0777"
> 26: action :create
> 27: end
>
Archive powered by MHonArc 2.6.16.