Contributors30 minutesTest Kitchen enables you to specify details about your virtual machine. When working with Azure, this includes which image to use, the instance size, networking settings, and how to run Chef – including which recipes and which tests to run. Test Kitchen is the interface you use to create, destroy, and run Chef on your instances.
Here you'll make sure that your workstation is set up for Chef development. You'll also prepare your Azure account to create test instances.
If you don't have an Azure account, Microsoft is offering a 30-day free trial for up to $200 (USD) of usage.
| In this module you'll use CentOS, a free computing platform that's functionally compatible with Red Hat Enterprise Linux. CentOS typically costs less to run on Azure, and is an ideal way to quickly test out your Chef code. |
1. Set up your workstation for Chef development
Although this module doesn't involve the Chef server or bootstrapping a node, we recommend that you complete Manage a Red Hat Enterprise Linux node with Chef server before starting this module.
If you prefer to learn about local development now, before learning how to bootstrap a node, perform these steps to set up your workstation. Then come back to this page.
At this point, your workstation should:
- have the latest version of Chef Workstation.
- have a programmer's text editor that you're comfortable working with.
- have the
~/learn-chef directory for you to work in. - have Git and an SSH client.
Having Git is important because you'll use it to download starter code to work with.
Having an SSH client is important because you can use it to log in to your CentOS instance to verify your work.
If your workstation is running Windows, remember to open the Chef Workstation desktop shortcut. The desktop shortcut brings up a PowerShell session that's configured to work with Chef.

2. Prepare your Azure account
You'll use Test Kitchen to create an Azure instance later in this module. For now, let's ensure you have everything you'll need to create and connect to your instance.
Test Kitchen uses drivers, or plugins, to work with cloud and virtualization platforms. Some drivers come with Chef Workstation. For Azure, you need to install the kitchen-azurerm driver on your workstation manually. You also need to create a configuration file on your workstation that authenticates access to Azure resources.
Review the kitchen-azurerm project page and perform the steps to install the driver and set your configuration file.
Here's an example of how to install the kitchen-azurerm driver.
Terminal: ~
$ | chef gem install kitchen-azurermBuilding native extensions. This could take a while...Successfully installed unf_ext-0.0.7.5Successfully installed unf-0.1.4Successfully installed domain_name-0.5.20180417Successfully installed http-cookie-1.0.3Successfully installed faraday-cookie_jar-0.0.6Successfully installed timeliness-0.3.8Successfully installed ms_rest-0.7.2Successfully installed ms_rest_azure-0.10.6Successfully installed azure_mgmt_network-0.16.0Successfully installed azure_mgmt_resources-0.16.0Successfully installed sshkey-1.9.0Successfully installed kitchen-azurerm-0.14.012 gems installed
|
The process involves compiling Ruby gems from source. If you receive an error, you may need to install build tools that can compile the sources. For example, on macOS, you can install Xcode. On Linux, you can install build-essential. Here's an example for Ubuntu:
Terminal: ~
$ | sudo apt-get install build-essential
|
Here's an example Azure credentials file.
Editor: ~/.azure/credentials
1
2
3
4
| [12345678-YOUR-GUID-HERE-123456789abc]
client_id = "12345678-1234-1234-1234-CBA987654321"
client_secret = "5VqaLPR3EDPt+your-secret-here-BHdLBXVggpb3="
tenant_id = "12345678-1234-1234-1234-CBA987654321" |
Also note the region, for example, East US or UK West, where you'll run your test instances.
You'll also need an SSH public and private key pair to connect to your instances.
If you're new to Azure, their Create a Linux virtual machine with the Azure portal quickstart walks you through the creation of your first Linux virtual machine. After you verify that you're able to create an instance, note the region for later.