The ansible documentation recommends a number of possible data structures for orchestrating multiple servers. My systems are not particularly complex, so I’ve resorted to a fairly simple structure. Under the ansible directory, I have added:
The bin directory contains scripts I use with ansible. I found I preferred to keep scripts hidden away in a separate bin directory. It’s courses for horses.
The group_vars folder contains yml files named for various groups. Those files usually just set variable values. They are executed when a machine which is a member of the corresponding group is configured. Similarly, the host_vars folder contains yml files for individual machines.
The files folder contains files to be copied to target servers. It actually contains a number of subfolders, one called all, one per inventory group, and one per host. These files will be copied to their corresponding servers when they are initially set up, and when the files change. I may, in the future, divide this directory into two, as per the *_vars.
The inventory folder contains two files, hosts and pw.yml. The hosts file is a standard ansible inventory file, with servers named and put into appropriate groups. The file pw.yml is my ansible_vault password file, containing nasty little secrets about the machines named in the inventory file, to keep them to order.
The prep directory contains scripts and files used to prep a machine after it’s been set up to prepare it to be managed by ansible (more here). It will, for example, install the version of python required by ansible.
The tasks directory contains all my yml files that actually do any work. There’s also a couple of files such as main.yml, which simply includes a number of other yml files, which together represent the tasks to perform in normal circumstances. There are other specialised scripts, such as backup.yml and upgrade.yml, which, as you might guess from their names, dance the fandango, & make a jolly nice cup of tea, respectively.
The ansible directory itself contains the main yml files, such as common.yml, which really just include shorthands to the corresponding files in the tasks directory, plus my ansible.cfg and a README.