Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between 'knife cookbook create' and 'chef generate cookbook'?

Tags:

I'm struggling with the chef learning curve. What is the difference between these two commands, and why are there two of them ?

knife cookbook: The knife cookbook subcommand is used to interact with cookbooks that are located on the Chef server or the local chef-repo.

$ knife cookbook create a_knife_cookbook $ ls -a   CHANGELOG.md    README.md       attributes   definitions   files   libraries   metadata.rb   providers   recipes   resources   templates 

chef generate cookbook: The chef generate cookbook subcommand is used to generate a cookbook.

$ chef generate cookbook a_chef_cookbook $ ls -a   .gitignore   .kitchen.yml   Berksfile   README.md   chefignore   metadata.rb   recipes   spec   test 
like image 987
cbron Avatar asked Sep 16 '15 22:09

cbron


People also ask

What is a chef cookbook?

Cookbooks are fundamental working units of Chef, which consists of all the details related to working units, having the capability to modify configuration and the state of any system configured as a node on Chef infrastructure. Cookbooks can perform multiple tasks.

What is the difference between chef cookbook and recipe?

Cookbooks are a collection of recipes. Apart from recipes, cookbooks contain other elements like metadata, attributes, libraries, resources, templates, and tests which helps the nodes to achieve their desired state. Cookbooks can be created by Chef commands or by the Chef command-line tool called Knife.

What is knife in chef?

Knife is Chef's command-line tool to interact with the Chef server. One uses it for uploading cookbooks and managing other aspects of Chef. It provides an interface between the chefDK (Repo) on the local machine and the Chef server. It helps in managing − Chef nodes.


1 Answers

knife cookbook create is the legacy way to create a cookbook, it builds the structure of a cookbook with all possible directories.

chef generate cookbook is part of Chef-DK and aims at generating a testable cookbook structure with minimal directories to use in test-kitchen.

Both can be tweaked, the chef generate is easiest to tweak as the command has been written in this way to allow all to build the cookbook structure that better fits their needs.

like image 53
Tensibai Avatar answered Sep 28 '22 18:09

Tensibai