Basic Chef Workstation and Server Installation and configuration
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.
Notice, the default location for the installation is c:opscode.
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.
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:
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.pem – private key copied from the Ubuntu Chef installation
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.
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.