Chef is a powerful automation platform that transforms infrastructure into code. Whether you’re operating in the cloud, on-premises, or in a hybrid environment, it automates and manages the infrastructure, across your network, no matter its size.
Chef is useful for a wide variety of infrastructure setups, whether you are managing Linux web hosting environments, Data Centres with a fleet of servers or a web hosting company which would like to automate the task of configuring servers ready for deployment.
The below diagram shows how you develop, test, and deploy your Chef code:
Flavors of chef:
- Open Source Chef: The Open Source version of Chef is freely available to all, to manage and deploy. It means that you have to download and deploy chef on your own infrastructure, all yours to manage and to maintain.
- Hosted Chef: The hosted chef is hosted in chef cloud. In hosted chef, you only worry about the configuration of recipes and nodes, rather than deployment of chef. You simply upload the cookbooks and Chef does the rest.It requires a subscription fee and support contract, but allows up to 5 nodes for free.
- Private Chef:For deploying and managing own IT infra, in your own premises. Allows up to 25 nodes for free. Unlike Open Source Chef, you get all the features and functionalities like hosted chef, but in your own infrastructure.
The Chef ecosystem:
It allows the administrator to interact with the chef server and manage the infrastructure. The workstation is your local machine which you use to write the cookbooks and upload them to the chef server.
1.1 Knife: It is a tool to interact with the chef server. It is used to manage roles, cookbooks, nodes, data bags, index, recipes and environments on the chef server.
Here are few examples of the Knife command:
# knife cookbook create Znetlive
The above command creates a cookbook called Znetlive in your workstation with all the necessary files and configurations.
Now, the cookbook is all yours to play with. Create your recipes, cook something good. When it smells good, use the command below 😉
# knife cookbook upload Znetlive
1.2 Chef Repository: While we talk about chef repositories, it is something we already know, don’t we? Yes, it is same as GitHub repositories or any other code repository. In simple terms, repository is a directory where you put all your code. You can manage all your chef repos in the same manner using GitHub, Gitlab, SVN etc.
2. Chef Server:
It is the main component of the chef ecosystem and stores the policies and other configuration/ node details. The database Postgres SQL is used on the chef server.
Below are the components of chef server:
- 2.1 ER Chef: Written in Erlang, it handles the API requests on the chef server.
- 2.2 Web UI: It is the Graphical Management Console used to manage the chef nodes, permissions, cookbooks and assignment of cookbooks to nodes. It is written in Ruby on Rails. Not to worry, as we will not be writing code in ruby for now, though it is a great skill to have.
- 2.3 Nginx: Nginx is the front End load balancer to the chef server. Any requests through the API first interacts with the Nginx.
- 2.4 Message Queues: Message Queues are used to send messages to search index of the chef server using the following:
- 2.4.1 Rabbit MQ: Open Source Middleware based on Advance Message Queueing Protocol (AMQ). Click here to learn more about Rabbit MQ.
- 2.4.2 Chef Expander: Pulls messages from Rabbit MQ and once it is processed and formatted, it forwards the message to Chef Solr.
- 2.4.3 Chef Solr: Indexes and Searches these messages. It is based on Apache Solr (the open source search indexing platform). Solr acts as a wrapper for indexing and searching using REST APIs.
- 2.5 Search Index: It stores the messages in the indexed format, with the nodes information in the textual format.
- 2.6 Postgres SQL Database: The Relational Database is used to store information on configurations, environments, roles, data bags, node attributes. It is basically a data storage repository.
- 2.7 Bookshelf: Stores all the cookbooks that are uploaded via the workstation.
- 2.8 Cookbooks: They store everything about our infrastructure in the form of code.
- 2.9 Node Objects: It is JSON file stored on the chef server, containing run lists and attributes.
- 2.9.1 Run Lists: Contains recipes and roles and executes in the same order as specified in the run list. Many nodes might contain the same run list.
- 2.9.2 Attributes: It describes the specific piece of data on the node like which packages to install or update, or services to be running on a node.
- 2.10 Policies: It defines roles and environment settings for the nodes.
The nodes are simply your servers in the chef network which use the chef server to update their configurations and changes as directed by it.
These servers can be cloud servers, VPS or dedicated servers.
Below are the components:
- 3.1 Chef Client: It is installed on every chef node which acts as an agent to interact with the chef server and fetch cookbook and configuration. It registers the node to the chef server and checks periodically for the configuration data.
- 3.2 OHAI: Transmits basic node information like CPU, RAM, OS details to the chef server.
Phhew…!! I know it is a lot to take in at once. Just sit back, relax and go through the points once again. I know what are you thinking right now. Is chef suitable for me? Should I adopt this technology? etc. etc.
Well, the ability to turn your infrastructure into code and fine control over your automation is what chef provides and if you would like to control your infrastructure at code level, this is for you. No matter, whether you are managing a Linux or Windows hosting environment, you can automate using chef.
If you are an engineer/ sysadmin, you can learn this to boost your DevOps skills. Automation is something which is changing the industry right now and faster you learn, longer you can survive in this information age. So, go ahead and give it a try.
So, one thing now remains. Go ahead and install Chef. If you face any issue, ask through the below comment section.
Services ZNetLive offer:
Suhash Chand, a system admin-Linux, is a AWS-SAA, RHCSA, RHCE, RHCVA, RHEx-236 certified professional, handling Linux systems’ administration and Cloud Consultancy. In his free time, Subash loves listening to theme music.