Testing servers with Inspec
Just as your application, code should be covered by unit and integration tests. Infrastructure as code should have good test coverage as well. There are multiple ways to do infrastructure code tests. They are as follows:
- Test only the code, without creating a real infrastructure (with tools such as ChefSpec and rspec-puppet)
- Test a single server
- Test the complete system
We won't look at the first option to test our infrastructure in this book. For guidance on how to test the complete system (with all the cloud resources, servers, and so on), look at Chapter 7, Collaborative Infrastructure. As for this chapter, let's check one way to test a single server with Terraform and Inspec.
Inspec is a testing framework written in Ruby. It provides an easy-to-understand DSL that allows you to write human-readable descriptions of what the server should run, which packages it should have, and so on. The only thing Inspec needs is the address of the server. But, first things first...