I’ve been wanting to automate the server setup I usually do manually on fresh ubuntu server for a while now. Repetitive stuff like SSH hardening, Docker setup, firewall rules, fail2ban, etc. Figured it was time to just automate it instead of doing it by hand every time.
I came across guillaumebriday/kamal-ansible-manager and used it as a starting point, then built on top of it. Added more hardening mapped to CIS benchmark, tested with Molecule, cleaned things up to use fully-qualified collection names (FQCN) throughout, and wrote out proper docs along the way.
That is very nice ansible collection with single purpose. And that is great.
roles/bootstrap/defaults/main.yml
---
bootstrap_user:
name: ansible
There is general recommendation to use plain (not nested) variables - bootstrap_user_name, bootstrap_user_ssh_public_key_path, not bootstrap_user dict with keys.
Imagine users want to set public key, but use default name for bootstrap user. They would have to define complete dict (name and public key). So default is basically useless here.
There is no guarantee that all the playbooks will be executed with gather_facts: true, so I would add task to collect necessary facts to the roles (where required).