Home

Awesome

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

<!-- TOC depthFrom:2 --> <!-- /TOC -->

Setup your workstation

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

Install the following:

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