Install berkshelf in your chef workstation using the following command.
gem install berkshelf
Managing Existing Cookbooks:
2. Open the berksfile that is created inside your cookbook and mention all the dependencies .In our example , for powershell, windows and chef-handler cookbooks are the dependencies. So inside the powershell berksfile you can mention the dependencies in the following format.
3. Windows cookbook has a chef-handler dependency , but you dont have to mention it in the berksfile. It will automatically install the relevant chef-handler cookbook for the windows cookbook. You just have to mention the direct dependencies inside the berksfile.
5. By default , berksfile configures itself with the default knife.rb settings. You can check the config in ~/.berksfile/config.json .The config.json contains a validator ,chef url settings. You can override the default settings using the following command.
4. Once the dependencies are mentioned in a berksfile, you can install the dependencies using the following command.
Creating And Managing New Cookbooks With Berkshelf:
berks cookbook cookbook_name
2. Let say, you want to create a cookbook for your new php application. Apache2 , php and Msql will the dependencies for your phpapp. So you can mention the dependencies in the berksfile of the newly created cookbook using berkshelf.
site :opscode metadata
3.Install the dependencies using the berks install command. As explained earlier, the dependent cookbooks will get installed in ~/.berksfile/cookbooks folder.
In windows systems it get installed in C:UsersAdminstrator.berksfilecookbooks location
4. Once your cookbook is ready , you can upload the with all the dependent cookbooks using the following command.
berks upload phpapp
The above command will upload the phpapp cookbook and all the other dependent cookbooks from the berkshelf’s cookbook folder.
5. Ther are various other commands associated with berkshelf. It will be used in different use cases. The commands are given below.
berks apply ENVIRONMENT # Apply the cookbook version locks from Berksfi...
berks configure # Create a new Berkshelf configuration file
berks contingent COOKBOOK # List all cookbooks that depend on the given c...
berks cookbook NAME # Create a skeleton for a new cookbook
berks help [COMMAND] # Describe available commands or one specific c...
berks init [PATH] # Initialize Berkshelf in the given directory
berks install # Install the cookbooks specified in the Berksfile
berks list # List all cookbooks (and dependencies) specifi...
berks outdated [COOKBOOKS] # Show outdated cookbooks (from the community s...
berks package [COOKBOOK] # Package a cookbook (and dependencies) as a ta...
berks shelf SUBCOMMAND # Interact with the cookbook store
berks show [COOKBOOK] # Display name, author, copyright, and dependen...
berks update [COOKBOOKS] # Update the cookbooks (and dependencies) speci...
berks upload [COOKBOOKS] # Upload the cookbook specified in the Berksfil...
berks version # Display version and copyright information
For more information, visit the official berkshelf site Berkshelf.com