wilblack
wilblack

Reputation: 1107

Can't find external cookbooks, Vagrant with Chef Solo

I inherited a project that hasn’t been deployed in a couple of years. It was originally set-up for local deployment on a Vagrant machine using Chef.

When I run the the vagrant up command, I get an error that it is not finding some cookbooks. First it was not finding cookbooks in the cookbooks directory specified in the Vagrantfile. I fixed this by adding a metadata.rb file to the cookbook i was trying to run. It looks like

#cookbooks/app/metadata.rb
depends "openssl"  # this is in the cookbooks directory
depends "build-essential" # this in the cookbooks directory
depends "git" # this in the cookbooks directory 

Now when I run vagrant up it breaks in the git cookbook because it cannot find one of it’s dependencies, dmg (which I don’t even need).

So how do I install these cookbooks dependencies so that it will run. Should these cookbooks be installed on my host machine (i.e. my Mac which hosts the Vagrant box) or on the Vagrant itself. I have downloaded the ChefDK and have Berkshelf but am not sure how to use it on and existing project. Also based on the solo.rb file it looks like it is looking for cookbooks in /etc/chef/cookbooks.

# solo.rb
log_level :info
cookbook_path "/etc/chef/cookbooks"
json_attribs "/etc/chef/cookbooks/node_staging.json"
role_path "/etc/chef/roles"

Here is sample output from running vagrant up.

==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2015-11-30T19:46:31+00:00] INFO: Forking chef instance to converge...
==> default: [2015-11-30T19:46:31+00:00] WARN:
==> default: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
==> default: SSL validation of HTTPS requests is disabled. HTTPS connections are still
==> default: encrypted, but chef is not able to detect forged replies or man in the middle
==> default: attacks.
==> default:
==> default: To fix this issue add an entry like this to your configuration file:
==> default:
==> default: ```
==> default:   # Verify all HTTPS connections (recommended)
==> default:   ssl_verify_mode :verify_peer
==> default:
==> default:   # OR, Verify only connections to chef-server
==> default:   verify_api_cert true
==> default: ```
==> default:
==> default: To check your SSL configuration, or troubleshoot errors, you can use the
==> default: `knife ssl check` command like so:
==> default:
==> default: ```
==> default:   knife ssl check -c /tmp/vagrant-chef/solo.rb
==> default: ```
==> default:
==> default: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
==> default: Starting Chef Client, version 11.18.12
==> default: [2015-11-30T19:46:31+00:00] INFO: *** Chef 11.18.12 ***
==> default: [2015-11-30T19:46:31+00:00] INFO: Chef-client pid: 1844
==> default: [2015-11-30T19:46:32+00:00] INFO: Setting the run_list to ["role[vagrant]"] from CLI options
==> default: [2015-11-30T19:46:32+00:00] INFO: Run List is [role[vagrant]]
==> default: [2015-11-30T19:46:32+00:00] INFO: Run List expands to [app::default]
==> default: [2015-11-30T19:46:32+00:00] INFO: Starting Chef Run for geosurvey
==> default: [2015-11-30T19:46:32+00:00] INFO: Running start handlers
==> default: [2015-11-30T19:46:32+00:00] INFO: Start handlers complete.
==> default: Compiling Cookbooks...
==> default:
==> default: Running handlers:
==> default: [2015-11-30T19:46:32+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default:
==> default: [2015-11-30T19:46:32+00:00] ERROR: Exception handlers complete
==> default: [2015-11-30T19:46:32+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: Chef Client failed. 0 resources updated in 1.06392657 seconds
==> default: [2015-11-30T19:46:32+00:00] ERROR: Cookbook dmg not found. If you're loading dmg from another cookbook, make sure you configure the dependency in your metadata
==> default: [2015-11-30T19:46:32+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

Upvotes: 0

Views: 381

Answers (2)

Andres Murillo
Andres Murillo

Reputation: 1

I have similar problems and managed to solved them party. Installing vagrant berkshelf plugin solves it party. As I understand one has to go through each cookbook and type barks install appart from configuring vagrant barkshelf like this:

config.berkshelf.enabled = true
config.berkshelf.berksfile_path = "./cookbooks/database/Berksfile"

But I'm exploring this vendor solution that didn't work quite well. As far I understand to coderanger if I had a a directory named "./cookbooks-source" and within have a bunch of cookbooks (cb1, cb2, cb3, ...) I would have to iterate each of them and type something like

berks vendor ../../cookbooks

but then each of these cookbooks dependencies might conflict with each other ? Plus I find it quite inconvenient. Also exploring berks package but just don't know how to hook it up to vagrant.

Upvotes: 0

coderanger
coderanger

Reputation: 54249

Vagrant on its own doesn't support Berkshelf integration. There is a plugin available for it (vagrant-berkshelf) which will pull in dependencies and sync them to the VM, but it isn't recommended given that it can be a bit flaky. Test Kitchen (with kitchen-vagrant) is generally easier. You can also do it manually by using the berks vendor command to download the deps and dump them into a folder structure chef-solo can use.

Upvotes: 1

Related Questions