Jordi
Jordi

Reputation: 23237

Chef: No such cookbook

I'm getting this error when I'm trying to provion my vm using vagrant and chef:

==> default: ====================================
==> default: Error Resolving Cookbooks for Run List:
==> default: ====================================
==> default:
==> default: Missing Cookbooks:
==> default: ------------------
==> default: No such cookbook: windows
==> default:
==> default: Expanded Run List:
==> default: ------------------
==> default: * java
==> default:
==> default: Platform:
==> default: ---------
==> default: x86_64-linux
==> default:

My vagrant structure is:

VagrantFile
├───chef
│   ├───cookbooks
│   │   ├───apt
│   │   ├───java
│   ├───roles
│   │   ├───java-dev-workstation.rb

Vagrantfile content is:

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.provision "chef_solo" do |chef|
    chef.roles_path = "chef/roles"
    chef.cookbooks_path = "chef/cookbooks"
    chef.add_role "java-dev-workstation"
  end
end

And java-dev-workstation.rb:

name "java-dev-workstation"

default_attributes( 
  # Because it's Oracle, we need to agree to the terms and conditions.
  :java => { 
    :install_flavor => 'oracle',
    :jdk_version => '8',
    :accept_license_agreement => true,
    :oracle => { "accept_oracle_download_terms" => true } 
  }

)

run_list(
  "recipe[java]"
)

I'm using Chef 12.18.31.

Any ideas?

Upvotes: 2

Views: 1155

Answers (2)

Alexey Melezhik
Alexey Melezhik

Reputation: 971

Agreed with previous comment. So not to add all the dependencies manually use vagrant-berkshelf plugin - https://github.com/berkshelf/vagrant-berkshelf

All you need to do:

  1. Declare all the dependencies ( in your case it is only java cookbook, berkshelf will take care silently about cookbooks java cookbook depends on - windows, so on .. ) in proper Berksfile
  2. Point a Berksfile location in your Vagrantfile

Upvotes: 0

coderanger
coderanger

Reputation: 54211

The java cookbook depends on the windows cookbook, which you don't have downloaded and so it cannot proceed. This is why people generally use Berkshelf or the Policyfile system as both of those download dependencies automatically for you.

And to answer your likely next question: yes you need the dependency even though you aren't using a Windows VM, we don't have any way to do optional dependencies.

Upvotes: 2

Related Questions