Visual Studio Code Configuration
- Install Chef Extension into Visual Studio Code.
Automating Deployments using Chef
- Ensure you have manual steps/commands for whatever you want to automate.
- Chef Organizes declarative syntaxes into
Chefs Basic Workflow for cookbook automation
Scenario-1: Install Git and tree
- Manual Execution (Ubuntu):
sudo apt-get update sudo apt-get install git -y sudo apt-get install tree -y
- Manual Execution (RedHat):
sudo yum install git -y sudo yum install tree -y
- Creating a cookbook. For creating cookbook as part of chef dk installation, we get generators. Lets use cookbook generator
cd <starterkit-folder>\cookbooks\ chef generate --help # since we want to generate cookbook chef generate cookbook --help # generate a cookbook called exercise1 chef generate cookbook exercise1 -b
- Observe the folder structure of exercise1 and you should be able to see default.rb in recipes folder which is default recipe.
- Refer Here for Chef Resources
- Basic Resource syntax is
<resource type> '<name of resource>' do property1 value1 .. .. propertyn valuen action <some actions> end
- Upload the cookbook. Uploading the cookbook in this case will be done using a tool called berkshelf (berks).
cd <starterkit>\cookbooks\<cookbook> berks install berks upload
- Applying cookbook to node. In chef every node will have list of recipes to be executed. This list is called as run_list. Go to your node and change the run_list and add your recipe.
- Once recipes are added to run list wait for Convergence. In this lets manually force Convergence. Login into node and execute