Debugging chef run.--print to screen


#1

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


#2

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 davidmontgomery@gmail.com 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


#3

hash comes from a databag. Never had issues before

On Mon, Feb 17, 2014 at 5:12 PM, Daniel Condomitti daniel@condomitti.comwrote:

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 davidmontgomery@gmail.com
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


#4

Hi,

try node.chef_environment.

On 17/02/14 16:12, Daniel Condomitti wrote:

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 davidmontgomery@gmail.com 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


#5

I tied
bellow is output of logging.

log "#{node.environment}"
log “#{node.chef_environment}”

20: log "#{node.environment}"
21: log “#{node.chef_environment}”

where is the output? I thought would print to screen

On Mon, Feb 17, 2014 at 5:24 PM, Denis Barishev denis.barishev@gmail.comwrote:

Hi,

try node.chef_environment.

On 17/02/14 16:12, Daniel Condomitti wrote:

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 davidmontgomery@gmail.com

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


#6

Yeah,

try
puts "-------------------------------------"
puts “#{node.chef_environment”

otherwise it will be in your log if you use Chef::Log.info for example.

On 17/02/14 16:32, David Montgomery wrote:

I tied
bellow is output of logging.

log "#{node.environment}"
log “#{node.chef_environment}”

20: log "#{node.environment}"
21: log “#{node.chef_environment}”

where is the output? I thought would print to screen

On Mon, Feb 17, 2014 at 5:24 PM, Denis Barishev
<denis.barishev@gmail.com mailto:denis.barishev@gmail.com> wrote:

Hi,

try node.chef_environment.



On 17/02/14 16:12, Daniel Condomitti wrote:

    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
        <davidmontgomery@gmail.com
        <mailto:davidmontgomery@gmail.com>> 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