0

Hi I am using below in code in my chef recipe and it works fine with all the other existing servers however it doesn't work well with my new server.

user_array = node
node['user']['user_array_node_attr'].split("/").each do |hash_key|
  user_array = user_array.send(:[], hash_key)
end

And gives error as

FATAL: NoMethodError: undefined method 'split' for nil:NilClass

0

node['user']['user_array_node_attr'] is not defined, but node['user'] is. Check your attribute specification to make sure this has a value. Where does this value come from?

If it comes from another recipe, you might be in a situation where your run_list assumes this has a value before the recipe that defines it runs. This scenario can happen over time as cookbooks change -- a prior version sets the attribute properly and gets replaced, so existing nodes work fine but new nodes fail.

  • I guess it's the same as what you described above. Will it help to bring the whole vendor cookbooks folder to new repository? I mean I am using berkshelf chef and vendoring all the cookbooks in vendor/cookbooks folder. – Shailesh Sutar Mar 9 '17 at 15:56
  • That won't help -- the issue is a logical one. Cookbook A a time set that value, cookbook B was written to read it. A is changed to no longer write it but the value persists on existing nodes. Everything works until a new node is added where the value isn't set. You have to review your cookbooks / roles / environments and determine what is supposed to set that attribute. – Jason Martin Mar 9 '17 at 16:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.