Dev.to
6/15/2026

The Ansible Playbook I Run on Every New Server
Short summary
Ansible playbook that automates baseline server hardening—creates a non-root admin user, locks down SSH with key-only auth, configures UFW firewall defaults, and installs Fail2ban and unattended upgrades. The real value is idempotency: run it on any server to verify configuration drift or apply missing hardening steps. Six months later, you can verify nothing has drifted without re-reading the playbook.
- •Complete, production-ready Ansible playbook for consistent server baseline hardening
- •Configures SSH lockdown, UFW firewall, Fail2ban, and automatic security updates
- •Idempotent design lets you detect and repair configuration drift months after initial setup
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



