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
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)
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
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:
- Open a terminal
- Run the command
echo 'eval "$(chef shell-init bash)"' >> ~/.bashrc
* - Relaunch terminal or run the command
source ~/.bashrc
- Run the command
which ruby
should return/opt/chefdk/embedded/bin/ruby
- NOTE: If you are running another shell
sh
orzsh
you can substitute the name of your shell for bash
In this step we will download a Vagrant box image for testing with Virtual Box.
- Open a terminal (bash, powershell, etc)
- Run the following command
vagrant box add mwrock/Windows2012R2
- 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