Allan Espinosa

Workarounds to converge test-kitchen on Windows guests

2014 May 8

Below are a few hacks I did to get “test-kitchen converge” runs to test my windows cookbooks.

Invoke the cmd.exe interpreter explicitly

By default test-kitchen relies on ssh to run commands. Logging in via cygwin-ssh gives you a plain bourne shell. This has its own issues in running the chef-client.

EDIT: I need to test this workflow again on Vagrant 1.6.x that has native support for windows guest.

--- a/lib/kitchen/provisioner/chef_zero.rb   2014-05-08 00:12:12.971562743 +0900
+++ b/lib/kitchen/provisioner/chef_zero.rb   2014-05-08 00:10:44.612041428 +0900
@@ -69,7 +69,7 @@

         if local_mode_supported?
-          ["#{sudo('chef-client')} -z"].concat(args).join(" ")
+          ["#{sudo('cmd /c chef-client')} -z"].concat(args).join(" ")

Related blockers.

Change the base path

Otherwise the chef-client can’t recognize the paths it receives from test-kitchen.

  name: chef_zero
  sudo: false
  root_path: c:/Windows/Temp


  1. Windows 2012 R2 base image used for testing