Using Artifactory 6.x ?
JFrog Artifactory 6.x User Guide
Still using Artifactory 4.x ?
JFrog Artifactory 4.x User Guide
Have a question? Want to report an issue? Contact JFrog support
To enable calculation of Chef package metadata in local repositories so they are, in effect, Chef supermarkets, set the Package Type to Chef when you create the repository:
Artifactory allows you to define any layout for your Chef Cookbook repositories. In order to upload packages according to your custom layout, you need to package your Chef Cookbook files with Knife or Berkshelf and archive the files as tar.gz. Then you can upload to any path within your local Chef supermarket, see publishing Cookbooks.
A Remote Repository defined in Artifactory serves as a caching proxy for a supermarket managed at a remote URL such as
Artifacts (such as tgz files) requested from a remote repository are cached on demand. You can remove downloaded artifacts from the remote repository cache, however, you can not manually deploy artifacts to a remote Chef repository.
To define a remote repository to proxy a remote Chef Cookbook, repository follow the steps below:
A Virtual Repository defined in Artifactory aggregates packages from both local and remote repositories.
This allows you to access both locally hosted Chef Cookbook packages and remote proxied Chef Cookbook repositories from a single URL defined for the virtual repository.
To define a virtual Chef Cookbook repository, create a virtual repository, set the Package Type to be Chef, and select the underlying local and remote Chef repositories to include in the Basic settings tab.
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:
Or, if you are using Artifactory SaaS the URL would be:
https://<server name>.jfrog.io/<server name>/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.
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 :
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
By default, Artifactory allows Anonymous Access for Chef repositories. This is defined under Security | General Configuration. For details please refer to Allow Anonymous Access.
If you want to be able to trace how users interact with your repositories you need to uncheck the Allow Anonymous Access setting. This means that users will be required to enter their username and password.
The Knife command line tool does not support basic authentication (it only supports authentication with RSA keys).
To enable basic authentication, you will need to install the knife-art.gem plugin.
If properly installed you should see the following specific Artifactory commands:
These commands are a wrapper around the standard Knife supermarket commands, that enable basic authentication. To add these credentials, pre-pend them to the URL of the Chef supermarket configured in your knife.rb file:
Use an encrypted password
Use an encrypted password instead of clear-text; see Centrally Secure Passwords.
You can use the UI or a simple REST API call to upload the tgz/tar.gz containing the Cookbook to a Chef repository.
Artifactory will automatically extract the relevant information from the
metadata.json to later serve the index and respond properly to client calls. This
metadata.json file is mandatory. If it does not exist in your cookbook, you can use a Knife command to generate it and then publish it to Artifactory. For example:
From version 6.1.0, Berkshelf supports authenticated access to Artifactory using an API Key. Previous versions of Berkshelf only supported Anonymous access to Artifactory.
To resolve dependencies from a Chef supermarket in Artifactory, first configure your Artifactory API Key using config.rb:
Then set the default supermarket in your Berksfile's Cookbook:
Then you can execute the
berks command to download the required dependencies from Artifactory:
Artifactory lets you view selected metadata of a Chef Cookbook directly from the UI.
In the Artifacts tab, select Tree Browser and drill down to select the
tgz/tar.gz file you want to inspect. The metadata is displayed in the Chef Info tab.
Artifactory supports a variety of ways to search for artifacts.
Artifactory also supports
knife search [search terms ...]:
Artifactory annotates each deployed or cached Chef Cookbook package with at least 3 properties:
chef.name, chef.version and
chef.maintainer. If available, it will also add
chef.dependencies, chef.platforms multi-valued properties.
You can use Property Search to search for Chef Cookbook according to their name, version, maintainer, dependencies or platforms requirements.