trappar/remote_syslog2-cookbook

install recipe fails

Opened this issue · 0 comments

I created a wrapper for this cookbook to setup papertrail, and got an error.

My default recipe is just include_recipe 'remote_syslog2'

and my attributes file is just setting the config.

I was able to fix it by adding the rest of your attributes file to my attributes file. Copied as is, with the exception of the old_bins. However just changing the old_bins line doesn't seem to fix it in my limited testing. I don't really know ruby, but if this were python, I would say that default['remote_syslog2']['install'] needs to be defined as a object/hash/whatever before setting the keys inside it. However, looking at other cookbooks it seems like maybe ruby doesnt require that. Hopefully this helps.

default['remote_syslog2']['config_file'] = '/etc/remote_syslog2.yml'
default['remote_syslog2']['extra_options'] = ''
default['remote_syslog2']['pid_dir'] = '/var/run'
default['remote_syslog2']['install']['download_file'] = 'https://github.com/papertrail/remote_syslog2/releases/download/v0.17/remote_syslog_linux_i386.tar.gz'
default['remote_syslog2']['install']['download_path'] = '/tmp/remote_syslog.tar.gz'
default['remote_syslog2']['install']['extract_path'] = '/tmp'
default['remote_syslog2']['install']['extracted_path'] = '/tmp/remote_syslog'
default['remote_syslog2']['install']['extracted_bin'] = 'remote_syslog'
default['remote_syslog2']['install']['bin_path'] = '/usr/local/bin'
default['remote_syslog2']['install']['bin'] = 'remote_syslog2_0.17'
default['remote_syslog2']['install']['old_bins'] = ['remote_syslog2']

The chef output when running it on a node.

NoMethodError
-------------
undefined method `[]' for nil:NilClass

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/remote_syslog2/recipes/install.rb:2:in `from_file'
  /var/chef/cache/cookbooks/remote_syslog2/recipes/default.rb:10:in `from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/remote_syslog2/recipes/install.rb:

  1:  install = node['remote_syslog2']['install']
  2>> bin_file = "#{install['bin_path']}/#{install['bin']}"
  3:
  4:  install['old_bins'].each do |old_bin_file|
  5:    file "#{install['bin_path']}/#{old_bin_file}" do
  6:      action :delete
  7:      notifies :stop, 'service[remote_syslog2]', :immediately
  8:    end
  9:  end
 10:
 11:  remote_file install['download_path'] do

Platform:
---------
x86_64-linux


Running handlers:
[2017-01-04T11:04:54-05:00] ERROR: Running exception handlers
Running handlers complete
[2017-01-04T11:04:54-05:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 03 seconds
[2017-01-04T11:04:54-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2017-01-04T11:04:54-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-01-04T11:04:54-05:00] ERROR: undefined method `[]' for nil:NilClass