When you come in the world of infra/machine provisioning one of the big things that you hear talk about is Chef. In this article we will see what exactly is chef and how it works to make you provision your machines faster. Lets see what are chef server and how to work with chef?
What it can do?
Chef is a software using which you can turn your infrastructure into code which in return makes your Infrastructure becomes flexible, version-able, human-readable, and testable. With chef you can install, patch and do lot of stuff on a huge number of machines with really less time.
What are the components of chef?
Mainly chef has two components.
One is chef server and the other is chef client.
Chef server is the component which has all the data/info that is needed to provision the chef client.
With chef client you can understand your machine that needs to be provisioned with a chef-client program running on it. This client keeps checking if something needs to be installed and install it whenever it finds so.
Chef client keep checking your run list which is combination of cookbooks. And run those cookbooks which install the softwares or packages.
What are cookbooks and recipes?
These are infrastructure defined in code written in Ruby. You define what to install in these cookbooks and recipes. You can provision or change almost everything with these cookbooks. From linux file permissions to creating users and groups to managing server config. You can use them in any way possible. If you can do it by commands, you can do it by cookbooks.
How things work with chef?
You have a chef server running. When ever you want to launch a machine you start it and install chef-client which registers it to the chef server. Now you assign some recipe of role to this machine. The chef client on the machine will pick those recipes and install or provision things that are mentioned in that recipe or cookbook.
Now lets say you want to install a software in 5000 machines, you will attach the recipe for the software to the role which is common to all those machines. Now on the next chef-client run it will pick all the changes and will apply on all the machines.
Run a Chef Server.
Launch machines those needs to be provisioned via this chef server.
Install chef-clients on those machines.
Write cookbooks and recipes for your softwares of download from open source community. Chef maintains supermarket from where you can use them.
Create a run list which comprises of roles and recipes. Roles can be group of roles and recipes.
Chef client will run on machines and it will install the specified softwares.
Next time you want to make changes to the machine. You make change in the run list which is attached to the machine and it will be applied in the next chef client run.
If you want to learn more about chef. There official documentation is a great place to start. Also keep following my blogs for more such articles. We will read more about how to manage chef-servers in big infrastructure.