How to run Test Kitchen on an existing Windows server?


#1

Is it possible to run Test Kitchen to do a test converge of a Chef cookbook on an existing Windows server? If so, what does the .kitchen.yml file need to look like?

I know how to do it for Linux – for example, this .kitchen.yml file works lets me do a test converge of the cookbook on the existing Linux server :

---
platforms:
  - name: linux
    driver:
      name: ssh
      hostname: <fqdn>
      username: <user>
      password: <password>
      sudo: true

provisioner:
  name: chef_zero

suites:
  - name: default
    run_list:
      - recipe[<cookbook_name>]

Is there an analogous incantation for Windows? (The above example uses the "kitchen-ssh: driver – but I couldn’t find a “kitchen-winrm” driver…) I can’t seem to find any material online that directly addresses this question. I’m hoping one of you can help me out!


#2

Posting works! Minutes after posting this question, I came across the following solution from a coworker. I could only test it on Linux, but this .kitchen.yml file lets me do a test converge of a cookbook on an existing Windows server. So I’m all set. And I hope this helps others out there as well.

---
driver:
  name: proxy
  host: <fqdn> 
  reset_command: "exit 0"
  port: 5985
  username: <user>
  password: <password>
        
provisioner:
  name: chef_zero
    
platforms:
  - name: windows
     
suites:
  - name: default
    run_list:
      - recipe[<cookbook_name>]

#3

If you are connecting to a real machine that requires actual credentials (perhaps it’s joined to active directory and GPO prevent local accounts), you can use environment variables to store the username and password

---
driver:
  name: proxy
  host: <fqdn> 
  reset_command: "exit 0"
  port: 5985
  username: <%= ENV['TK_USERNAME'] %>
  password: <%= ENV['TK_PASS'] %>