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
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
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.
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.
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.
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)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With