How to install ChefDK in Amazon Linux 2

The ChefDK is a package that includes everything you need to start using Chef. You will need this if you want to develop using chef.

Since I always use Amazon Web Services (AWS) EC2, I tend to choose Amazon Linux 2 even for projects using Chef.

Below is a step-by-step tutorial on how to install ChefDK in an EC2 instance running Amazon Linux 2.


Installation via shell commands

SSH to your Amazon Linux 2 EC2 Instance and run the command below.

curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -c current -P chefdk

This will install the latest version of ChefDK.

For production systems we should specify the specific version of ChefDK or else this will install the version. To do this we need to add the -v option in the end of the command.

Below is an example where we install ChefDK version 4.7.73.

curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -c current -P chefdk -v 4.7.73

Next is to check if chef was installed properly. Go to the Verification section of this post.


Installation via ChefDK Download Page

Go to https://downloads.chef.io/chefdk.

You may select your desired version for ChefDK. Default is the latest stable version.


Copy the URL for the latest version of Red Hat Enterprise Linux.


SSH to your Amazon Linux 2 instance and run the command.

wget [URL of Red Hat Enterprise Linux ChefDK Installer]
wget https://packages.chef.io/files/stable/chefdk/4.7.73/el/8/chefdk-4.7.73-1.el7.x86_64.rpm

Run the following command to install ChefDK.

sudo rpm -Uvh [ChefDK Installer Filename].rpm
sudo rpm -Uvh chefdk-4.7.73-1.el7.x86_64.rpm

Verfication

To check if the installation of ChefDK was successful run the following command.

chef -v

This will show the version of the following.

  • ChefDK version
  • Chef Infra Client version
  • Chef InSpec version
  • Test Kitchen version
  • Foodcritic version
  • Cookstyle version

Output will look like this.

ChefDK version: 4.7.73
Chef Infra Client version: 15.7.32
Chef InSpec version: 4.18.51
Test Kitchen version: 2.3.4
Foodcritic version: 16.2.0
Cookstyle version: 5.20.0

With that we have verified the successful installation of ChefDK in Amazon Linux 2.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.