Examples

We’ve collected a variety of examples to highlight all the different things one can do with kitchen.

kitchen-vagrant

The default driver with a default provider of VirtualBox. Here is a fully annotated example of the kitchen.yml generated by chef generate

---
# Configure the driver (cloud/hypervisor)
driver:
  name: vagrant #ec2, dokken, libvirt
  # provider: virtualbox

# Configure the provisioner (config management)
provisioner:
  name: chef_zero #chef_zero, chef_solo, salt_solo, puppet_apply, ansible_playbook, shell

# Configure the verifier (testing framework)
verifier:
  name: inspec

# Enumerate platforms
# A platform represents a single configuration of an operating system
# While this is often 1:1, the names allow this to be customizable
# At least 1 platform is **required**
platforms:
  # Drivers may support defaults that automatically
  # map certain names to an image for the given driver
  - name: ubuntu-16.04
  - name: centos-8

# Enumerate suites
# At least 1 suite is **required**
suites:
  # The name of each suite maps to a configuration / set of tests
  # Depending on the verifier, default locations may be inferred based on
  # directory naming
  - name: default
    run_list:
      - recipe[git_cookbook::default]
    verifier:
      inspec_tests:
        - test/integration/default
    attributes:

Sometimes you’d like to add another NIC to your vm, or bump up the memory. You might have a forwarded_port you’d like to add also. The following snippet has a couple suggestions how. You can even turn on the auto_correct if you think you’ll need it.

  name: vagrant
  network:
    - ["forwarded_port", {guest: 80, host: 8080, auto_correct: true}]
    - ["forwarded_port", {guest: 443, host: 8443}]
    - ["private_network", {ip: "10.0.0.1"}]
  customize:
    cpus: 2
    memory: 4096

The driver tries to closely mirror the upstream, as illustrated by forwarded_port and private_network.

If you would like more information the kitchen-vagrant github page has more.

hangops-jobbot/.kitchen.yml

---
driver:
  name: vagrant
  network:
    - ["forwarded_port", {guest: 8080, host: 8081}]

provisioner:
  name: chef_solo
  data_bags_path: './test/integration/data_bags/'
  solo_rb:
    environment: test

platforms:
  - name: ubuntu-16.04

suites:
  - name: default
    run_list:
      - recipe[hangops-jobbot::default]
    attributes: