Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use knife to create a new recipe in a cookbook

I've used knife solo to create a new folder and a cookbook with a default recipe using a custom template defined by .chef/knife.rb. My question is what command do I use for knife to create new recipes with that template instead of using cp?

Something like knife cookbook addrecipe somerecipe

like image 564
John Wyatt Avatar asked Oct 03 '13 00:10

John Wyatt


People also ask

What can I do with the knife cookbook?

Using the knife cookbook sub-command, you can perform all kinds of operations on your cookbooks including create, delete, upload, lock, view, etc. To create a new Chef cookbook, refer to this: 12 Chef Knife Cookbook Command Examples

How do I create a new cookbook in chef?

To create a new Chef cookbook, refer to this: 12 Chef Knife Cookbook Command Examples To upload a single cookbook, use the following syntax: Using knife cookbook sub-command, the following will upload a cookbook to the Chef server.

How to create a cookbook using knife in Linux?

To create a cookbook, use “knife cookbook create” command as shown below. The following will create a cookbook with name thegeekstuff. For the above command, knife command creates a separate directory called “thegeekstuff” under ~/chef-repo/cookbooks as shown below. The following is the cookbook folder structure. 2.

What is a cookbook in chef?

Chef - Cookbooks. 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. Cookbooks contain values about the desired state of node.


2 Answers

You can use chef rather than knife for recipe creation.

chef generate recipe cookbooks/test_cookbook new_recipe

Compiling Cookbooks...Recipe: code_generator::recipe[...]    
- create new file cookbooks/test_cookbook new_recipe.rb    
- update content in file cookbooks/test_cookbook new_recipe.rb from none to 8602b0    (diff output suppressed by config)
like image 112
Yonkee Avatar answered Oct 08 '22 22:10

Yonkee


once you have the cookbook created, then there will be recipe folder inside the cookbook . you can go on writing as many recipes as you want inside the recipes folder. AFAIK, knife cookbook does not provide any option for creating a new recipe. check knife cookbook --help

like image 38
slayedbylucifer Avatar answered Oct 08 '22 22:10

slayedbylucifer