Configure Amazon Linux Docker Image for Test Kitchen in Chef Cookbook

From Bonus Bits
Jump to: navigation, search

Purpose

This article gives the steps to setup Test Kitchen with kitchen-docker Ruby gem to use the newly released Amazon Linux Docker Image.


Prerequisites


Install kitchen-docker gem

Fist make sure we have the kitchen-docker gem installed.

/opt/chefdk/embedded/bin/gem install kitchen-docker --no-rdoc --no-ri


Kitchen Config

As of kitchen-docker v2.6.0 amazonlinux image is not supported by default. Here's a workaround example. This could be your default Kitchen config .kitchen.yml or a separate one such as .kitchen.docker.yml. If using a none default config simply call it with in BASH like this KITCHEN_YAML=.kitchen.docker.yml kitchen <command>

---

driver:
  name: docker
  use_sudo: false # For Native Docker on Mac. Comment if using Toolbox (docker-machine)
  driver_config:
    ssl_verify_mode: ":verify_none"

provisioner:
  name: chef_zero
  require_chef_omnibus: 12.18.31
  data_bags_path: test/data_bags
  encrypted_data_bag_secret_key_path: test/data_bags/encrypted_data_bag_secret
  roles_path: test/roles
  environments_path: test/environments

platforms:
  - name: amazonlinux
    driver_config:
      image: amazonlinux:latest
      platform: rhel

verifier:
  name: inspec

suites:
  - name: default
    run_list:
      - role[docker_role]
    provisioner:
      client_rb:
        environment: docker_environment


Related Articles