Skip to content

joaoasrosa/packer-serverspec-example

 
 

Repository files navigation

Packer Serverspec Example

wercker status

Packer provides a great way of describing the steps for creating a virtual machine image. But it doesn't have a built-in way of verifying those images.

Serverspec provides a nice framework for writing tests against infrastructure, asserting the operation of services or the installation of packages.

This repo demonstrates a simple integration between Packer and Serverspec, using Serverspec tests to validate the instance provisioning before the image is created.

Installation

First you need to install Packer.

Next download the Puppet modules described in the Puppetfile. For this we're using Bundler which you'll need installed.

bundle install
bundle exec librarian-puppet install

Usage

Now you'll need to set a couple of Amazon environment variables:

export AWS_ACCESS_KEY_ID=xxxx
export AWS_SECRET_ACCESS_KEY=xxxx

And finally run Packer:

packer build template.json

This will boot an AWS instance, install Puppet, use Puppet to install various bits of software, then run the test suite. Only if all of that works will it build the AMI.

About

Using Serverspec tests to verify images built using Packer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 82.6%
  • Shell 16.4%
  • Puppet 1.0%