Tom Klino
Tom Klino

Reputation: 2504

No resource found when using berks cookbook in test kitchen

I'm trying to test a recipe that uses the sudo community cookbook.

I have installed berks locally, I have created a Berksfile and added the following to it:

source "https://supermarket.getchef.com"

metadata

cookbook 'sudo'

and issued the commands berks install and berks vendor

nonetheless, I'm still getting the error

[2016-11-30T12:32:53+00:00] ERROR: No resource or method named `sudo' for `Chef::Recipe "default"'

pointing to this part of my recipe:

49>> sudo 'reboot_bot' do
50:    user 'reboot_bot'
51:    nopasswd true
52:    commands [
53:      '/sbin/reboot'
54:    ]
55:  end

Anything else that needs to be done and I'm missing? Something I'm doing wrong?

Upvotes: 0

Views: 255

Answers (1)

coderanger
coderanger

Reputation: 54211

You shouldn't need to put this in the Berksfile, that is only for overrides when you need to load from a non-standard location. Add the sudo cookbook as a dependency of your own cookbook in the metadata.rb and then Berks will see it and more importantly Chef will also see it (Chef doesn't know about Berksfiles) and will make sure to load the custom resource.

Upvotes: 1

Related Questions