Search code examples
windowsvagrantchef-infratest-kitchen

Chef Kitchen + Vagrant Window7 box failing due to SSH


LOG INFO:

 -----> Starting Kitchen (v1.2.1)
 -----> Creating <default-windows>...
   Bringing machine 'default' up with 'virtualbox' provider...
   ==> default: Importing base box 'windows'...
   ==> default: Matching MAC address for NAT networking...
   ==> default: Setting the name of the VM: default-   windows_default_1422548310230_74071
   ==> default: Fixed port collision for 22 => 2222. Now on port 2202.
   ==> default: Clearing any previously set network interfaces...
   ==> default: Preparing network interfaces based on configuration...
       default: Adapter 1: nat
       default: Adapter 2: hostonly
   ==> default: Forwarding ports...
       default: 22 => 2202 (adapter 1)
   ==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...           default: SSH address: 127.0.0.1:2202
       default: SSH username: vagrant
       default: SSH auth method: private key
       default: Warning: Connection timeout. Retrying...
       default: Warning: Connection timeout. Retrying...
       default: Warning: Connection timeout. Retrying...
       default: Warning: Connection timeout. Retrying...

MY kitchen.yml:

---
driver_plugin: vagrant
driver_config:
  require_chef_omnibus: true
  network:
  - ['private_network', {ip: '192.168.33.33'}]

provisioner:
  name: chef_zero

platforms:
  - name: windows
    driver:
      box: windows
      communicator: winrm
    driver_config:
      gui: true

suites:
  - name: default
    run_list:
      - recipe[tcserver::java-for-tcserver]
      - recipe[tcserver::default]
    attributes:

$ vagrant box list

bseller/santiago      (virtualbox, 1.0.0)
chef/centos-6.5       (virtualbox, 1.0.0)
chef/centos-6.5       (vmware_desktop, 1.0.0)
chef/ubuntu-14.04     (virtualbox, 1.0.0)
hashicorp/precise32   (virtualbox, 1.0.0)
hashicorp/precise64   (virtualbox, 1.1.0) 
learningchef/centos65 (virtualbox, 1.0.7)
opscode-centos-6.5    (virtualbox, 0) 
opscode-ubuntu-12.04  (virtualbox, 0)
opscode-ubuntu-14.04  (virtualbox, 0)
pcf-immersion-box     (virtualbox, 0)
suse/sles11sp3        (virtualbox, 0.1.7) 
ubuntu-chef           (virtualbox, 0)
ubuntu-ruby-chef      (virtualbox, 0)
ubuntu/trusty32       (virtualbox, 14.04)
ubuntu1204            (virtualbox, 0)
vista-ie7             (virtualbox, 0)
windows               (virtualbox, 0)
windows8              (virtualbox, 0)

My generated Vagrantfile from kitchen converge

Vagrant.configure("2") do |c|
  c.vm.box = "windows"
  c.vm.box_url = "https://opscode-vm-    bento.s3.amazonaws.com/vagrant/virtualbox/opscode_windows_chef-provisionerless.box"
  c.vm.hostname = "default-windows.vagrantup.com"
  c.vm.network(:private_network, {:ip=>"192.168.33.33"})
  c.vm.synced_folder ".", "/vagrant", disabled: true
  c.vm.provider :virtualbox do |p|
  end
end

I'm able to successfully run a kitchen converge on a centos/rhel/ubuntu box. This seems to totally be a windows issue (like usual).

It appears that my directives in kitchen.yml are not being translated to the Vagrantfile.

Following runs of kitchen converge indicate VM is running but unable to connect:

[SSH] connection failed, retrying (#<Net::SSH::Disconnect: connection closed by remote host>)

Solution

  • As per this excellent blog post from Matt Wrock, you need to use cutting edge test-kitchen and kitchen-vagrant. With all credit to Matt Wrock, he helped me figure out which versions.

    The tl;dr is:

    If you're using a Gemfile in your cookbook, you can use Bundler's git dependency support to pull in these correct branches/forks. If you're using only Chef-DK without Bundler, you'll need to replace the Chef-DK shipped test-kitchen and kitchen-vagrant