Install Chef Server & Workstation on Ubuntu 20.04

The
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
The

The
The

Welcome to today’s guide to learn how to install Chef Server and Workstation on Ubuntu 20.04 (Focal Fossa). Chef is a powerful automation solution designed to help you turn your infrastructure into code. The infrastructure can be local, cloud or hybrid environment. With Chef, you can automate how to deploy, configure, and manage infrastructure. The Chef server acts as a central repository of your recipes and information about each node it manages.

The company behind the Chef automation server has developed other automation tools, including:

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

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

Step 1: Update the system and set the host name

We need to update our system to ensure that all installed packages are the latest version.

sudo apt update
sudo apt -y upgrade

Set the server hostname, which will be the DNS name of the 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 a DNS server, please set records in the following location /etc/hosts file:

192.168.200.10 chef-server.example.com

Also install some other basic packages on the Ubuntu machine.

sudo apt -y install curl wget bash-completion

After installing these packages and upgrading the computer, it is recommended that you restart.

sudo reboot

Step 2: Configure local mail relay

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

  • reset Password
  • User invitation
  • Failover notification
  • Job notification failed

Use the following guidelines to configure a local mail transfer agent on the Chef server:

Install Postfix on Ubuntu and configure it to send only SMTP server

Step 3: Configure NTP

The Chef server is particularly sensitive to clock drift. It requires that the system on which it runs is connected to the Network Time Protocol (NTP).

Install the chrony package on Ubuntu 20.04.

sudo apt -y install chrony

Set the correct time zone for the date to be automatically selected.

sudo timedatectl set-timezone Africa/Nairobi

You can choose to restrict access to the NTP server, for example from the Chef client node, as shown below:

restrict 192.168.18.0 mask 255.255.255.0 nomodify notrap

Where 192.168.18.0 is the IP subnet of your local network. After making changes, restart the ntp service:

sudo systemctl restart chrony

if you have UFW With the firewall enabled, don’t forget to allow the ntp port:

sudo ufw allow ntp

Display 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 the Chef client, install ntp and set the NTP server to the Chef server IP address

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

Uncomment the NTP pool server line and specify the 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 the Chef server software package

First, check the latest version of the Chef server from it Chef download page

At the time of writing, the latest version is 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

After the download is complete, use 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, and then configure Chef Server:

sudo chef-server-ctl reconfigure

Before starting the configuration, you need to accept the 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
  • The RSA private key will be automatically generated.
  • This is the user’s private key and should be kept in a safe place.
  • Options--filename 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

In addition, 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 start with a lowercase letter or number,
  • Full name must start with a non-space character
  • of --association_user Options will be related user_name Used with the admins security group on the Chef server.
  • The RSA private key will be automatically generated. This is the key to the chef verification procedure and should be kept in a safe place.
  • of --filename The option will save the RSA private key to the specified absolute path.

See the example below:

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

The generated key should be /home table of Contents

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

Install Chef Manage

Chef Manage is an advanced plugin that provides a graphical user interface for managing common Chef server tasks. Free (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 .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 username/group opscode. PostgreSQL username is opscode-pgsql. Can install other packages from https://packages.chef.io/

If you want to use or already use UFW firewall, please open the port 80 with 443 By running the following command:

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

You should be able to access the Chef Web Administrator Information Center at the following URL https://serverip/login

Install Chef Server & Workstation on Ubuntu 20.04

Log in with the username you added earlier. The fresh Chef dashboard should be similar to the following

Install Chef Server & Workstation on Ubuntu 20.04

Step 5: Install the Chef Development Kit on the workstation computer

Chef Workstation is where you install the Chef development kit. It contains all the tools needed to build and test infrastructure by the outstanding Chef community. Use the following guidelines to install the Chef development kit/workstation:

How to install Chef Development Kit/Workstation on Ubuntu

For Arch Linux users, please use:

How to install Chef Development Kit on Arch Linux

Step 7: Configure the knife on Chef Workstation

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

How to configure Chef Knife on Chef client node, upload recipes and run recipes

The
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
The

The
The

Sidebar