Compliance testing with InSpec
Verifying that servers and applications you install are configured correctly and fulfill all compliance requirements by hand is tedious and error-prone. Chef comes with InSpec, a human-readable language for compliance auditing and testing your infrastructure. With InSpec, you can write automated tests to verify a host of criteria on your servers: from the contents of certain files to applications running on certain ports, you can make sure that your servers and applications are configured correctly.
Getting ready
Make sure you have ChefDK installed, as described in the Installing the Chef Development Kit on your workstation recipe in Chapter 1, Chef Infrastructure.
How to do it…
Let's create a very simple compliance requirement as code and run it on your local workstation:
Create a new profile for your InSpec tests:
mma@laptop:~/chef-repo $ inspec init profile my_profile Create new profile at /Users/mma/work/chef-repo/my_profile * Create directory controls * Create...