Search code examples
chef-infraberkshelf

How to have precedence in bershelf to take cookbooks from chef server before searching on supermarket?


We have a CI setup in our organization where we upload our cookbook to a repository. From there it is picked up by the CI app. If all checks are passed it'll upload the said cookbook to chef server. As part of the build, it'll check the berksfile and gather dependent cookbooks and upload them as well.

We are using Chef Server 12.2

The issue is we have a custom cookbook written and uploaded directly to chef server(It's not on the supermarket). The new cookbooks that we are pushing are dependent on this cookbook. And we've given

source :chef_server
source "https://supermarket.chef.io"

in the berksfile. Yet it tries to go to the supermarket and get this dependent cookbook. The build is failing on CI due to it and my newer cookbooks which are dependent on this cookbook are not getting uploaded to the chef server How can I set the precedence for berks to get my cookbook from chef server and not the supermarket?


Solution

  • Quote from berkshelf documentation (emphasis is mine):

    If a source is configured with the location :chef_server, then Berkshelf will use the configured Chef Server as an API source. This requires Chef Server 12.4.0 or newer, or Hosted Chef.

    So obviously the source :chef_server does not work as the /universe endpoint used by berkshelf has been included to chef server in 12.4.0.