Unable to resolve a cookbook from artifactory with a Policyfile chef install

747 Views Asked by At

I am trying to use a Policyfile to configure an Artifactory repo as the source for a cookbook. I am using manual upload / curl to publish the cookbook to a /chef repo in artifactory (this is new too) - i wasn't able to publish with stove and want to avoid knife-art for now. The chef install run fails.

I am not sure if it's a fault with the upload or the chef install, and am not getting debug info from chef.

cookbook upload

curl --user "myuser:API_KEY" --data-binary @mycookbook.tar.gz -X PUT https://my-artifactory-server/artifactory/chef/mycookbook.tar.gz I have also tried adding it to /chef/mycookbook/mycookbook.tar.gz. There are no versions in the path or artifact name, but the metadata is valid. Are versions required?

Policyfile.rb

default_source :artifactory, "https://my-artifactory-server/artifactory/chef"
cookbook 'mycookbook'
run_list 'mycookbook::default'

I have tried with /artifactory/api/chef/ and /artifactory/api/chef/chef as the URI too. ARTIFACTORY_API_KEY variable is set to my user API key.

From a directory with the policyfile, I run chef install -D - not much info from debugging, but this is the output i get.

$ chef install --debug
Building policy mypol
Expanded run list: recipe[mycookbook::default]
Caching Cookbooks...
Error: Failed to generate Policyfile.lock
Reason: (Solve::Errors::NoSolutionError) Unable to satisfy the following requirements:

- `mycookbook (>= 0.0.0)` required by `user-specified dependency`

Have tried looking through the Artifactory logs to get an idea of what might be wrong, but not seeing much - requests.log shows a GET on /artifactory/api/chef/chef/universe which returns an OK with {} for the body - so assuming the cookbook isn't being added to a cookbook listing of some sort? Artifactory version is 5.10.

I have tried adding a virtual repo that serves the "chef" local repo and update policyfile with that, but get the same result.

1

There are 1 best solutions below

1
On

Eventually got knife artifactory working to see how it uploads. My pathing was wrong, and uploading directly to /artifactory/chef with the PUT doesn't reflect in universe.

for Curl, excluding auth params:

-X POST https://artifactory-server/artifactory/api/chef/REPO/api/v1/cookbooks/COOKBOOK.tgz?category=CAT -H "content-type: application/x-binary" --data-binary @yourcookbookarchive.tgz