Table of contents
1.
Introduction
2.
What is a cookbook?
3.
Knife cookbook site
4.
Commands
4.1.
Private Supermarket
4.1.1.
Example
4.2.
download
4.3.
install
4.4.
list
4.5.
search
4.6.
share
4.7.
show
4.8.
unshare
5.
Frequently Asked Questions
5.1.
What is a cookbook in DevOps?
5.2.
What is Knife?
5.3.
Why is a cookbook important?
5.4.
What is a cookbook in the programming context?
5.5.
Why is Chef used in DevOps?
6.
Conclusion
Last Updated: Aug 13, 2025
Easy

Overview of Knife Cookbook Site

Author yuvatimankar
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

In this blog, we will discuss the various arguments of the knife cookbook site command in detail. We use this command to interact with the cookbooks that are available in the Chef Supermarket. Are you ready?

overview of knife cookbook site

So, Stay till the end, and Let's get started!

What is a cookbook?

A cookbook is a basic unit of configuration and policy distribution in Chef Infra. It defines a scenario and keeps everything needed to support it. The cookbook organizes material into recipes. The cookbook can do multiple tasks—cookbooks store values about the state required of the node.

Knife cookbook site

To provide access to tools, cookbooks, and users on the chef supermarket, the Supermarket API is used. All of the tools, cookbooks, and users on the supermarket are accessible via RESTful API by accessing supermarket.chef.io/api/v1/ with the help of supported endpoints. The Knife is often the better way to interact with the supermarket, though in some cases, direct use of the Supermarket API is required.

So, to interact with cookbooks that are present in the chef supermarket, the knife cookbook site subcommand is used. A user account is needed for any actions that write data to this site. A user account does not require search, install, download, or list arguments.

Commands

Private Supermarket

For using the knife cookbook site command with a private supermarket installation, we first have to add the URL of our supermarket to our config.rb file.

Example

knife[:supermarket_site] = 'https://supermarket.example.com'


A knife will use https://supermarket.chef.io by default if the value is not specified.

download

  • For downloading a cookbook from the community website, use the download argument.
     
  • A cookbook will be downloaded in tar.gz archive format and kept in the current working directory.
Syntax knife cookbook site download NAME_OF_COOKBOOK [VERSION_OF_COOKBOOK] (options)
Options -f FILE, --file FILE, --force, COOKBOOK_VERSION, -m SUPERMARKET_SITE, --supermarket-site SUPERMARKET_SITE
Example knife cookbook site download getting-started

install

This argument is used to install a cookbook downloaded from the community site into a local git repo. This argument uses the git version control system associated with the chef Supermarket site for installing community-contributed cookbooks to the local chef repository. 

After using this argument, the following things are done:

  • A new "pristine copy" branch is generated in git for mapping the upstream.
     
  • The cookbook is downloaded in tar.gz format from the Chef Supermarket.
     
  • All the existing versions of a cookbook are deleted from the branch.
     
  • The "pristine copy" branch is merged with the master branch.
Syntax knife cookbook site install NAME_OF_THE_COOKBOOK [VERSION_of_COOKBOOK] (options)
Options -B BRANCH, --branch BRANCH, -b, --use-current-branch, -D, --skip-dependencies, -o PATH:PATH, --cookbook path PATH:PATH
Example knife cookbook site install getting-started

list

This argument is used to see a list of cookbooks currently present at the Chef Supermarket.

Syntax knife cookbook site list
Options -m SUPERMARKET_SITE, --supermarket-site SUPERMARKET_SITE, -w, --with-uri
Examples knife cookbook site list

search

This argument is used to search for a cookbook present at the Chef Supermarket. We can use a search query to return a cookbook list at the Chef Supermarket.

Syntax knife cookbook site search SEARCH_QUERY (options)
Options --supermarket-site SUPERMARKET_SITE, -m SUPERMARKET_SITE
Examples knife cookbook site search 'apache*'

share

This argument is used to insert a cookbook into the Chef Supermarket. A user account is needed for this action as a certificate for Chef Supermarket. By default, Knife uses the user name and API key which is identified in the configuration file used during the upload. These values should be specified in an alternate configuration file or on the command line. 

Syntax knife cookbook site share NAME_of_COOKBOOK CATEGORY (options)
Options CATEGORY, -m SUPERMARKET_SITE, -n, --dry-run, -o PATH:PATH, --cookbook-path PATH:PATH, --supermarket-site SUPERMARKET_SITE
Example knife cookbook site share "apache2" "Web Servers"

show

This argument is used to see information about a cookbook at the Chef Supermarket.

Syntax knife cookbook site show NAME_OF_COOKBOOK [VERSION_OF_COOKBOOK]
Options -m SUPERMARKET_SITE, --supermarket-site SUPERMARKET_SITE, COOKBOOK_VERSION
Examples
  • knife cookbook site show haproxy
  • knife cookbook site show devops -F text

unshare

This argument is used to stop sharing a cookbook at the Chef Supermarket. A maintainer of a cookbook can only perform this action.

Syntax knife cookbook site unshare NAME_OF_COOKBOOK/versions/VERSION
Options -m SUPERMARKET_SITE, --supermarket-site SUPERMARKET_SITE
Examples

knife cookbook site unshare "getting-started"

For version:

knife cookbook site unshare "getting-started/versions/0.10.0”

 

Check out most important Git Interview Questions here.

Frequently Asked Questions

What is a cookbook in DevOps?

In terms of DevOps, Cookbooks are the fundamental unit of Chef, which has all the details related to working units and can change the configuration.

What is Knife?

A knife is a command-line tool that interfaces between a chef Infra Server and local chef-repo.

Why is a cookbook important?

A cookbook is important because it allows us to dive into that culture and traditions while educating its readers about the importance and joy of cooking.

What is a cookbook in the programming context?

A cookbook in the context of programming means a collection of small programs depicting a particular programming concept.

Why is Chef used in DevOps?

In DevOps, Chef manages and deploys servers and applications in-house and on the cloud.

Conclusion

In this article, we discussed the overview of the Knife Cookbook site. We started by introducing the cookbook; then, we saw some arguments about the knife cookbook site. To learn more about Knife, check out our articles on


Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive ProgrammingJavaScriptSystem Design, etc. Enroll in our courses and refer to the mock test and problems available. Take a look at the interview experiences and interview bundle for placement preparations.

Happy learning, Ninja

Live masterclass