I’ve spent this last couple of months experimenting extensively with Ansible. So far I’ve only worked on a series of VMs using Vagrant and KVM on my workstation. I’ve become reasonably proficient with
ansible.cfg, inventory files and playbooks. I’ve already written my first roles and know how to properly organize them in a directory subtree with tasks, files, handlers etc. Looks like I’m beginning to wrap my head around this, though I must say Ansible is a hell of a beast and the learning curve is quite steep.
I feel the time has become to use it for my everyday work. Before I dive head first into using inventories and playbooks and roles for my everyday work, I’m facing the following problem. How do I organize all this wealth of files to come intelligently? How will all this looks like in a year? How can I avoid having myriads of redundant playbooks scattered all over semi-redundant Git repositories?
I’ve given this some reflection for a couple days, and here’s what I came up with.
1. One central Git repository where I store pretty much everything except roles. Here’s what this would look like:
$ tree -F . ├── campanula/ │ ├── ansible.cfg │ ├── inventory │ └── roles/ ├── dedibox/ │ ├── ansible.cfg │ ├── inventory │ └── roles/ ├── microlinux/ │ ├── alphamule.yml │ ├── ansible.cfg │ ├── inventory │ ├── nestor.yml │ ├── proxy.yml │ └── roles/ └── scholae/ ├── ansible.cfg ├── inventory ├── pc-direction.yml ├── pc-info.yml ├── portable.yml ├── proxy.yml ├── roles/ ├── sauvegarde.yml └── serveur.yml
A little explanation on what is what here:
microlinuxis my own office, with a proxy, a backup server and my main workstation.
scholaeis our local school with about three dozen machines (servers, desktop clients, laptops) all running Rocky Linux
campanulais a small company in Belgium
dediboxis the directory for all my public Internet-facing server
2. All these various playbooks use a series of
roles. I would store all the roles separately in another Git repository and aim for reusability. So I would have something like a
rockylinux-8-roles repo containing a series of roles like
Notice the directory tree above has a series of empty
roles/ directories. Now this is where I would import the roles from GitHub (with the corresponding
.gitignore files of course).
So far this makes sense to me in theory, but before diving into this, I thought I’d share this idea with you. I’m curious about your way of doing things and your eventual suggestions.
Cheers from the sunny South of France,