CHAPTER 2

image

The Chef Server

This chapter covers Chef server and its components in detail. First we cover the different types of chef servers and then move on to discuss the components of the open source chef server.

The Chef Server

The chef server is the server component of the Opscode chef tool. The server is a centralized location where data related to chef is stored.

The data that is stored on the server includes cookbooks, node objects, and any policy that needs to be applied on any node. Each node registered with the chef server has an agent known as chef client installed on it. The agent contacts the chef servers and pulls the configuration that needs to be applied on the node. The chef client is responsible for execution of the actual code on the node. Chef is a thick client architecture tool that enables the client to do the heavy lifting. Due to this approach the effort is distributed throughout the infrastructure nodes and not on a single server.

Types of Chef Server

Chef servers can be classified into three types.

  1. Hosted enterprise chef
  2. Enterprise chef
  3. Open source chef server

Hosted Enterprise Chef

This type of chef server is a paid version and is offered as a service. As the name suggests, it is a cloud-based, highly available, and scalable version of chef. It has all the capability of chef and one can just sign up to use it. It has to be accessed via the Internet. Thus, a hosted enterprise chef is a great way for enterprises to leverage a fully supported and hosted version, such as cloud computing, for their applications. The managed offering frees the enterprise to focus its efforts on its core applications rather than installing, configuring, and managing chef.

Enterprise Chef

This version of chef is the same as the hosted version. The only difference between them is that this one needs to be installed in the enterprise data centers and is not available as a hosted and managed offering.

In terms of technical capabilities, it is the same as the hosted version. It also has dedicated support directly from chef and features such as RBAC (Role-Based Access Control), built-in support for high availability, and so on.

Open Source Chef Server

This is a free version of the chef server which has many of the capabilities of the enterprise version but also some limitations. It does not include support directly from chef but has support from the chef community. The customer needs to manage the chef instances. High availability and scalability are not offered out of the box. Any data migration or patching also needs to be done by the user.

Extra Functionalities in Enterprise Chef

Enterprise chef has all the functionalities of the open source chef server along with the following features:

  • Improved RBAC: Enterprise chef comes with built-in RBAC, which is used to configure fine-grained permissions for users. This is an important requirement for any automation tool from a security perspective.
  • Built-in support for high availability: Enterprise chef comes with multiple installation options. The enterprise version of chef can be installed in a stand-alone mode and also in a high-availability mode. High availability can be a key requirement for some of the enterprises.
  • Push client jobs: The server can push the configuration to a client node in enterprise chef. In open source chef server the chef client needs to pull the data.
  • Improved management console for ease of administration.
  • Monitoring and reporting: Reporting and monitoring features are enhanced in enterprise chef; while in open source we have minimal monitoring and reporting.
  • Support directly from chef: It has support directly from chef.

Components of Open Source Chef Server

The previous versions of chef were written in Ruby. Chef 11 was released in early 2013. One of the major changes was that the API (application programming interface) server was written in Erlang.

Erlang is a functional programming language that has many good features, like fault tolerance, concurrency, and high scalability, and it can also work in distributed environments. Due to the massive scalable nature of Erlang, it is used in telecom software and other high-performance real-time systems.

Due to this change and leveraging the Erlang language, this version of chef is more scalable and provides higher performance.

Figure 2-1 shows the various components that are part of a chef server and how they are connected to one another.

9781430262954_Fig02-01.jpg

Figure 2-1. Working of the chef server

Nginx

Nginx is a popular open source http server and reverse proxy. Nginx is a high-performance http server which can handle heavy workload websites.

Nginx is leveraged by chef as the http server and every request that comes to the chef server is routed to Nginx. Then, Nginx forwards the request based on the type of request. If it’s a cookbook-related–request then it is forwarded to Bookshelf. Bookshelf then forwards the request to Erchef, and it is handled accordingly. Any request coming is finally handled by Erchef.

Bookshelf

Bookshelf is a component of chef which holds the cookbooks in the chef server. All cookbooks that are uploaded to the chef server are stored in Bookshelf. The cookbook contains different types of files, from templates to recipes, and so on. Bookshelf also maintains different versions of the cookbooks.

The content in Bookshelf is stored using the checksum; the files are updated only if the checksum changes. Bookshelf uses flat files to store the content and the content is separate from the search index repositories.

Figure 2-2 shows how cookbooks are typically stored in the cookbook content. The path where these files are located is/var/opt/chef-server/bookshelf/data/bookshelf/.

9781430262954_Fig02-02.jpg

Figure 2-2. How cookbook files are stored

WebUI

The web interface of the chef server is a Ruby on Rails 3.0 application.

Figure 2-3 shows the web interface of a chef server. This is the screen that appears when you open the web interface for the first time.

Web UI provides the graphical interface for the administrator and users to work with the chef tool.

9781430262954_Fig02-03.jpg

Figure 2-3. Web interface of the chef server

Erchef

The core API of the chef server is written in Erlang and is known as Erchef. As it is written in Erlang it is much faster compared to its previous versions. The previous versions were written in Ruby. This version is also compatible with the previous version of the server. The cookbooks that were written for the previous versions will work in this version also.

The new version provides higher performance and scalability and it was one of the reasons for rewrite of the API server using Erlang.

Message Queue

Chef uses RabbitMQ for queueing the messages. RabbitMQ is one of the leading open source message queueing platforms. The messages that are received by the chef server are sent to the search index using the Message Queue.

All the messages are added to a queue; the chef expander pulls these messages from the RabbitMQ queue, changes them to the required format, and then sends them to the chef solr for indexing. Chef solr is a search engine which exposes its Rest API for indexing.

By using message queues, high workloads can be handled through the queue mechanism and then eventually indexed and made available through the index.

Chef Solr

Chef Solr is the search engine in chef. It wraps Apache solr and exposes its REST API for searching and indexing. Apache solr is an open source search platform that provides search capabilities with features like dynamic clustering and integrations with databases. It is fault tolerant and highly reliable. Solr is written in Java and runs as a stand-alone full-text search server within a servlet container such as Jetty. Solr uses the Lucene Java search library at its core for full-text indexing and search, and it has REST-like HTTP/XML and JSON (JavaScript Object Notation) APIs that make it easy to use from virtually any programming language. Solr’s powerful external configuration allows it to be tailored to almost any type of application without Java coding, and it has an extensive plug-in architecture when more advanced customization is required.

Postgresql

Postgresql is a leading open source RDBMS (relational database management system). This forms the database for the chef tool.

Postgresql is used to store the data related to the chef server. The current version of chef uses postgresql version 9.2.x. By default, chef creates a database named Opscode_Chef. Figure 2-4 shows the structure of the database.

9781430262954_Fig02-04.jpg

Figure 2-4. Structure of database

Ports

Table 2-1 shows the list of ports that the chef server utilizes.

Table 2-1. Ports Used by Chef

Service

Port Used

Erchef

8000

ChefServer-WebUI

9462

Postgresql

5432

RabbitMQ

5672

Chef Solr

8983

Bookshelf

4321

Nginx

443/80

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset