3

I'm new to test kitchen with windows

I'm testing chef recipes on a windows machine using Test Kitchen with Vagrant (virtualbox)

I have win-2012-r2 box that works fine with Vagrant (both winrm and rdp works)

But, when using the same with kitchen, it tries to connect SSH instead of winrm

Here is my .kitchen.yml file

---
driver:
  name: vagrant

provisioner:
  name: chef_zero

verifier:
  name: inspec

transport:
  name: winrm
  elevated: true

platforms:
  - name: win-2012-r2
    driver:
      box: win-2012-r2
      communicator: 'winrm'
      winrm_username: 'admin'
      winrm_password: 'adminadmin'

suites:
  - name: default
    run_list:
      - recipe[ttest::default]

While running kitchen test, the output is

-----> Starting Kitchen (v1.11.1)
-----> Cleaning up any prior instances of <default-win-2012-r2>
-----> Destroying <default-win-2012-r2>...
       Finished destroying <default-win-2012-r2> (0m0.00s).
-----> Testing <default-win-2012-r2>
-----> Creating <default-win-2012-r2>...
       Bringing machine 'default' up with 'virtualbox' provider...
       ==> default: Importing base box 'win-2012-r2'...
==> default: Matching MAC address for NAT networking...
       ==> default: Setting the name of the VM: kitchen-ttest-default-win-2012-r2_default_1472129655910_94157
       ==> default: Clearing any previously set network interfaces...
       ==> default: Preparing network interfaces based on configuration...
           default: Adapter 1: nat
       ==> default: Forwarding ports...
           default: 22 (guest) => 2222 (host) (adapter 1)
       ==> default: Booting VM...
       ==> default: Waiting for machine to boot. This may take a few minutes...
           default: SSH address: 127.0.0.1:2222
           default: SSH username: vagrant
           default: SSH auth method: private key
......................
STDERR: Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

Not sure where I'm missing.

Test Kitchen version 1.11.1
Vagrant 1.8.5
VirtualBox 5.1

Thanks you all

Shan
  • 153
  • 1
  • 1
  • 8

2 Answers2

2

Try setting the port to 5985 (or whatever port you need.
For example:

platforms: - name: windows2016 transport: name: winrm elevated: true port: 5985

If this doesn't work try kitchen converge -l debug and get some more info on why the machine timed out.

Zwadderich
  • 21
  • 3
1

I had a similar issue with this and in my case, to fix this issue, I needed to specify the communicator attribute as "winrm" in the kitchen.yml file:

driver:
  name: vagrant
  boot_timeout: 1200
  gui: true
  communicator: winrm

Also, I notice your credentials looks different than mine. I specify "username" and "password" under "platform"/"driver_config", not "winrm_username" and "winrm_password". Also, in my case, my port is not the typical 5985 because it's a custom Virtual Box and in my case 55985 (HOST) gets mapped to 5985 (GUEST), but you'll need to use the correct port as mentioned by Zwadderich:

transport:
  name: winrm
  elevated: true
  username: Tester
  password: [PASSWORD]
  port: 5985

Because my box is a custom Windows box the name matches the box as known by vagrant

platforms:
  - name: VAGRANT-CUSTOM-BOX-NAME
    driver_config:
      username: Tester
      password: [PASSWORD]
      vm_hostname: false
    driver:
      port: 55985
      customize:
        memory: 4048

The "driver_config" section appears to effect the generated vagrant file used to bring up the box using vagrant. I hope this helps!