Before writing the actual tests we need to define our test environment
which is created as Docker containers behind the scenes.
This is done via a Docker Compose file and an Ansible inventory where
we define all hosts and groups required for the test run.

In our case we want to test our nginx installation on a single host with
Ubuntu Trusty:

Now, let’s write some tests that ensure nginx is installed according to our
requirements:

## tests/test_nginx_install.yml-include:../nginx_install.yml-hosts:webtasks:-name:nginx service is runningservice:name:nginxstate:startedtags:test-name:nginx service is enabledservice:name:nginxenabled:yestags:test-name:nginx service is listening on port 80wait_for:port:80timeout:10tags:test

You may have noticed that all we have to do is use the same Ansible modules
we’re already used to.
In case you are new to all this playbook stuff, the official
Ansible playbook guide will help you getting started.

Labeling a playbook’s task with a test tag makes goodplay recognize it
as a test task. A test task is meant to be successful (passes) when it
does not result in a change and does not fail.