Configuration Mangement(CM) in Chef
- To do CM ensure (Are aware of manual way)
- You are aware of all the prerequisite softwares to be installed.
- You have a list of commands to be executed to deploy the application
Hello-World Chef Scenario
-
As of now we have a Lab setup
-
Now Scenario is
- We want all of our chef-client nodes to have the following softwares installed
- tree
- git
- elinks
- We want all of our chef-client nodes to have the following softwares installed
-
Commands for installing the above on
- Ubuntu:
sudo apt-get update sudo apt-get install git -y sudo apt-get install tree -y sudo apt-get install elinks -y- Centos:
sudo yum install git -y sudo yum install tree -y sudo yum install elinks -y -
To develop cookbooks we will be using visual studio code
-
Workflow to be followed in Chef:
- Generate a cookbook if required or else use the existing cookbook
- Generate a recipe or use the existing recipe
- Find a chef resource for every linux command you have noted (as above)
- Test whether the recipe (or the changes) are working or not
- upload the Cookbook to Chef Infra Server
- make changes if necessary to the run list of the nodes and wait for convergance
-
How to realize the above workflow
- To generate a cookbook, when we install chefdk on workstation we get generators and we can generate using command. Navigate to chef-repo and with in chef-repo you have cookbooks folder cd into that
cd C:\DevOps\Chef\Apr20\chef-starter\chef-repo\cookbooks chef generate --help chef generate cookbook --help chef generate cookbook helloworld -b-
To generate a recipe in the cookbook use the command
chef generate recipe --help. But in this scenario, i will be using a default recipe called as default.rb already generated with cookbook 