What is kitchen ?
kitchen is the tool provided by Chef to test your cookbook across any combination of platforms and test suites.
How it helps?
You can test your cookbook across different platforms at one go.
What is required to run this ?
Download and Install Chef-workstation
$gem list kitchen*
test-kitchen supports all above clouds on which you can test you cookbooks isn’t it good …
Here I am covering working with kitchen-azurerm
Install azure cli Azure cli installation guide https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-apt?view=azure-cli-latest
Configure Azure Subscripiton
Run following Azure cli command to login to your Azure portal
Note down the tenantid and id(subscription id)from the output you get after running the above command .
Create Service Principal
az ad sp create-for-rbac --name
Note down the “appId”,”password” from output you get after running above command. Also note down whole output somewhere.
Create azure credentials file
Using a text editor, open or create the file ~/.azure/credentials and add the following section, noting there is one section per Subscription ID. Make sure you save the file with UTF-8 encoding
client_id = "your-azure-application-id-here"
client_secret = "your-passwrod-here"
tenant_id = "your-azure-tenant-id-here"
chef generate cookbook test-helloworld
Update kitchen.yml with following contents
driver: name: azurerm subscription_id: 'your-subscription-id' location: 'East US 2' machine_size: 'Standard_B2ms'
- name: ubuntu-18.04
- name: default
After doing all above setup you are good to verify all kitchen commands.
Note: All this spins up the instance on Azure so don’t forget to check or manually delete Resource Group after you execute
kitchen destroy or
kitchen test command.