Skip to content

Instantly share code, notes, and snippets.

@smford22
Last active September 29, 2017 23:32
Show Gist options
  • Select an option

  • Save smford22/7576dc5cda6d66611abbc1fcf3bc7641 to your computer and use it in GitHub Desktop.

Select an option

Save smford22/7576dc5cda6d66611abbc1fcf3bc7641 to your computer and use it in GitHub Desktop.
Chef Workstation Setup

Chef Training Workstations Prereqs

Overview

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

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, Sublime Text, or other

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: 2.2.1
chef-client version: 13.3.42
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.1
kitchen version: 1.17.0
inspec version: 1.35.1
$
$
$ 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 Virutual Box.

  1. Open a terminal (bash, powershell, etc)
  2. Run the following command vagrant box add bento/centos-6.8
  3. When prompted choose Option 2 'virtualbox'
$ vagrant box add bento/centos-6.8
==> box: Loading metadata for box 'bento/centos-6.8'
    box: URL: https://atlas.hashicorp.com/bento/centos-6.8
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) parallels
2) virtualbox
3) vmware_desktop

Enter your choice: 2
==> box: Adding box 'bento/centos-6.8' (v2.3.1) for provider: virtualbox
    box: Downloading: https://atlas.hashicorp.com/bento/boxes/centos-6.8/versions/2.3.1/providers/virtualbox.box

WINDOWS BASE BOXES

If you would rather use a Windows Base box for testing you will need an account at Vagrant Cloud. Once logged in you can run the following commands...

$ vagrant login
In a moment we will ask for your username and password to HashiCorp's
Atlas. After authenticating, we will store an access token locally on
disk. Your login details will be transmitted over a secure connection, and
are never stored on disk locally.

If you do not have an Atlas account, sign up at
https://atlas.hashicorp.com.

Atlas URL: https://app.vagrantup.com
Atlas Username: sford@chef.io
Password (will be hidden):
You are now logged in.

$ vagrant box add opentable/win-2012r2-standard-amd64-nocm
==> box: Loading metadata for box 'opentable/win-2012r2-standard-amd64-nocm'
    box: URL: https://app.vagrantup.com/opentable/win-2012r2-standard-amd64-nocm
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) virtualbox
2) vmware_desktop

Enter your choice: 1
==> box: Adding box 'opentable/win-2012r2-standard-amd64-nocm' (v1.0.0) for provider: virtualbox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment