Welcome to today’s guide on how to install Chef Server and Workstation on Ubuntu 20.04 (Focal Fossa). Chef is a powerful automation solution designed to help you transform your infrastructure into a code. The Infrastructure can be on-premise, Cloud, or a hybrid environment. With Chef, you automate how the infrastructure is deployed, configured, and managed. The Chef server acts as a central repository for your cookbooks as well as for information about every node it manages.

The company behind Chef automation server has worked on other automation tools which are:

  1. Chef – For Infrastructure Automation
  2. Habitat – Application automation
  3. INSPEC – Compliance Automation

Follow the steps in the next sections below to install and configure Chef Server on Ubuntu 20.04 Linux server.

Step 1: Update system and set hostname

We need to update our system to ensure all installed packages are latest releases.

sudo apt update
sudo apt -y upgrade

Set server hostname that will be the DNS name of your Chef Server deployed on Ubuntu 20.04.

sudo hostnamectl set-hostname chef-server.computingforgeeks.com

If you have an active DNS server, set the A record accordingly. For installations without DNSserver, set the record on /etc/hosts file:

192.168.200.10 chef-server.example.com

Also install some other basic packages on your Ubuntu machine.

sudo apt -y install curl wget bash-completion

After installing these packages and upgrading your machine I recommend you perform a reboot.

sudo reboot

Step 2: Configure Local Mail Relay

The Chef server uses email to send notifications for various events:

  • Password resets
  • User invitations
  • Failover notifications
  • Failed job notifications

Configure a local mail transfer agent on the Chef server using the guide:

Install and configure Postfix as a Send-Only SMTP Server on Ubuntu

Step 3: Configure NTP

The Chef server is particularly sensitive to clock drift and it requires that the systems on which it is running be connected to Network Time Protocol (NTP).

Install chrony package on Ubuntu 20.04.

sudo apt -y install chrony

Set correct timezone for date to be picked automatically.

sudo timedatectl set-timezone Africa/Nairobi

You can choose to restrict access to NTP server, e.g from your Chef client nodes, set like below:

restrict 192.168.18.0 mask 255.255.255.0 nomodify notrap
<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/07/echo/chef-server-set-ntp-min-1024×313.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

Where 192.168.18.0 is the IP subnet of your local network. Restart ntp service after making the change:

sudo systemctl restart chrony

If you have UFW firewall enabled, don’t forget to allow ntp port:

sudo ufw allow ntp

Show ntp status:

sudo chronyc sources

Confirm time synchronization:

$ timedatectl
               Local time: Fri 2020-07-10 20:38:57 EAT
           Universal time: Fri 2020-07-10 17:38:57 UTC
                 RTC time: Fri 2020-07-10 17:38:58
                Time zone: Africa/Nairobi (EAT,  0300)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

On Chef clients, install ntp and set NTP server to Chef server IP address

sudo apt install chrony
sudo vim /etc/ntp.conf

Uncomment NTP pool server lines and specify Chef server IP address

#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst

server  192.168.18.39

Step 4: Download and install Chef server package

First, check the latest version of Chef server from Chef Downloads page

As of this writing, the recent release is version 13.2.0. This is the package we will download and install:

VERSION="13.2.0"
wget https://packages.chef.io/files/stable/chef-server/${VERSION}/ubuntu/18.04/chef-server-core_${VERSION}-1_amd64.deb

Once the download is complete, install the package using dpkg command:

sudo apt install ./chef-server-core_${VERSION}-1_amd64.deb

Sample status:

....
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'chef-server-core' instead of './chef-server-core_13.2.0-1_amd64.deb'
The following NEW packages will be installed:
  chef-server-core
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/381 MB of archives.
After this operation, 1,262 MB of additional disk space will be used.
Get:1 /root/chef-server-core_13.2.0-1_amd64.deb chef-server-core amd64 13.2.0-1 [381 MB]
Selecting previously unselected package chef-server-core.
(Reading database ... 28284 files and directories currently installed.)
Preparing to unpack .../chef-server-core_13.2.0-1_amd64.deb ...
Unpacking chef-server-core (13.2.0-1) ...
Setting up chef-server-core (13.2.0-1) ...

Wait for the installation to complete then configure Chef Server:

sudo chef-server-ctl reconfigure

Before the configuration is started you need to accept license agreement.

....
Before you can continue, 3 product licenses
must be accepted. View the license at
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 Persisting 3 product licenses... ✔ 3 product licenses persisted. ---------------------------------------------

Create an administrator account

The format is:

sudo chef-server-ctl user-create USER_NAME FIRST_NAME LAST_NAME EMAIL 'PASSWORD' --filename FILE_NAME
  • An RSA private key is generated automatically.
  • This is the user’s private key and should be saved to a safe location.
  • The option--filename will save the RSA private key to the specified absolute path.

Example:

sudo chef-server-ctl user-create chefadmin Chef Admin 
  [email protected] 'StrongPassword' 
  --filename /home/chefadmin.pem

Also, create an organization. The syntax is:

sudo chef-server-ctl org-create short_name 'full_organization_name' --association_user user_name --filename ORGANIZATION-validator.pem
  • The name must begin with a lower-case letter or digit,
  • The full name must begin with a non-white space character
  • The --association_user option will associate the user_name with the admins security group on the Chef server.
  • An RSA private key is generated automatically. This is the chef-validator key and should be saved to a safe location.
  • The --filename option will save the RSA private key to the specified absolute path.

See example below:

chef-server-ctl org-create mycompany 'Company X, Inc.' 
  --association_user chefadmin 
  --filename /home/mycompany-validator.pem

Generated keys should be available on /home directory

# ls /home/
chefadmin.pem  mycompany-validator.pem

Install Chef Manage

Chef Manage is a premium add-on that provides a graphical user interface for managing common Chef server tasks. It’s free for up to 25 nodes.

Let’s install the management console:

sudo chef-server-ctl install chef-manage 
sudo chef-server-ctl reconfigure 
sudo chef-manage-ctl reconfigure

You can also install Chef Manage from a .deb package:

VER="3.0.11"
wget https://packages.chef.io/files/stable/chef-manage/${VER}/ubuntu/18.04/chef-manage_${VER}-1_amd64.deb
sudo dpkg -i chef-manage_${VER}-1_amd64.deb
sudo chef-manage-ctl reconfigure

All Chef Server services will run under the username/group opscode. The username for PostgreSQL is opscode-pgsql. Additional packages can be installed from https://packages.chef.io/

If you wish to use or already using UFW firewall, open ports 80 & 443 by running the commands below:

sudo ufw allow proto tcp from any to any port 80,443

You should be able to access the Chef web admin dashboard on https://serverip/login

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/07/echo/chef-server-login-admin-page-min-1024×413.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

Login with username added earlier. A fresh Chef dashboard should be similar to below

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/07/echo/chef-server-admin-dashboard-min-1024×427.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" src="data:image/svg xml,”>

Step 5: Install Chef Development Kit on your Workstation machine

Chef Workstation is where you have Chef development Kit installed. It contains all the tools you need to develop and test your infrastructure, built by the awesome Chef community. Install Chef Development Kit / Workstation using the guides below:

How to install Chef Development Kit / Workstation on Ubuntu

For Arch Linux users, use:

How to install Chef Development Kit on Arch Linux

Step 7: Configure knife on Chef Workstation

Knife is the command-line tool that provides an interface between your workstation and the Chef server.  Next read:

How to configure Chef Knife, Upload Cookbooks and Run a recipe on Chef Client Nodes