Ansible Refactoring Series

Ansible Refactoring Series

Refactoring Ansible Modularity, Reuse, and Maintainability

In this series I want to explore refactoring a good, or at least decent, monolithic application deployment playbook into something more modular, easier to maintain, and with simpler and better reusability We’ll start by validating it works before our first pass at simply breaking it into more modular playbooks and separating out the variables.

Moving on we’ll identify what if any components would be be better off suited to roles and consider using one or more existing roles from Ansible Galaxy if appropriate. Finally we’ll turn our attention to the Postgresql component and look at how we could move this into an Ansible Collection, and if this makes sense.

Sneak Preview

The Infrastructure

A simple multi-tier infrastructure with a load-balancer (HAProxy) acting as a front end to 2 app servers running a flask application using Postgres as its persistance datastore.

ntier topology

The Application

ntier app topology

Time to get started with Part 1: Setting up your Control Node