AC.

Speedup Ansible Playbook Pull-Requests by only running affected roles

Original Article : Read on Medium

Summary

This article explains how I optimized my Ansible playbooks pull-requests by implementing a feature I called affected_roles. This allows for conditional role execution based on changes detected in a pull request.

This solution involves detecting which roles are affected by changes using a dedicated role that runs on the Ansible executor and sets facts about which roles are affected based on git diff. This allows You to define when conditions on each role you want to run conditionally. I provide code snippets and explanations for registering the current branch, detecting changes, extracting affected folders, and filtering folders within the roles directory.

I hope this will be helpfull to anyone having to deal with the Ansible playbook and will allow you to have faster pull request validations on your Ansible projects.

You May Also Like