Serverspec new matchers: Part 1

As I wrote in my previous post, Serverspec allows users to describe the machine setup using many different resource types. There are lots of resource types already implemented in the framework but based on the setup, which should be described, they can be insufficient.

The good thing about Serverspec is that it is easily extensible. Recently I have added several new matchers and resource types, which I will describe in the next few blog posts.

Lets start with iis_app_pool resource type and its new matchers.


IIS Application Pool resource type


In order to test the IIS Application pool, whether the Enable 32-Bit Applications option is enabled, you should use the have_32bit_enabled matcher.


In order to test the IIS Application pool Idle Time-out setting, you should use the have_idle_timeout matcher(in minutes).


In order to test the IIS Application pool Identity type(which configures how the app pool runs), you should use the have_identity_type matcher.


In order to test the IIS Application pool Regular Time Interval, you should use the have_periodic_restart matcher(in minutes).


In order to test the IIS Application pool Load User Profile setting, you should use the have_user_profile_enabled matcher.


In order to test the IIS Application pool username specified in case of Specific User used, you should use the have_username matcher.


In order to test the IIS Application pool Managed Pipeline Mode, you should use the have_managed_pipeline_mode matcher.


In order to test whether the IIS Application pool is started, you should use the started matcher.

In my next blog post I will have a look at the matchers for the iis_website and service resource types together with the two new resource types event_log and perf_counter types.

Note: The matchers described above can found in the Serverspec gem 1.14 and above.

Getting started with Serverspec

What is Serverspec?
Rspec tests for verifying the configuration of a given machine. It is used together with configuration management tools like Salt, Ansible, Puppet, Chef, etc. as a integration testing framework.

It is a Ruby-based framework, which uses internally Shell(Linux environments), Powershell(Windows environment) scripts for checking the target machines if the configuration management tool has configured them correctly.


The easiest way to install is to use the serverspec gem:

gem install serverspec


I will concentrate on testing Windows machines using the Serverspec framework, but the approach is the same for Linux ones.

To get started with Serverspec, the serverspec-init tool can be used, it creates the needed setup for a testing suite:

Select OS type: 

  1) UN*X
  2) Windows 

Select number: 2 

Select a backend type: 

  1) SSH
  2) Exec (local) 

Select number: 2 

Note: The setup is done for windows local environment.

The command will create the following setup on the local machine:


The httpd_spec.rb contains example Rspec tests.

Executing the rake spec command(rake gem is needed) will run the Rspec tests.

rake spec

Resource Types

Serverspec has many different resource types implemented, which allow users to describe the machine setup in their Rspec tests.

Helpful information about these resource types can be found here.