By Jess Males – Technical Consultant

Operating our infrastructure as code delivers a world of best practices from the realm of software development. Linting before commits is a no-brainer. Continuous delivery relieves the drudgery of manually rolling out infrastructure changes. These practices are now common. One practice less frequently discussed is test-driven-development: write a test-case for the infrastructure before writing the implementation. Serverspec and Inspec offer this; TestInfra and BATS do so as well. However, I have recently been working with Goss ( and I wanted to share some of its features.

The first feature to highlight is autoadd. With this subcommand, the goss binary analyzes the local system to figure out the shape of the running process. For example, `goss autoadd sshd` is going to: identify that a process named ‘sshd’ should be running; identify that port 22 should be listening; and write a yaml configuration file outlining this (a gossfile). Actually, this is just the start, it will also record the state of the service, the user the service is to be run as, the group it is to be run as, and more. This feature makes capturing system specifications eminently easier.

Secondly, I want to introduce Goss’s render and template features. Render allows gossfiles to reference other gossfiles. The templates allow programmatic gossfile generation. Between the two, we have the capability of constructing powerful generic profiles for the entirety of our environment. This is in sharp contrast of having to manually generate gossfiles specific to every imaginable use case.

Finally, the validate feature checks that our system is configured to our specification; more conveniently, the serve feature starts an HTTP endpoint that provides this information on demand. Now, system validation isn’t just a one-time check after system creation; when plumbed with your monitoring system, it becomes a continual and automatic process.

Goss provides straight-forward test creation with flexible test layout mechanisms. Above this, its server mode gives us a tool for integrating this testing into our automation pipelines. With such easy test generation and test execution: Goss is a powerful tool for operating infrastructure as code.