Francois
Francois

Reputation: 1911

Can you mix chef-zero chef-metal, chef-metal-vagrant (Vagrant) and berkshelf?

I want to leverage chef-metal and chef-zero with my existing cookbooks and chef-repo (already leveraging berkshelf and vagrant for dev)

I started with the example provided at https://github.com/opscode/chef-metal#vagrant

I've got a vagrant_linux.rb

require 'chef_metal_vagrant'

   vagrant_box 'CentOS-6.4-x86_64' do
      url 'http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box'
   end

   with_machine_options :vagrant_options => {
      'vm.box' => 'CentOS-6.4-x86_64'
   }

I also have dev_server.rb

require 'chef_metal'

with_chef_local_server :chef_repo_path => '~/workspace/git/my-chef-repo'

machine 'dev_server' do
  tag 'dev_server'
  recipe 'myapp'
  converge true
end

If I put my myapp cookbook under ~/workspace/git/my-chef-repo/cookbooks, the above works fine using the following command, I've got a vagrant managed vm named dev_server converging (applying myapp recipe)

chef-client -z vagrant_linux.rb dev_server.rb

But now, I'd like to keep my cookbooks folder empty and use berkshelf, It does not look supported by chef-zero at the moment, is it ? How could I do that ?

Upvotes: 0

Views: 581

Answers (2)

Irving
Irving

Reputation: 73

You can pass :cookbook_path that contains multiple paths as an Array like so: https://github.com/opscode/ec-metal/blob/master/cookbooks/ec-harness/recipes/vagrant.rb#L12-L13

with_chef_local_server :chef_repo_path => repo_path,
  :cookbook_path => [ File.join(repo_path, 'cookbooks'),
  File.join(repo_path, 'vendor', 'cookbooks') ]

Then you can use berks to vendor upstream cookbooks into a different path (vendor/cookbooks/), while putting your own cookbooks into cookbooks/ like so: https://github.com/opscode/ec-metal/blob/master/Rakefile#L114

berks vendor vendor/cookbooks/

Upvotes: 2

user3820873
user3820873

Reputation: 1

The "berks vendor" command is how I generally do that--use "berks vendor" and add the vendored path to your cookbook path.

Upvotes: 0

Related Questions