Question

I've got a Chef project that, locally with Vagrant, works really nicely. I'm using librarian-chef, which means I can specify my dependencies in a Cheffile like this:

site 'http://community.opscode.com/api/v1'
cookbook 'jenkins'

When I then run librarian-chef install, it pulls down jenkins and all the cookbooks it depends on into a cookbooks directory.

There's also another directory, site-cookbooks, which is where I'm writing all of my own custom cookbooks and recipes.

In the Vagrantfile, you can then tell it to look at two different paths for cookbooks:

config.vm.provision "chef_solo" do |chef|
  chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
  # snip
end

This works perfectly when I run vagrant up. However, it doesn't seem to play nicely with AWS OpsWorks – as this requires all cookbooks to be at the top level of the Chef repository.

My question then, is: what's the nicest way to use Chef with OpsWorks without including all of the dependencies at the top level of my repository?

Was it helpful?

Solution 2

As of recently, OpsWorks supports Chef 11.10 and Berkshelf, giving you a much nicer way of managing cookbook dependencies.

OTHER TIPS

OpsWorks doesn't play nice with a number of tools created for Chef. I tried using it not long after it came out and gave up on it (OpsWorks was using Chef 9 at the time).

I suggest you either move from OpsWorks to Enterprise Chef, or try the following:

1. Create a separate repo for your cookbooks

Keep all cookbooks in a separate repo. If you want it a part of a larger repository, you can include it as git submodule. Git submodules are generally a bad thing but cookbooks are a separate entity, that can live independently of the rest of your project, so it actually works quite well in this case.

To add a cookbooks repository inside another repo, use:

git submodule add git://github.com/my/cookbooks.git ./cookbooks

2. Keep your cookbooks together with community cookbooks

You can either clone the cookbooks into your repository, add them as submodules, or try using librarian-chef/Berkshelf to manage them. You could try using this method, it should work with librarian-chef: https://sethvargo.com/using-amazon-opsworks-with-berkshelf/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top