Table of contents
1.
Introduction
1.1.
About Chef Workstation
2.
Supported Operating Systems
3.
System Requirements
4.
Installation of the Chef Workstation
4.1.
For macOS
4.2.
For Windows
4.3.
For Linux
5.
Verify the Installation
6.
Setting Up the Chef Workstation
7.
Configuration of Ruby Environment
8.
Setting Up the Chef Repo
9.
Setting up the Chef Credentials
10.
Verifying the Client-to-Server Communication
11.
Frequently Asked Questions
11.1.
Does Chef have a GUI?
11.2.
What do you understand by a node in Chef?
11.3.
What is an attribute in Chef?
11.4.
Is Chef free to use?
11.5.
Is Chef based on Ruby?
12.
Conclusion
Last Updated: Mar 27, 2024
Medium

Installation & Setup of Chef Workstation

Author Amit Singh
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Have you ever used any software or tool to automate the management of the servers and network equipment in your organization?

logo

This article focuses on one of the automation software, which is called Chef. We will also study the installation of the Chef Workstation. Then we will study how we can configure it.

Let’s see what it is in more detail.

About Chef Workstation

logo

Chef Workstation comes with everything you need to get started with Chef in a simple one-click installation and to start delivering infrastructure automation without the need to set up any other software, such as a Chef client or Chef server. The ideal tool for brand-new users to begin using Chef is Chef Workstation.

A variety of resources, helpers, and testing tools are included in Chef Workstation, the new developer toolkit from Chef that makes it simpler than ever to automate infrastructure, application, and security testing. DevOps automators can generate, test, and deliver the codified artifacts all from within their preferred development environment with Chef Workstation.

Chef Workstation comes with:

  • Chef Infra Client,
     
  • Chef Habitat,
     
  • Chef InSpec,
     
  • Testing tools such as Test Kitchen and Cook style,
     
  • chef and knife command line tools,
     
  • Everything else which is required to author cookbooks and upload these cookbooks to the Chef Infra Server.
     

Now, let’s see which Operating Systems are supported by Chef Workstation:

Supported Operating Systems

plug

Here is the list of supported Host Operating Systems:

Platform Version
Amazon Linux 2
Apple macOS 10.15, 11, 12
Windows 10, 11, Server 2012, Server 2012 R2, Server 2016, Server 2019, Server 2022
Red Hat Enterprise Linux / CentOS 7.x, 8.x
Ubuntu 16.04, 18.04, 20.04
Debian 9, 10, 11

 

System Requirements

img01

Let’s check out the minimum system requirements:

  • RAM: 4GB,
     
  • Disk: 8GB
     
  • Additional memory and storage space may be required if you want to take advantage of the Chef Workstation tools like Test Kitchen, which helps in the creation and management of virtualized test environments

Installation of the Chef Workstation

ask

The Chef Workstation installer must run as a privileged user.

Chef Workstation installs to /opt/chef-workstation/ on macOS / Linux and C:\opscode\chef-workstation\ on Windows. These file locations help avoid interference between these components and other applications that may be running on the target machine.

For macOS

mac

If you want to install the Chef Workstation and you have a macOS-supported device, you can follow these steps:

  1. We will start by going to the Chef Workstation downloads page. Then select the appropriate package depending on your macOS version. Click on the Download button.
     
  2. Then follow the steps to accept the license and install the Chef Workstation.
     

You can also install Chef Workstation using the package manager known as Homebrew using the following command:

brew install --cask chef-workstation

 

After macOS, let’s move on to Windows OS.

For Windows

windows

If you want to install the Chef Workstation and you have a Windows-supported device, you can follow these steps:

  • We will start by going to the Chef Workstation downloads page. Then select the appropriate package depending on your macOS version. Click on the Download button.
     
  • Then follow the steps so that you can accept the license and install the Chef Workstation. You also have an option that will allow you to change your installation location. By default, the installer uses the following directory: 
C:\opscode\chef-workstation\ directory.

 

  • The last step is totally Optional. If you are using Windows Operating System, it is recommended very strongly that you use Windows PowerShell instead of a command prompt or cmd.exe.
     

You can also install the Chef Workstation using the package manager known as Chocolatey:

choco install chef-workstation

 

Now, let’s see how you can install Chef Workstation in Linux.

For Linux

linux

If you want to install the Chef Workstation and you have a Windows-supported device, you can follow these steps:

  1. We will start by going to the Chef Workstation downloads page. Then select the appropriate package depending on your distribution (Red Hat Enterprise Linux or Debian/Ubuntu). Click on the Download button.
     
  2. After the download, you can use your distribution’s package manager for the installation of Chef Workstation:
     

Red Hat Enterprise Linux:

yum localinstall chef-workstation-21.10.640-1.el8.x86_64.rpm

 

