A Beginner’s Guide to Chef on CentOS 8
What is Chef?
Chef is an open-source configuration management DevOps tool used for configuration and management of multiple systems in infrastructure. Using Chef, we can use so-called recipes and cookbooks to automate and speed up managing multiple systems in our environment. By using Chef, we can adjust every system in our environment to our desired state, which we defined using the code in recipes. In the process, code is continuously tested and deployed using Chef.
It is worth noting that Chef is one of the tools used for configuration management. In a way, Chef is programming control of nodes in our environment. Some people would argue it is more inclined towards developers, whereas its competitor, Puppet, is more inclined towards system administrators. Read more about the comparison of configuration management tools (Ansible, Chef, SaltStack, and Puppet).
Recipes and Cookbooks
At the heart of Chef, we have recipes. A recipe is code written in Ruby, which consists of various configurations that we want to deploy. We can combine those recipes, along with other components such as attributes, files, libraries, etc., into building cookbooks (our workstations), which we can then deploy onto nodes.
A couple of advantages of Chef are the large support community and excellent online documentation. This assists users in finding widely available recipes since Chef is open-source software.
Knife is a command-line tool that enables communication (relay the contents of chef-repo) between recipes, cookbooks, and the Chef server. More importantly, Knife also allows us to manage nodes, cookbooks, environments, roles, data bags, resources, and the chef-client installation on the nodes.
The Chef setup consists of three main components that we want to manage:
- Chef workstation
- Chef Infra server
- Chef nodes
Inside the Chef workstation, we can create recipes and cookbooks to configure and manage our infrastructure. We can then upload those recipes and cookbooks onto the Infra server by using Knife.
The Chef Infra server is a “bridge” between the workstation and nodes. On the Infra server, which can be hosted locally or remotely, we can store recipes and cookbooks and deploy them on the nodes.
Chef nodes are hosts on the infrastructure that we want to configure and manage. Chef client service, which runs on the nodes, enables communication between the Chef Infra server and the nodes we want to deploy and manage.
In today’s example, we will cover installing Chef on CentOS 8. Before you proceed with it, ensure that you meet a few basic prerequisites:
- Enough system resources (check official system requirements)
- Make sure that network and firewall settings are in order.
- Enable NTP (Network Time Protocol) on your systems
How to Install the Chef Infra Server on CentOS 8
As a first step, we can navigate to our /tmp/ directory using the command.
After that, we can download the latest RPM package.
[root@chefserver tmp]# curl -O https://packages.chef.io/files/stable/chef-server/14.0.65/el/7/chef-server-core-14.0.65-1.el7.x86_64.rpm % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 241M 100 241M 0 0 840k 0 0:04:54 0:04:54 --:--:-- 767k
Alternatively, you can download the package from the website and then upload it to the system that will run Infra Server.
After the download is complete, we can install the RPM package with the following command.
[root@chefserver tmp]# rpm -Uvh chef-server-core-14.0.65-1.el7.x86_64.rpm warning: chef-server-core-14.0.65-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY Verifying... ################################# [100%] Preparing... ################################# [100%] Updating / installing... 1:chef-server-core-14.0.65-1.el7 ################################# [100%]
After the RPM installation is complete, we can make cookbooks available by running the reconfigure command.
[root@chefserver]# chef-server-ctl reconfigure Documentation: https://docs.chef.io/server_overview/ Patents: https://www.chef.io/patents +---------------------------------------------+ Chef License Acceptance Before you can continue, 3 product licenses must be accepted. View the license at https://www.chef.io/end-user-license-agreement/ Licenses that need accepting: * Chef Infra Server * Chef Infra Client * Chef InSpec Do you accept the 3 product licenses (yes/no)? > yes Running handlers: Running handlers complete Chef Infra Client finished, 410/878 resources updated in 03 minutes 22 seconds Chef Server Reconfigured!
Output for the reconfigure command can be quite large, so we have pasted only the product license acceptance prompt and the final output. Please note that running the reconfigure command can take several minutes to complete (as in our example), as resources have to be updated.
Additionally, chef-server-ctl is used to configure the Infra server, services, users, organizations, etc.
After the reconfigure command is done, we can use the following command to check the list of available software.
[root@chefserver]# chef-server-ctl service-list bookshelf* elasticsearch* nginx* oc_bifrost* oc_id* opscode-erchef* postgresql* redis_lb*
Create Admin User
The next step in the process is creating a Chef administrator/user. To do so, we can use the following command.
chef-server-ctl user-create USER_NAME FIRST_NAME LAST_NAME EMAIL 'PASSWORD' --filename FILE_NAME
In our example, we would input the information below.
root@chefserver]# chef-server-ctl user-create tom Thomas Janson email@example.com 'us3str0ngp4$$w0rd_!' --filename /home/tom/tjanson.pem
We can use the following sub-commands to manage our users.
user-create user-delete user-edit user-list user-show
After we've created the user, we can proceed with creating an organization with the following syntax.
sudo chef-server-ctl org-create short_name 'full_organization_name' --association_user user_name --filename ORGANIZATION-validator.pem
Information for our example is below.
[root@chefserver]# chef-server-ctl org-create liquidweb 'Liquid Web' --association_user tom --filename /home/tom/org-validator.pem
The syntax for sub-commands for managing your organization is similar to managing users.
In today’s article, we covered the theoretical basics of Chef and how to install the Chef on CentOS 8. We recommend going through Chef's official documentation and scrolling through our extensive Knowledge Base for more information and tutorials about Chef and many other related topics.
Contact us today at 1.800.580.4985 to speak to a knowledgeable Solutions Provider who can get you the info you need, to make an informed decision right away.
Too busy to talk? Click HERE to open a quick chat with us to find out more.
Want more info in an email you can review at your leisure? Email us today to get handy advice on which product would best suit your needs.
We look forward to hearing from you!
- How to Install Adminer MySQL Database Management Tool on AlmaLinux
- How to Edit the PHP Memory for Your WordPress Site via WP Toolkit
- 4 Methods for How to Install Yarn on Windows Server
- How to Install Bpytop Resource Monitoring Tool on AlmaLinux
- How to Fix “This Site Can’t Provide a Secure Connection” Error
- How to Install MongoDB on AlmaLinux
About the Author: Thomas Janson
Thomas Janson joined Liquid Web's Operations team in 2019. When he is not behind the keyboard, he enjoys reading books, financial statements, playing tennis, and spending time outdoors.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
How to Install Adminer MySQL Database Management Tool on AlmaLinuxRead Article
What is CGI-Bin and What Does it Do?Read Article
Top 10 Password Security StandardsRead Article
Top 10 Password Security StandardsRead Article
How to Use the WP Toolkit to Secure and Update WordPressRead Article