Like software code, testing infrastructure code is an all-important task. There should ideally be no code floating around in production that has not been tested, especially when you have strict customer SLAs to meet, and this is true even for the infrastructure. In this chapter, we'll look at syntactic checks, testing without applying the code on the machines (the no-op mode), and functional testing for playbooks, which are at the core of Ansible and trigger the various tasks you want to perform on the remote hosts. It is recommended that you integrate some of these into your Continuous Integration (CI) system that you have for Ansible to better test your playbooks. We'll be looking at the following points:
- Syntax checking
- Checking mode with and without --diff
- Functional testing
As part of functional testing, we will be looking at the following...