Chapter 7. Testing and Writing Better Infrastructure Code with Chef and Puppet

In this chapter, we will cover the following recipes:

  • Linting Chef code with Foodcritic and Puppet code with puppet-lint
  • Unit testing with ChefSpec and rspec-puppet
  • Testing infrastructure with Test Kitchen for Chef and Beaker for Puppet
  • Integration testing with ServerSpec

Introduction

In the development world, good practices of testing software are widespread, such as unit and integration tests. Linters are also used daily for most languages by software developers. These techniques are fortunately brought to the infrastructure world through the tools we use; now as infrastructure is basically code, it can be analyzed, tested, and reported! Combined with CI systems, writing ...

Get Infrastructure as Code (IAC) Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.