In the last few years, I've worked on multiple Ansible repositories for multiple organizations, and many of them were very chaotic. To ensure that your repository is easy to manage, I'm going to give you a template that I always use.
First of all, I always create three files in the root folder:
- ansible.cfg: A small configuration file to explain to Ansible where to find the files in our folder structure
- hosts: The hosts file we have already seen in the previous chapters
- master.yaml: A playbook that aligns the whole infrastructure
In addition to those three files, I create two folders:
- playbooks: This will contain the playbooks and a folder called groups for groups management.
- roles: This will contain all of the roles we need.
To clarify this, let's use the Linux tree command to see the structure of an Ansible repository for a simple web application...