Creating portable roles for Ansible
Before attempting to follow this recipe, I recommend having some basic knowledge of Ansible and how to write an Ansible playbook. If you’ve never written an Ansible playbook, I recommend following the Creating a playbook guide from the official Ansible documentation. That can be found here: https://docs.ansible.com/ansible/latest/getting_started/get_started_playbook.html.
In this recipe, you will learn how easy it is to move things around when using Ansible roles. When I first started using Ansible, I wrote my playbooks using tasks only. This to me seemed like a logical approach at the time and was more akin to traditional scripting since everything happened in chronological order.
The problem with writing playbooks in this way is there are no clear dependencies, and the tasks are defined along with the hosts, all in the same file. If you wanted to move things to another playbook, you’d have to be careful to grab the correct dependencies...