Test kitchen is unable to winrm into windows vm

Trying to make my own windows 2012 R2 vagrant VM for test kitchen.

I’ve created a box based on these instructions

I’ve ensured:

  • windows firewall turned off
  • winrm is configured to allow non https
  • username & password = vagrant
  • virtualbox port forwarding is configured correctly

I am able to winrm into the virtualbox from my mac.

knife wsman test 127.0.0.1 -m -p 55985
Connected successfully to 127.0.0.1 at http://127.0.0.1:55985/wsman.

Yet when I try and run kitchen setup It fails to authenticate.

sowens-MBP:nd-web sowen$ ki setup -l debug
-----> Starting Kitchen (v1.10.0)
D      [Vagrant command] BEGIN (vagrant --version)
D      [Vagrant command] END (0m0.30s)
D      [Vagrant command] BEGIN (vagrant plugin list)
D      [Vagrant command] END (0m1.14s)
D      Berksfile found at /Users/sowen/Devops/cookbooks/nd-web/Berksfile, loading Berkshelf
D      Berkshelf 4.3.5 library loaded
D      winrm requested, loading winrm gem (["~> 1.6"])
D      winrm is loaded.
D      winrm-fs requested, loading winrm-fs gem (["~> 0.4.1"])
D      winrm-fs is loaded.
-----> Creating <default-windows-2012>...
D      <default-windows-2012> is synchronizing on Kitchen::Driver::Vagrant#create
D      <default-windows-2012> is messaging Kitchen::Driver::Vagrant#create
D      Creating Vagrantfile for <default-windows-2012> (/Users/sowen/Devops/cookbooks/nd-web/.kitchen/kitchen-vagrant/kitchen-nd-web-default-windows-2012/Vagrantfile)
D      ------------
D      Vagrant.configure("2") do |c|
D        c.berkshelf.enabled = false if Vagrant.has_plugin?("vagrant-berkshelf")
D        c.vm.box = "spencer/win2012-vagrant"
D        c.vm.communicator = "winrm"
D        c.vm.guest = ":windows"
D        c.vm.synced_folder ".", "/vagrant", disabled: true
D        c.vm.provider :virtualbox do |p|
D          p.customize ["modifyvm", :id, "--memory", "4096"]
D        end
D      end
D      ------------
D      [Vagrant command] BEGIN (vagrant up --no-provision --provider virtualbox)
       Bringing machine 'default' up with 'virtualbox' provider...
       ==> default: VirtualBox VM is already running.
D      [Vagrant command] END (0m2.43s)
D      [Vagrant command] BEGIN (vagrant winrm-config)
D      [Vagrant command] END (0m2.42s)
       [WinRM] connection failed. retrying in 3 seconds: #<WinRM::WinRMAuthorizationError: WinRM::WinRMAuthorizationError>
       [WinRM] connection failed. retrying in 3 seconds: #<WinRM::WinRMAuthorizationError: WinRM::WinRMAuthorizationError>
       [WinRM] connection failed. retrying in 3 seconds: #<WinRM::WinRMAuthorizationError: WinRM::WinRMAuthorizationError>
       [WinRM] connection failed. retrying in 3 seconds: #<WinRM::WinRMAuthorizationError: WinRM::WinRMAuthorizationError>
       [WinRM] connection failed. retrying in 3 seconds: #<WinRM::WinRMAuthorizationError: WinRM::WinRMAuthorizationError>

.kitchen.yml

---
driver:
  name: vagrant
  customize:
    memory: 4096

provisioner:
  name: chef_zero

platforms:
  - name: windows-2012
    transport:
      name: winrm
      max_threads: 1
      username: vagrant
      password: vagrant
    driver:
      port: 55985
      guest: :windows
      box: spencer/win2012-vagrant
    driver_config:
      guest: windows
      communicator: winrm
      vm_hostname: false
    run_list:
    attributes:
      test_kitchen: true

I am able to use other windows vagrant boxes like this one

https://wrock.blob.core.windows.net/vhds/vbox2012r2.box

---
driver:
  name: vagrant
  customize:
    memory: 4096

provisioner:
  name: chef_zero
  # require_chef_omnibus: 12.9.41

platforms:
  - name: windows-2012
    transport:
      name: winrm
      max_threads: 1
      username: vagrant
      password: vagrant
    driver:
      port: 55985
      guest: :windows
    driver_config:
      box_url: https://wrock.blob.core.windows.net/vhds/vbox2012r2.box
      guest: windows
      communicator: winrm
      vm_hostname: false
    run_list:
    attributes:
      test_kitchen: true

What else could I be missing that causes test kitchen to fail to winrm into my box, but works with other vagrant boxes?

Solution is to move the ‘username’ and ‘password’ values to the driver_config section

---
platforms:
  - name: windows-2012
    driver_config:
      box: spencer/win2012-vagrant
      username: administrator
      password: vagrant
      communicator: winrm
    run_list:

Further debugging

knife bootstrap windows winrm 127.0.0.1 \
--winrm-user administrator \
--winrm-password 'vagrant' \
--winrm-port 55985 \
--node-name vagrant-test