Testing Ansible Roles with Docker
Background
When you first start using Ansible, you go from writing bash scripts that you upload and run on machines to running desired end state playbooks. You go from a write-once read-never set of scripts to an easily readable and updatable yaml. Life is good.
Fast forward to when you become an Ansible power user. You’re now:
-
Writing playbooks that run on multiple distros
-
Breaking down your complex Ansible project into multiple bite-sized roles
-
Using variables like a boss: host vars, group vars, include variable files
-
Tagging every possible task and role so you can jump to any execution point and control the execution flow
-
Sharing your playbooks with colleagues and they’ve started contributing back
As you gain familiarity with Ansible, you inevitably end up doing more and more stuff-- which in turn makes the playbooks and roles that you’re creating and maintaining longer and a bit more complex. The side effect is that you may feel that development begins to move a bit slower as you manually take the time to verify variable permutations. When you find yourself in this situation, it’s time to start testing. Here’s how to get started by using Docker and Ansible to automatically test Continue reading