Use the Knife Command Line

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide
ft:sourceType
Paligo

Chef repositories must be prefixed with api/chef in the path

When accessing a Chef supermarket through Artifactory, the repository URL must be prefixed with api/chef in the path. This applies to all Knife commands.

For example, if you are using Artifactory standalone or as a local service, you would access your Chef supermarket using the following URL:

http://localhost:8081/artifactory/api/chef/<repository key>

Or, if you are using Artifactory Cloud the URL would be:

https://<server name>.jfrog.io/artifactory/api/chef/<repository key>

To use the Knife command line you need to make sure it's installed. It's part of ChefDK, that can be installed in various ways.

Once you have created your Chef supermarket, you can select it in the Tree Browser and click Set Me Up to get code snippets you can use to change your Chef supermarket URL, and deploy and resolve packages using the knife command line tool.

image2017-2-21 11:8:54.png

Set the default Chef supermarket with a URL pointing to a Chef supermarket in Artifactory by editing your ~/.chef/knife.rb configuration file (the example below uses a repository with the key chef-virtual ). You authenticate the request using your username and password or with your Artifactory API key :

Setting the default Chef supermarket for Knife with credentials

knife[:supermarket_site] = 'http://admin:password@localhost:8081/artifactory/api/chef/chef-virtual'
or
knife[:supermarket_site] = 'http://admin:<APIKEY>@localhost:8081/artifactory/api/chef/chef-virtual'

knife.rb file location

The knife.rb file doesn't exist by default. It can be created with the knife configure command. Refer to the knife documentation for possible knife.rb locations.

The location of this file can be overidden with the --config parameter when running a knife command