Infrastructure Testing with Serverspec
An important principle in DevOps is to test your infrastructure. The tests should run as part of your continuous delivery pipeline giving you agility and confidence in your infrastructure changes. Serverspec is one example of an infrastructure testing framework. Serverspec can be used to test local and remote target machines by connecting over SSH or WinRM.
This Lab illustrates how to perform Infrastructure Testing with Serverspec. You will write Serverspec tests to specify the expected behavior of machines running in the reverse-proxy, load-balancing tier and the application tier of a sample application. The tests illustrate how to describe the expected behavior of servers and Docker containers. You will run the tests using Serverspec at the command-line and in a Docker container.
Upon completion of this Lab, you will be able to:
- Understand where automated infrastructure testing fits into DevOps
- Initialize Serverspec infrastructure test suites
- Write Serverspec tests for a variety of Serverspec resources including packages, services, ports, and Docker infrastructure
- Run Serverspec from the command line and in a Docker container
You should be familiar with:
- A programming language. Ruby familiarity is most beneficial, but not required.
- Basic Docker concepts, such as images and containers
- Basic Linux concepts, such as the command line, processes, packages, and services
Before completing the Lab instructions, the environment will look as follows:
After completing the Lab instructions, the environment should look similar to:
March 27th, 2023 - Resolved an issue that caused the lab to fail to set up on rare occasions
December 5th, 2022 - Added checks to track lab progress
May 3rd, 2019 - Updated packages that caused Docker to fail to install on the Application instance
January 10th, 2019 - Added a validation Lab Step to check the work you perform in the Lab
Logan has been involved in software development and research since 2007 and has been in the cloud since 2012. He is an AWS Certified DevOps Engineer - Professional, AWS Certified Solutions Architect - Professional, Microsoft Certified Azure Solutions Architect Expert, MCSE: Cloud Platform and Infrastructure, Google Cloud Certified Associate Cloud Engineer, Certified Kubernetes Security Specialist (CKS), Certified Kubernetes Administrator (CKA), Certified Kubernetes Application Developer (CKAD), and Certified OpenStack Administrator (COA). He earned his Ph.D. studying design automation and enjoys all things tech.