Chef resources in vagrant provisioning

Hi,

I am trying to use this cookbook “https://github.com/cookbooks/nd-chef-hosts

As per readme file I’ve created a vagrant file like this

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "lucid64-customized"
config.vm.network :public_network
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe “nd-chef-hosts::example”
#chef.log_level = :debug
end

but when i “vagrant up --provision” . It throws this error

NoMethodError

No resource or method named hosts' forChef::Recipe “example”’

Cookbook Trace:

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nd-chef-hosts/recipes/example.rb:6:in
`from_file’

Relevant File Content:

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nd-chef-hosts/recipes/example.rb:

I’ve googled a lot but was not able to find the resolution for this problem.

Please help .

~cheers

You need to load the cookbook as "hosts" instead of "nd-chef-hosts". It doesn't have the name in the metadata so falls back on using the folder name, which isn't correct in this case. The issue is that LWRPs are names automatically based on the name of the cookbook they are in.

--Noah

On Mar 2, 2014, at 4:51 AM, Suresh Prajapati er.sureshprajapati@gmail.com wrote:

Hi,

I am trying to use this cookbook "GitHub - cookbooks/nd-chef-hosts: A Chef cookbook for chef-hosts (Initial Upstream: needle-cookbooks, Repository: chef-hosts)"

As per readme file I've created a vagrant file like this

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "lucid64-customized"
config.vm.network :public_network
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "nd-chef-hosts::example"
Chef Infra (archive).log_level = :debug
end

but when i "vagrant up --provision" . It throws this error

NoMethodError

No resource or method named hosts' for Chef::Recipe "example"'

Cookbook Trace:

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nd-chef-hosts/recipes/example.rb:6:in `from_file'

Relevant File Content:

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nd-chef-hosts/recipes/example.rb:

I've googled a lot but was not able to find the resolution for this problem.

Please help .

~cheers