Table of Contents
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
hardening (configuration)
Location: configuration/hardening/
RHEL 10 baseline playbook: hardening, base packages, firewall, SSH, logging, backups, and optional TLS/monitoring. Marked in the playbook as NOT TESTED – WRITTEN BY AI; review and test in a safe environment before production use.
What it does (overview)
- Base stack – Installs common packages (curl, wget, vim, git, btop, cockpit, firewalld, fail2ban, rsync, etc.), web server (nginx or apache), PHP, database (MariaDB or PostgreSQL), Redis.
- Firewalld – Enables firewalld, sets default zone, opens ports (SSH, 80, 443, Netdata, Cockpit, etc.).
- SSH hardening – Custom port, no root login, no password auth, fail2ban jail.
- Users – Creates admin user/group and passwordless sudo (change default password in vars).
- Disks – Optional: mount unmounted block devices under
/mntand add fstab entries. - TLS / Nginx – Certbot (optional), self-signed cert fallback, security headers, example SSL vhost (requires template
nginx_default_ssl.j2). - Netdata – Installs via official script and enables the service.
- Rsyslog – Forwards logs to a remote syslog server (configure host/port in vars).
- Backups – Daily cron job: rsync snapshot of
/etc,/var/www,/hometo a backup dir with retention. - Sysctl – Applies performance/security-related kernel parameters.
Files
| File | Purpose |
|---|---|
| osconfig.yml | Single playbook containing all tasks and handlers. |
Configuration
Edit the vars section at the top of osconfig.yml:
- common_packages, web_server, php_packages, db_engine, redis_package
- admin_user, admin_group
- ssh_port, ssh_permit_root_login, ssh_password_authentication
- firewall_allowed_ports
- remote_syslog_host, remote_syslog_port
- backup_src, backup_dest, backup_retention_days
- sysctl_params
Replace the default admin password and any placeholder hostnames/URLs (e.g. logs.example.com, TLS common name).
How to run
ansible-playbook -i inventory.ini configuration/hardening/osconfig.yml -K
Ensure your inventory targets the correct RHEL 10 hosts. The playbook references a template nginx_default_ssl.j2 when web_server == 'nginx'; create it or adjust the task if you use that path.