0

I'm trying to run a cookbook using chef-client by using "chef-apply default.rb" (where default.rb is the default recipe of the cookbook) but I keep getting the same error regardless of the cookbook I'm trying. Is what i'm doing incorrect? Is there another way to execute a single cookbook?

The errors I'm getting are:

[2016-07-20T11:00:57+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-07-20T11:00:57+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-07-20T11:00:57+00:00] FATAL: NoMethodError: undefined method `[]' for nil:NilClass
ninesalt
  • 4,054
  • 5
  • 35
  • 75
  • 1
    yes, chef-apply is intended to run a single recipe, not a cookbook. Use chef-solo or chef-zero with a cookbook_path and runlist argument. See https://learn.chef.io – Tensibai Jul 20 '16 at 12:11
  • Is this why I'm getting the error? – ninesalt Jul 20 '16 at 12:48
  • According to my divination skills as you didn't show any recipe code, I would say you're trying to access `node['whatever']` attribute defined in the cookbook attribute file which is not loaded by `chef-apply` as its goal is to run self contained recipes only. – Tensibai Jul 20 '16 at 12:49

1 Answers1

1

As Tensibai mentioned, chef-apply is for training and sometimes one-off management scripts. It has no concept of "cookbooks". The likely issue is that chef-apply is not running the attributes files (because it can't) so expected default values aren't present in the recipe code.

tl;dr stop using chef-apply. You probably want chef-solo.

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • You mean Chef Zero, don't you? ;-) (aka. [Local Mode](https://docs.chef.io/ctl_chef_client.html#run-in-local-mode) – StephenKing Jul 20 '16 at 14:24
  • No, I mean `chef-solo`. Now that we have fixed solo to be Correct™ again, we're going back to the old labeling as it reduces user confusion. – coderanger Jul 20 '16 at 14:28