Scaling DevOps with Ansible — Part 2- Test! Test! Test!

Tj Blogumas
DevOps Dudes
Published in
6 min readMar 26, 2020

--

This is a continuation to my Part 1 story “Scaling DevOps with Ansible” be sure to check it out.

TDD Model

Introduction: As our catalog of Ansible roles grows and begins to be consumed by more and more users, it’s vital that we ensure changes to these roles do not cause breaking changes for current use cases. For the majority of system engineers with an operations background, writing maintainable code with automated tests while developing on git branches is a whole new world. This article will aim to help provide an example development workflow for those tasks with writing Ansible roles.

Framework:
Ansible has an amazing framework call MOLECULE for writing high-quality roles with an automated testing framework for unit/component/integration tests. Instead of creating folders and yaml files from scratch, we will install Molecule and use it’s command line from start to finish.

Note: You’ll wan’t to be working in a linux environment (CentOS with Desktop GUI works really well) as well as have docker and python3 installed.

Installing Molecule:

mkdir -p molecule-test-folder && cd $_
python3 -m venv .venv
source .venv/bin/activate
pip install -U setuptools pip 'molecule' --trusted-host pypi.org
pip install 'molecule[docker]' --trusted-host…

--

--

Tj Blogumas
DevOps Dudes

DevOps Architect @ a large financial institution. DevOps practitioner for over a decade. Technology and Automation enthusiast.