Creating a custom Test Kitchen box

Sorry for another noob question.

I started creating some tests with Test Kitchen and I’m using the following Kitchen configuration:

$ cat .kitchen.yml
  name: vagrant

  name: chef_zero

# Uncomment the following verifier to leverage Inspec instead of Busser (the
# default verifier)
# verifier:
#   name: inspec

  - name: debian-8.2

  - name: default
      - recipe[frontends::default]

Tests are very slow because it installs Chef Client every time, so I know I can use require_chef_omnibus: false to avoid to install it every time.

Kitchen is now using the box from

But how I can create a custom box with Chef Client already installed? I tried to look for some guides or documentation but I found nothing useful.

Could you help me please?

Ok, I realized that boxes are Vagrant ones.
I am trying to create a custom Vagrant box for this :blush:

It’s fairly easy to create a custom Vagrant box of your own but it doesn’t sound like you need it.

Are you just using kitchen test? It’s nice one-stop-shop but also destroys the instances it creates after it’s done testing them, so it’s less than ideal for quick, iterative testing while you’re coding.

You could just use kitchen converge, which will create an instance, install and run Chef, and return you to your shell without destroying the instance (the VM will remain running in the background). You can then make changes to your recipe and run kitchen converge again to keep testing. Since Chef is already installed at that point, it won’t try to reinstall it again.

If you have actual tests you want to run, you can run kitchen verify.

Every now and then, though, it’s good to do a kitchen destroy and start over to make sure your cookbook works from A to Z.

If you want to build your own Vagrant box from scratch, the Vagrant site has tutorials that should get you up and running.

And if you’re using VirtualBox.

If you’re happy with the Debian 8.2 box provided by Chef (other than its lack of an installed Chef Client), then just use this tutorial to customize it:

Keep in mind that one advantage of not bundling Chef Client in a Vagrant box is you can test your cookbook(s) with different versions of Chef (which is why it’s easy to set the version of Chef to install in your .kitchen.yml. (And at the same time, Chef Inc. doesn’t have to update its boxes every time a new version of Chef Client comes out :stuck_out_tongue:)

But unless I’m missing something, I think you should be satisfied with using kitchen converge.