I have a cookbooks folder in root project which also has the Vagrantfile. I only have a couple of cookbooks (starter depends on "apt" and database depends on mysql). These cookbooks were generated with berks cookbook.
Now problem is when it comes to set the config.berkshelf.berksfile_path in the Vagrantfile, I don't know if put ./cookbooks/starter/Berksfile or ./cookbooks/database/Berksfile since both cookbooks have berks dependencies.
I tried multiple options like move these cookbooks into cookbooks-src and iterate through each of them and execute berks vendor ../../cookbooks but didn't work since the second vendor generated cookbooks would overwrite previous one.
Tried also vendor each cookbooks dependencies into ./cookbooks/the-cookbook/cookbooks but vagrant doesn't recognize them.
This is my vagrant file:
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "chef-DK"
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--cpuexecutioncap", "67"]
v.memory = 537
end
config.berkshelf.enabled = true
config.berkshelf.berksfile_path = "./cookbooks/starter/Berksfile"
config.vm.provision :chef_solo do |chef|
chef.install = false
chef.run_list = [
'recipe[starter::default]',
'recipe[database::default]'
]
end
end
project/
├── cookbooks/
│ ├── database
│ │ ├── recipes
│ │ ├── Berksfile
│ │ └── metadata.rb
│ └── starter
│ ├── recipes
│ ├── Berksfile
│ └── metadata.rb
└── Vagrantfile
============================================
content of starter/metadata.rb:
name 'starter'
maintainer 'YOUR_NAME'
maintainer_email 'YOUR_EMAIL'
license 'All rights reserved'
description 'Installs/Configures starter'
long_description 'Installs/Configures starter'
version '0.1.0'
depends 'apt', '~> 3.0.0'
content of starter/Berksfile:
source "https://supermarket.chef.io"
metadata
cookbook 'apt', '~> 3.0.0'
============================================
content of database/metadata.rb:
name 'database'
maintainer 'The Authors'
maintainer_email '[email protected]'
license 'all_rights'
description 'Installs/Configures database'
long_description 'Installs/Configures database'
version '0.1.0'
depends 'mysql', '~> 6.0'
content of database/Berksfile:
source "https://supermarket.chef.io"
metadata
cookbook 'mysql', '~> 6.1.3'
Berksfile
s and thedepends
in yourmetadata.rb
files? just to check that you don't have any unusual dependence. Probably you will need to create another third Berksfile that includes the other two cookbooks. – zuazo