Debian/Ubuntu:

dpkg -i chef-workstation_21.10.640-1_amd64.deb

 

After the installation, let’s see how we can verify whether the Chef Workstation is appropriately installed or not.

Verify the Installation

We can verify the installation of the Chef Workstation by using this command:

chef -v

 

This command will return the versions of all the Chef tools that are installed in your system.

After the installation of the Chef Workstation, let’s move on to the setup.

Setting Up the Chef Workstation

chef

Before we start setting up, please keep in mind that:

  • You have already installed the Chef Workstation.
     
  • An instance of Hosted Chef Server or Chef Infra Server is running.
     
  • You have the CLIENT.PEM file provided by your Chef administrator, unless you’re using Chef Manage or Hosted Chef.
     

If all have already completed the above-mentioned steps, let’s move on to the real deal.

Configuration of Ruby Environment

configuration

Ruby is frequently used by users to create Chef policies (for example, cookbooks, Policyfiles, and Chef InSpec profiles). If you find that to be the case, we advise setting the Chef Workstation Ruby as your default system Ruby. 

If you are using Windows, Chef Workstation already includes a desktop shortcut to your PowerShell prompt that is already configured for usage.

But if you are using macOS or any Linux distro, you will need to:

  • Determine the default shell in your PC.
     
  • Then add the initialization content of the Workstation to the shell. 
     
  • After that, open a shell window and try running:
     
which ruby


After this, let’s move on to the setup of the Chef Repo.

Setting Up the Chef Repo

imag01

A Chef Infra repository is necessary if you’re setting up Chef for the first time in your company to save your cookbooks and other tasks.

The chef-repo is actually a directory on your Workstation. Everything you need to define your infrastructure using Chef Infra is stored in the chef-repo, for instance:

  • Cookbooks (including recipes, custom resources, attributes, libraries, as well as templates),
     
  • Data Bags, and
     
  • Policyfiles.
     

It is recommended to synchronize the chef-repo directory with a version control program like git. The chef-repo should be treated exactly like the source code.

The chef and knife commands will be used to upload data from the chef-repo directory to the Chef Infra Server. After it has been uploaded, the Chef Infra Client makes use of that information to manage the nodes that have been registered with the Chef Infra Server and to make sure that the correct cookbooks, policyfiles, and settings are applied to the correct nodes in the proper sequence.

Setting up the Chef Credentials

authorized

When you launch the Chef Workstation software for the first time, a .chef directory is created in your user directory. You will keep your Chef Workstation settings and client keys in this .chef directory.

The Chef Infra Server CLI or the Manage UI must be used to manage users if you’re configuring Chef Workstation as an administrator of the Chef Infra Server. A user-specific RSA client key is generated when a new user is created; you must safely communicate this key with the new user.

You must configure your specific client private key, which your server administrator will provide for you and correlate to a client on the Chef Infra Server if you’re installing Chef Workstation as a Chef user. The client private key is a .pem formatted RSA private key.

After this, let’s move on to the final step, i.e., verifying the client-to-server communication.

Verifying the Client-to-Server Communication

protect

After the configuration, if you want to verify if your Chef is able to connect to the Chef Infra Server or not.

For the verification, you can just run the below command on your command line:

knife client list

 

This command will return a list of clients like,

chef_machine
registered_node

 

Also, if the Chef Infra Server you are currently using has a self-signed certification, you can use the following subcommand to download the Chef Infra Server TLS/SSL certificate:

knife ssl fetch

 

You can save that certification in your .chef/trusted_certs

Frequently Asked Questions

Does Chef have a GUI?

Chef is actually written in Ruby and Erlang, and it uses a pure-Ruby DSL in the Knife CLI. It also includes a nice GUI for easy management.

What do you understand by a node in Chef?

A node can be understood as any machine that is currently being managed by the Chef server. It can be attached to any network that can send and receive information.

What is an attribute in Chef?

An attribute is a piece of basic information about a specific node. It basically shows the state of the node.

Is Chef free to use?

Chef is actually an open-source configuration management tool which is developed by Opscode. Chef is actually available for free, but there are also paid versions, such as Chef Enterprise.

Is Chef based on Ruby?

Chef uses a Ruby-based domain-specific language, which is usually abbreviated as “DSL.”

Conclusion

In this article, we have studied Installation as well as the setup of the Chef Workstation in detail. 

We hope that this article has provided you with the help to enhance your knowledge regarding Chef Workstation and if you would like to learn more, check out our articles on chef migration and Chef Desktop.

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enroll in our courses and refer to the mock test and problems available; take a look at the interview experiences and interview bundle for placement preparations.

Do upvote our blog to help other ninjas grow.

Merry Learning!

 

Live masterclass