Why and How to Switch from ChefDK to Workstation

Managing infrastructure can be a daunting task. Navigating through a plethora of commands and configurations can make one feel lost in the complexity of it all, but having the right tools can make all the difference by maximizing productivity and simplicity at the same time.  

ChefDK was introduced with the intention to provide a package with all the necessary tools required to develop your own cookbooks. With time, ChefDK improved and scaled to be much more than just a development kit, and this increase in functionality called for an all-in-one tool that significantly reduced the complexity of working with an amalgam of all the tools developed by the community.  

The Chef Development Kit was hence succeeded by The Chef Workstation.   

Workstation, a comprehensive development environment that includes all the necessary tools, utilities, and libraries required to create, test, and deploy Chef infrastructure code.   

By expanding support to newer platforms and plugins, Chef Workstation not only replaces ChefDK but also adds on to its functionality, and now provides a comprehensive solution that merges all the previous features along with new ones.   

Install Chef Workstation  


But what does this mean? Why should one switch?  

  • Simplicity. Intended to be a single tool for managing infrastructure in its entirety unlike ChefDK which provides a collection of tools. Easily create and upload cookbooks, manage nodes, run chef client or any task required manage the chef infrastructure. Workstation also makes it easy for new users to learn and get used to the product quicker.
     
  • Productivity. With the all-inclusive approach, you need not juggle between various tools to complete tasks. By using a single interface, users can save time on finishing tasks. Built in tools like ChefSpec unit testing framework aids users in conducting faster cookbook tests.

  • Better security. Using encrypted data bags by default, storing sensitive data in an encrypted format using chef-vault, encrypting data transmissions between Chef and its clients using SSL/TLS makes workstation a safer, secured option in contrast to ChefDK.

  • Improved collaboration. Features such as ‘berks’, which manages cookbook dependencies, allowing users to easily share cookbooks with others, make it easier to collaborate with others on chef infrastructure. In addition, Git and other source control management systems are supported natively by Workstation, allowing users to collaborate on infrastructure modifications. 

  • Easier upgrades. Chef Workstation makes updating to new versions of Chef easier by enabling users to do it with a single command. The latest version of Chef and all necessary dependencies are downloaded and installed by Workstation automatically after the update command has been executed. Users can stay up to date with the newest security updates and functionalities thanks to this simplified technique.  
Convinced that Chef Workstation is the tool for you?  

Follow these steps to upgrade from ChefDK  


Step 1 - Download and install Chef Workstation from the Chef website. You will be led through the installation process by the installer, which will also install all necessary components. 

1.1 You can verify the version by running chef -v

Step 2 - If you were using ChefDK prior to this, upon installing Chef Workstation, all of your existing projects will be migrated.   

ChefDK Installed


If you are setting up chef for the first time however, you will need a Chef Infra repository for saving your cookbooks and projects.   

Follow these steps to do the same or alternatively, refer to the official documentation on Getting started with Chef Workstation.

Step 1 - Download and install the Chef Workstation on your system.

Step 2 - If ruby is primarily being used for developing Chef policy, it is recommended to use the Chef workstation ruby as your default system ruby. Skip this step otherwise.  

These instructions are intended for macOS and Linux users. On Windows, Chef Workstation includes a desktop shortcut to a PowerShell prompt already configured for use.  

2.1. Get the path to your default shell by running: echo $SHELL 

2.2. Add the workstation initialization content to your shell rc file:  

echo 'eval "$(chef shell-init <shell rc>)"' >> ~/.<shell rc>rc  

Replace <shell rc> according to your requirements eg. bash, zsh etc.  

2.3. Run  

which ruby  

in a new shell window  

The command should return /opt/chef-workstation/embedded/bin/ruby  

Step 3 - If you are setting up chef for the first time in your organization, set up a chef infra repository by using the command  

chef generate repo chef-repo  

This creates a repository called chef-repo

The repo is a directory on your workstation that stores everything you need to define your infrastructure with Chef Infra including cookbooks, policy files and data bags.  

 Step 4As a user,  you must create a special private key that matches a client on the Chef Infra Server made by your server administrator. This key is a secret code in the .pem format using the RSA encryption algorithm.  

 Step 5The .chef directory is important for Chef users as it contains the credentials file that allows them to communicate with the Chef Infra Server. To create this file, they need to run the knife configure command and provide specific details such as the Chef Server URL and Client Name, which are usually provided by the server administrator. Users can find this information in the Starter Kit file, which is available for download in the Administration tab for Hosted Chef or Chef Manage users. The Starter Kit also contains the config.rb file that users can use to configure their connection: 


Step 6 - Run   

cp ~/Downloads/MY_NAME.pem ~/.chef/ to copy the client.pem file to the .chef directory  

Step 7 - To verify if the Workstation can connect to the Infra server, run the following on your terminal  

knife client list  

This should return a list   

chef_machine
registered_node

  
You can use   

knife ssl fetch  

to pull the self signed certificates from the infra server.  

Once all the steps are followed, one can start using Chef Workstation for your infrastructure management needs.  

Migrating from ChefDK to Workstation encourages efficiency in managing Chef infrastructure. By consolidating all the necessary tools and functionalities into a single interface, streamlining infrastructure management tasks and reducing complexity, Workstation brings numerous benefits in terms of simplicity, productivity, security, collaboration and ease of upgrades.  

Explore other functionalities of Chef Workstation:  

Learn more:  


Tags:

Sarthak Vasal

Sarthak Vasal is a Technical Product Intern at Progress Chef. With a background in computer science, Sarthak brings a blend of technical expertise and business acumen to the table. As part of the Technical Product Marketing team, he is driven by a deep fascination for the journey from an idea to a fully realized product and its market success.