Part 4 - Roles Refactor This is Part 4 of an Ansible Refactoring Series - Start Here
In our second pass through the project we will take the now more modular solution a step further and break it into roles. In this case we will basically map each of the 3 playbooks from Part 3 into 1 role each
Process Create a new branch refactor-pass-02-roles
Create a roles sub-directory in the repo
Part 3 - First Refactor This is Part 3 of an Ansible Refactoring Series - Start Here
In our first pass through the project we will just focus on breaking it up into more modular components, breaking apart the variables from the code, and cleaning up the base directory by moving out any files or templates into sub-directories. If you are Jeff Geerling and very comfortable with writing roles and collections then this part can be skipped!
Part 2 - First Deploy Now your environment is setup and customized it is time to clone, examine, and run your project repository or repo.
Simple Multi-Tier Application Overview The repo contains a simple, monolithic, playbook main.yml that deploys a multi-tier application serving both a web site and it’s associated API.
The Application comprises 3 main components, or tiers, which can be deployed onto the lab infrastructure. There is also a control node to work from.
Part 1 - Getting Started This is Part 1 of an Ansible Refactoring Series - Start Here
To follow along I assume you have access to a lab environment suitable for the task. I will add, July 2020, a Vagrantfile to simplify running this locally on your laptop. Meanwhile this can be deployed via the brand new Ansible Multitier Infra Config assuming you have AWS credentials or OpenStack.
ansible-playbook main.
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.