Overriding Test Kitchen Driver Configuration

When working with Test Kitchen, you have a couple of locations that you can set configuration.

The first is in your "global" configuration, stored in $HOME/.kitchen/config.yml, which is the base configuration that is used for any Test Kitchen interactions for that user. In a CI/CD setup, you may not have any control over this file.

The second option is actually available in your .kitchen.yml in your project.

Within the .kitchen.yml, you again have two options, globally and per-suite.

For instance, if we take the following example configuration:

---
driver:
  name: docker
  use_sudo: false
  provision_command:
    - /usr/bin/apt-get update -y
    - /usr/bin/apt-get install -y net-tools build-essential
  run_command: /bin/systemd
  cap_add:
    - SYS_ADMIN
  volume:
    - /sys/fs/cgroup

verifier:
  name: inspec

platforms:
  - name: debian
    driver_config:
      image: debian:jessie

suites:
  - name: default
    run_list:
      - recipe[cookbook-spectat::default]
    attributes:
      spectat:
        authorized_keys: ['fake-ssh-public-key']
  - name: another
  # ...

If, for some reason, we needed to override the use_sudo property for specifically the default suite, we could make the following change:

 suites:
   - name: default
+    driver:
+      use_sudo: true
     run_list:
       - recipe[cookbook-spectat::default]
     attributes:
       spectat:
         authorized_keys: ['fake-ssh-public-key']

In another example, we could be provisioning some software that has certain hardware requirements on AWS, at which point we could specific the AWS instance type in the configuration:

suites:
  - name: default
    driver:
      instance_type: m4.large
    run_list:
      - recipe[cookbook-spectat::default]
    attributes:
      spectat:
        authorized_keys: ['fake-ssh-public-key']

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the GNU General Public License v3.0 only.

#test-kitchen #blogumentation.

This post was filed under articles.

Has this content helped you? Please consider supporting me so I can continue to create content like this!

Related Posts

Other posts you may be interested in:

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.