Test Kitchen Setup with Azure

Setup Test Kitchen on Azure

  • note: Refer here for Test Kitchen intro and setup in AWS

Azure Driver

  • Prerequisites:
    • SSH Client: Git or Putty
    • IDE: Visual Studio Code with Chef Extension
    • ChefDk installed
    • Azure CLI installed
  • Generate cookbook on the workstation
    chef generate cookbook nginx_cookbook
    cd nginx_cookbook
  • Azure Preparation
    • Kitchen-azurerm driver is used. For more info refer here
    • The following details are to be fetched
      • Subscription ID: available from the Azure portal
      • Client ID: this will be the Application Id from the application in step 2.
      • Client Secret/Password: this will be the password you supplied in the command in step 2.
      • Tenant ID: use the command detailed in "Manually provide credentials through Azure CLI" step 1 to get the TenantId.
    • Execute the following command and note the subscription id and tenant id
    # login into azure
    az login
    az account show --query "{subscriptionId:id, tenantId:tenantId}"
    • Create the Service Principal for use
    az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/${SUBSCRIPTION_ID}"
    • Your appId, password, sp_name, and tenant are returned. Make a note of the appId and password
    • appId is ClientID and password is client secret
    • Create a file @ ~/.azure/credentials with following info
    client_id = "ClientID"
    client_secret = "ClientSecret"
    tenant_id = "tenantid"
    • change your .kitchen.yml to
        name: azurerm
        subscription_id: "yoursubscriptionid"
        location: "Central Us"
        machine_size: 'Standard_B1s'
        name: chef_zero
        # You may wish to disable always updating cookbooks in CI or other testing environments.
        # For example:
        #   always_update_cookbooks: <%= !ENV['CI'] %>
        always_update_cookbooks: true
        name: inspec
    - name: ubuntu-14.04
        image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
        vm_name: trusty-vm
            ostype: linux
            distro: ubuntu
    - name: default
        - recipe[nginx_cookbook::default]
            - test/integration/default
    • Execute the Command
    kitchen converge
    kitchen login
    • You can verify & once you finish the work destroy.
    • Note: The default user name is azure & password is P2ssw0rd

One thought on “Test Kitchen Setup with Azure

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner