rackspace-cookbooks/elkstack

Recipe compiler error when running with Chef 12.3.0

markcallen opened this issue · 3 comments

When running on a linux server with chef 12.3.0 installed I get the following error:

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/uhostelk/recipes/default.rb

NoMethodError


undefined method `unpack' for #Hash:0x00000005271258

Cookbook Trace:


/var/chef/cache/cookbooks/elkstack/recipes/_lumberjack_secrets.rb:41:in `from_file'
/var/chef/cache/cookbooks/elkstack/recipes/logstash.rb:52:in `from_file'
/var/chef/cache/cookbooks/elkstack/recipes/default.rb:14:in `from_file'
/var/chef/cache/cookbooks/uhostelk/recipes/default.rb:13:in `from_file'

Relevant File Content:


/var/chef/cache/cookbooks/elkstack/recipes/_lumberjack_secrets.rb:

34: lumberjack_secrets = nil
35: end
36: end
37:
38: # now try to use the data bag
39: if !lumberjack_secrets.nil? && lumberjack_secrets['key'] && lumberjack_secrets['certificate']
40: log lumberjack_secrets['key']
41>> node.run_state['lumberjack_decoded_key'] = Base64.decode64(lumberjack_secrets['key'])
42: node.run_state['lumberjack_decoded_certificate'] = Base64.decode64(lumberjack_secrets['certificate'])
43: elsif !lumberjack_secrets.nil?
44: Chef::Log.warn('Found a data bag for lumberjack secrets, but it was missing 'key' and 'certificate' data bag items')
45: elsif lumberjack_secrets.nil?
46: Chef::Log.warn('Could not find an encrypted or unencrypted data bag to use as a lumberjack keypair')
47: else
48: Chef::Log.warn('Unable to complete lumberjack keypair configuration')
49: end
50:

Hi there -- can you show us the data bag you're using? I think this is more a function of that being unexpected. We're actually doing test-kitchen tests with this setup and it's working okay.

It was the secrets. I don't know what was wrong, but recreating them and knife'ng them got the recipe to work. I also added a PR to solve the compiler error when the secrets are wrong. At least then you can debug the problem on the server instead of getting a compiler error.

@markcallen Thank you for the update. One of the reason we have TK suites is to catch those before they ever get to a server. That might be useful for your use case too. Cheers!