Skip to content

Instantly share code, notes, and snippets.

@dm4r
Last active April 26, 2017 02:26
Show Gist options
  • Save dm4r/210ebcb4283b448b80f4f899f3a59495 to your computer and use it in GitHub Desktop.
Save dm4r/210ebcb4283b448b80f4f899f3a59495 to your computer and use it in GitHub Desktop.

Chef Training Workstations Prereqs (Windows OS focused)

Overview

The following documents the setup steps for building a sane workstation environment on YOUR laptop to write and test Chef code. This document should work with Mac OS X, Windows, or Linux systems.

A workstation is a computer running the Chef Development Kit (ChefDK) that is used to author cookbooks, interact with the Chef server, and interact with nodes

Software Installation

You will need to install the following software on your system:

  • Chef Development Kit (ChefDK) - The Chef Development Kit contains all of the tools you need to write and test Chef code
  • Vagrant - Vagrant is a tool for building complete development environments
  • VirtualBox - Free open source tool for launching virtual machines on your laptop
  • A Developers text editor like Atom, Visual Studio Code, or others (the two mentioned here are free)

Validate ChefDK, Vagrant, and VirtualBox are installed

Open a terminal and run the following commands

  • $ chef -v - should return the version of ChefDK you have installed
  • $ vagrant -v - should return the version of vagrant you have installed
  • $ VBoxManage -v should return the version of VirtualBox installed
$ chef -v
Chef Development Kit Version: 1.2.22
chef-client version: 12.18.31
delivery version: master (0b746cafed65a9ea1a79de3cc546e7922de9187c)
berks version: 2017-02-13T15:22:25.194111 59785] 2017-02-13T15:22:25.194892 59785] 2017-02-13T15:22:25.195007 59785] 2017-02-13T15:22:25.195108 59785] 2017-02-13T15:22:25.227742 59785] 2017-02-13T15:22:25.227867 59785] 5.6.0
kitchen version: 1.15.0
$
$
$ vagrant -v
Vagrant 1.9.1
$
$
$ VBoxManage -v
5.1.14r112924

Setup your Shell Environment (Mac/Linux only)

Chef installs the Ruby programming language separate from any existing installs of Ruby. In this step we will setup your shell environment to use that version of ruby:

  1. Open a terminal
  2. Run the command echo 'eval "$(chef shell-init bash)"' >> ~/.bashrc *
  3. Relaunch terminal or run the command source ~/.bashrc
  4. Run the command which ruby should return /opt/chefdk/embedded/bin/ruby
  • NOTE: If you are running another shell sh or zsh you can substitute the name of your shell for bash

Download a Vagrant Box Image for testing

In this step we will download a Vagrant box image for testing with Virtual Box.

  1. Open a terminal (bash, powershell, etc)
  2. Run the following command vagrant box add mwrock/Windows2012R2
  3. When prompted choose Option 2 'virtualbox'
  • NOTE: The download is around 4GB in size
$ vagrant box add mwrock/Windows2012R2
==> box: Loading metadata for box 'mwrock/Windows2012R2'
    box: URL: https://atlas.hashicorp.com/mwrock/Windows2012R2
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) hyperv
2) virtualbox

Enter your choice: 2
==> box: Adding box 'mwrock/Windows2012R2' (v0.6.1) for provider: virtualbox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment