Testing Ansible Roles Using Containers

My Services – Docker repository provides the means to test the Ansible roles in my Libraries – Ansible repository using Docker containers, which simulate the Varilink Computing Ltd server estate on the developer desktop and support the use of Ansible to manage them via SSH connections. Since our servers are based on Debian, so are those Docker containers.

I believe this to be an artificial/unusual use of Docker. You wouldn’t normally use Ansible and SSH to connect to Docker containers and configure services within them using non-Docker related Ansible modules, though there are a set of Ansible community modules for managing Docker containers and this includes an Ansible module to execute a command in a Docker container. However, I’ve found this approach to be useful for the purpose of testing Ansible roles that will subsequently be used on non-Docker hosts, because it’s so easy to recreate containers.

I had a scenario in which I was retro fitting Ansible to a server estate that was already hosting services I had built without an automation tool. So I was seeking confidence that the Ansible roles I had developed would work for builds from scratch, making that ability to easily recreate containers important.

Continue reading