Chef: kitchen-azurerm

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
https://downloads.chef.io/chef-workstation/

List gem
$gem list kitchen*

kitchen-azurerm (1.0.0)
kitchen-digitalocean (0.10.6)
kitchen-dokken (2.9.0)
kitchen-ec2 (3.5.0)
kitchen-google (2.0.3)
kitchen-hyperv (0.5.4)
kitchen-inspec (1.3.2)
kitchen-openstack (5.0.1)
kitchen-vagrant (1.6.1)
kitchen-vcenter (2.7.0)
test-kitchen (2.5.0)

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
az login
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

[ADD-YOUR-AZURE-SUBSCRIPTION-ID-HERE-IN-SQUARE-BRACKET]
client_id = "your-azure-application-id-here"
client_secret = "your-passwrod-here"
tenant_id = "your-azure-tenant-id-here"

Create cookbook
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'

transport:
ssh_key: ~/.ssh/id_kitchen-azurerm

provisioner:
name: chef_zero

platforms:
- name: ubuntu-18.04
driver:
image_urn: Canonical:UbuntuServer:18.04-LTS:latest
vm_name: vj-trusty-vm
vm_tags:
ostype: linux
distro: ubuntu

suites:
- name: default
run_list:
- recipe[kitchentesting::default]
attributes:

After doing all above setup you are good to verify all kitchen commands. i.e. kitchen list
kitchen create
kitchen converge

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.

Ref: https://github.com/test-kitchen/kitchen-azurerm/blob/master/README.md

Published by Vasundhara Jagdale

I am vasundhara. Like to learn new things. And this is one of the new thing I am starting, nothing but my own blog. Quite exciting.... Will get to know about me more from my blogs...:D

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: