6

I have a self-hosted Chef server. I can knife upload to that server, and otherwise interact with it. Therefore, my knife.rb works fine. I have recently parameterized a cookbook in order to make it the basis for a family of related cookbooks.

The problem is that I want this cookbook to be private, so it only exists on my private Chef server. Unfortunately, I can't then do berks install on my other cookbooks. I've pointed my Berksfile at my Chef server:

source https://chef.myhost.com

This does not work. I think this is because that URL is for Chef Manage, not Chef Server API. However, I am at a loss for how to get Berkshelf to recognize my Chef Server and use its API.

The full error:

> berks install
Resolving cookbook dependencies...
Fetching 'blog_role' from source at .
Fetching cookbook index from chef.myhost.com...
Error retrieving universe from source: chef.myhost.com * [Berkshelf::APIClient::BadResponse] bad response #<Faraday::Response:0x36ae618 @on_complete_callbacks=[], @env=#<Faraday::Env @method=:get @body="<html><body>You are being <a href=\"chef.myhost.com:443/signup\">redirected</a>.</body></html>" @url=#<URI::HTTPS:0x36891f0 URL:chef.myhost.com/universe> @request=#<Faraday::RequestOptions timeout=30, open_timeout=30> @request_headers={"User-Agent"=>"Faraday v0.9.1"} @ssl=#<Faraday::SSLOptions (empty)> @response_headers={"server"=>"ngx_openresty/1.4.3.6", "date"=>"Sun, 08 Feb 2015 19:49:10 GMT", "content-type"=>"text/html; charset=utf-8", "transfer-encoding"=>"chunked", "connection"=>"close", "status"=>"302 Found", "strict-transport-security"=>"max-age=631138519", "x-frame-options"=>"DENY", "x-webkit-csp"=>"default-src 'self' chrome-extension:; connect-src 'self' chrome-extension:; font-src 'self' themes.googleusercontent.com chrome-extension:; frame-src 'none' chrome-extension:; img-src 'self' ssl.google-analytics.com chrome-extension: data:; media-src 'none' chrome-extension:; object-src 'none' chrome-extension:; script-src 'self' ssl.google-analytics.com 'unsafe-inline' chrome-extension:; style-src 'self' 'unsafe-inline' fonts.googleapis.com chrome-extension:; script-nonce REDACTED;", "x-xss-protection"=>"1", "location"=>"chef.myhost.com:443/signup", "x-ua-compatible"=>"IE=Edge,chrome=1", "cache-control"=>"no-cache", "set-cookie"=>"chef-manage=REDACTED; path=/; secure; HttpOnly", "x-request-id"=>"REDACTED", "x-runtime"=>"0.034395"} @status=302>>
Unable to satisfy constraints on package source_deploy, which does not exist, due to solution constraint (app_role = 0.9.1). Solution constraints that may result in a constraint on source_deploy: [(app_role = 0.9.1) -> (source_deploy >= 0.0.0)]
Missing artifacts: source_deploy
Demand that cannot be met: (app_role = 0.9.1)
Unable to find a solution for demands: app_role (0.9.1)

So, it tries to access https://chef.myhost.com/universe, but it is bounced to the /signup page, because this is Chef Manage, not Chef Server API... But I have no idea where the API is accessible from by default, if at all. I've read for the past hour various docs, and turned up nothing...

1

Turns out that the source in a Berksfile is actually the URL of a Berkshelf API Server, not a Chef Server API.

After doing gem install berkshelf-api and configuring the config.json to use my Chef Server as an endpoint, I was able to run berks-api and then use port 26200 on my Chef Server as the target of the source in the Berksfile.

From here, berks install and berks upload both worked.

| improve this answer | |
  • Where (which server) did you run the gem install berkshelf-api? I assume your config.json changes are in the workstation running berks install/upload? Where (what server) did you run berks-api? I'm trying to set this up myself and having the same issues. In my case I set up a berks-api organization on my Chef 12 Enterprise server, which I understand is Berks-API enabled? Thanks – Chris F Apr 13 '15 at 18:13
0

I just had the same issue as you. Since updating to a newer version of Chef Server and Chef DK in an environment re-roll I went to using berkshelf for dependency management.

My metadata.rb file for a cookbook, let's call it second_local_cookbook referenced first_local_cookbook like this:

depends 'first_local_cookbook'

Then when I would run:

berks install

On second_local_cookbook to determine cookbook dependencies and the command would fail in the same way as you:

Fetching cookbook index from https://supermarket.chef.io...
Unable to satisfy constraints on package first_local_cookbook, which does not exist, due to solution constraint (second_local_cookbook = 0.1.0).
Solution constraints that may result in a constraint on first_local_cookbook: [(second_local_cookbook = 0.1.0) -> (first_local_cookbook >= 0.0.0)]
Missing artifacts: first_local_cookbook

I didn't try your solution as I was hoping there was a simple answer to reference local private cookbooks without having to install a new server API. And I found this closed issue in berkshelf's GitHub (https://github.com/berkshelf/berkshelf/issues/892). To reference a local cookbook from another cookbook you merely reference the first_local_cookbook in the Berksfile of second_local_cookbook before the metadata area like this:

source 'https://api.berkshelf.com'

cookbook 'first_local_cookbook', path: '../first_local_cookbook'
metadata

And running berks install would then succeed:

berks install
Resolving cookbook dependencies...
Fetching 'first_local_cookbook' from source at ../first_local_cookbook
Fetching 'second_local_cookbook' from source at .
...

I can then run the berks upload successfully:

berks upload second_local_cookbook --no-freeze
Uploaded second_local_cookbook (0.1.0) to: 'https://chefserver:443/organizations/organization'
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.