(Locally) Testing ansible deployments
Tags: deployment, testing
I’ve always felt my playbooks undertested. I know about a possible solution of spinning up new OpenStack instances with the ansible nova module, but felt it to be too complex as a good idea to implement. Now I’ve found a quicker way to test your playbooks by using Docker.
In principal, all my test does is:- create a docker container
- create a copy of the current ansible playbook in a temporary directory and mount it as a volume
- inside the docker container, run the playbook
- running a playbook locally vs connecting via ssh can be a different beast to test
- can become resource intensive if you want to test different scenarios represented as docker images.
There is possibly more, but for myself in small it is a workable solution so far.
Find the code on github if you’d like to have a look. Improvements welcome!