Automation

Basic Chef Workstation and Server Installation and configuration

A quick look at Basic Chef Workstation and Server Installation and configuration walkthrough to help any get up and running quickly with learning Chef automation

Automation is perhaps the most exciting and most desirable skill in today’s work of infrastructure operations.ย  Today “infrastructure as code” is a buzzword you here everywhere.ย  If you haven’t started working on your automation skills, now is the time to do that.ย  You can’t go wrong working on how to automate processes, provisioning, desired state, etc.ย  There are a lot of tools out there that you can start with.ย  One of my goals this year in 2018 is to get better with automation.ย  A really nice platform to start with that is fairly easy to understand and that has a great learning program is Chef.ย  Chef is a great way to run in guest customizations and maintain a desired state on a Windows or Linux platform.ย  While Chef has some great learning modules that can be found here: learn.chef.io, I wanted to give a basic, quick overview of how to get Basic Chef Workstation and Server Installation and configuration accomplished where we are then ready to create cookbooks, upload cookbooks, bootstrap nodes, etc.

Basic Chef Workstation and Server Installation and configuration

There are two components to interacting with a Chef server.ย  You need to have a workstation that is running the Chef Development Kit which you can download here:ย ย https://downloads.chef.io/chefdk

Then you need to download the Chef Server piece.ย  What I did was stand up a very light Ubuntu 16.04 LTS server and then run the script with a few modifications that is found here:ย ย https://learn.chef.io/modules/manage-a-node-chef-server/ubuntu/bring-your-own-system/set-up-your-chef-server#/

Installing Chef Development Kit on a Workstation

Install Chef SDK on a workstation is very straightforward and is basically just “next, next, finish”.ย  However, let’s look at a few quick screenshots of that process.

Beginning-installation-of-Chef-Development-Kit-on-a-workstation
Beginning installation of Chef Development Kit on a workstation
Accept-the-Chef-Development-Kit-EULA
Accept the Chef Development Kit EULA

Notice, the default location for the installation is c:opscode.

Choosing-features-and-install-location-of-Chef-Development-Kit
Choosing features and install location of Chef Development Kit
Begin-the-install-of-Chef-Development-Kit-files
Begin the install of Chef Development Kit files
Chef-Development-Kit-installation-finishes
Chef Development Kit installation finishes

Once the Chef Development Kit is installed, you will see an icon on your desktop for the Development Kit.ย  This amounts to a specialized PowerShell environment that has the Chef modules loaded.

Chef-Development-Kit-PowerShell-prompt-with-modules-installed
Chef Development Kit PowerShell prompt with modules installed

Installing Chef Server

As mentioned above, I customized the install script (changed the organization, etc) for the server that is found on the page:ย https://learn.chef.io/modules/manage-a-node-chef-server/ubuntu/bring-your-own-system/set-up-your-chef-server#/

For my home lab where I was learning at least, the Chef server didn’t need much of anything.ย  I simply stood up a very light Ubuntu 16.04 LTS server with the following modest specs:

Ubuntu-16.04-LTS-server-for-Chef-Server
Ubuntu 16.04 LTS server for Chef Server
Running-Chef-Server-install-on-Ubuntu-16.04-LTS
Running Chef Server install on Ubuntu 16.04 LTS
Chef-Server-installation-completes-successfully-on-Ubuntu-16.04-server
Chef Server installation completes successfully on Ubuntu 16.04 server

After installing the Chef Server, we need to add a couple of files to our workstation configuration to allow connecting to the Chef Server instance.

  • knife.rb – configuration for the Chef knife utility
  • chefadmin.pemprivate key copied from the Ubuntu Chef installation
Knife-configuration-file-and-private-key-for-connecting-to-server
Knife configuration file and private key for connecting to server

The Chef tutorials helps with theย knife.rb file on the page:ย ย https://learn.chef.io/modules/manage-a-node-chef-server/ubuntu/bring-your-own-system/set-up-your-chef-server#/

A slightly modified example from what is found on the Chef site is below.ย  I am using an on prem server and not an AWS server as shown in the example.ย  Modify the organization name to match what you setup using the Chef server script found in the link above.

current_dir = File.dirname(__FILE__)
log_level                 :info
log_location              STDOUT
node_name                 "chefadmin"
client_key                "#{current_dir}/chefadmin.pem"
chef_server_url           "https://myserver/organizations/4thcoffee"
cookbook_path             ["#{current_dir}/../cookbooks"]

To obtain theย .pem file needed, this can be downloaded from the Chef Server from theย /drop directory.ย  The .pem file will be named according to how you modified the server install script.ย  If you left it as in the example, it will be calledย chefadmin.pem.

We use theย knife SSL fetch to add the certificate to the trusted_certs folder in your working Chef directory.

Use-knife-SSL-fetch-to-add-the-certificate
Use knife SSL fetch to add the certificate
Use-knife-SSL-fetch-to-verify-the-certificate-after-installing
Use knife SSL fetch to verify the certificate after installing

Now that we are to this point, we should have a working Chef workstation/server environment that we can use to begin automating!ย  We are now ready to begin working with the Chef Server – creating cookbooks, uploading cookbooks, bootstrapping nodes, etc.ย  That will be the focus of the next post.

Thoughts

Hopefully this Basic Chef Workstation and Server Installation and configuration walthrough will help any who may want to try to get started with automating their environments or simply play around with automation in the home lab. Automation skills are highly desirable. I recommend any who want to learn a new skill in 2018, focus on learning a bit of automation along with any other skills you may want to pick up. Next, we will take a look at creating cookbooks, uploading cookbooks, bootstrapping a host, and other Chef automation.

Subscribe to VirtualizationHowto via Email ๐Ÿ””

Enter your email address to subscribe to this blog and receive notifications of new posts by email.



Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com, and a 7-time VMware vExpert, with over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, He has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family. Also, he goes through the effort of testing and troubleshooting issues, so you don't have to.

Related Articles

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.