ansible-testkitchen-windows icon indicating copy to clipboard operation
ansible-testkitchen-windows copied to clipboard

Running Ansible playbooks against Windows and testing with Pester

Ansible / Test-Kitchen / Windows / Pester

This repository is an example of how you can test Ansible roles meant for Windows machines using test-kitchen.

The process will build an Ansible server as part of a test-kitchen run, apply configuration to a Windows node and then tests via Pester.

You can read a detailed blog post about this:

https://hodgkins.io/testing-ansible-roles-windows-test-kitchen

  • Setup your workstation
  • Install required Ruby gems
  • Run test-kitchen
  • Resources

Setup your workstation

I HIGHLY recommend using chefdk and its version of Ruby, especially on Windows platforms.

Install the following:

  • ChefDK
  • Vagrant
  • VirtualBox

Install required Ruby gems

Before starting we need to install some Ruby gems.

# enter the kitchen directory
cd kitchen

# use bundler to install the gems
chef exec bundle install

Run test-kitchen

With everything installed we can start using test-kitchen.

# enter the kitchen directory
cd kitchen

# create the vms
# on windows you may get a UAC prompt when virtualbox initially configures networking 
kitchen create

# apply the ansible role to the windows server
kitchen converge

# run the tests against the windows server
kitchen verify

# delete the vms
kitchen destroy

Linting

I am using Scrutinizer CI to lint the role. See .scrutinizer.yml.

Resources