Skip to main content

Test Driven Ansible Role Development with Molecule

Posted on 2nd June 2019

I used to maintain a number of Ansible roles, and I recently wrote one for automatically generating settings.php files for Drupal projects that I use for some client projects as part of the Ansible and Ansistrano deployment process, as it can populate these files with credentials stored in Ansible Vault.

I uploaded an initial version of the role onto GitHub, but haven’t yet released it onto Ansible Galaxy.

I’d seen in other people’s roles and read elsewhere about writing automated tests for Ansible roles using a tool called Molecule, and wanted to write some tests for this role before publishing it onto Galaxy.

I looked around for resources about Molecule, and found a blog post by Jeff Geerling, but also this YouTube video that I found very helpful.

I’ve since been re-writing the role from scratch based on Molecule, and plan to release an official version of it soon.

About Me

Picture of Oliver

Oliver Davies is a PHP Developer and Linux Systems Administrator based in the UK. He is a Senior Software Engineer at Inviqa and a part-time freelancer specialising in Drupal and Symfony application development.