Phase 2: OS Hardening with Ansible¶
This phase configures the secure operating system baseline using Ansible. It applies hardened system defaults and prepares the host for rootless container deployment using Podman.
๐ก Phase 2 โ OS Hardening with Ansible¶
๐งฐ Tools Required¶
- Ansible
- SSH key access to provisioned VM(s)
- Hardened role or playbook (custom or from
dev-sec/ansible-collection-hardening
)
๐ก๏ธ Security Controls Implemented¶
Control Area | Control |
---|---|
Access Control (AC) | SSH lockdown, sudo restrictions |
System Integrity (SI) | AIDE, auditd, tamper detection |
Configuration Management (CM) | Idempotent playbooks |
Security Protection (SC) | ufw, fail2ban, automatic updates |
๐ Suggested Folder Layout¶
ansible/
โโโ inventory/
โ โโโ hosts.ini
โโโ playbooks/
โ โโโ hardening.yml
โโโ roles/
โ โโโ hardening/
๐งช Sample playbooks/hardening.yml
¶
- name: Apply hardening to base OS
hosts: all
become: yes
roles:
- role: hardening
โ๏ธ What the Role Should Do¶
- Disable root SSH access
- Enable firewall (ufw)
- Set minimum password complexity
- Install & configure:
auditd
aide
fail2ban
unattended-upgrades
๐ Verification Tasks¶
- Run
aideinit
and confirm baseline creation - Run
auditctl -l
andjournalctl
to confirm logs - Test fail2ban trigger via SSH login attempts
โ Output of This Phase¶
- A hardened base system per CIS Level 1 guidance
- Ansible inventory + role ready for future updates
- Rootless
podman
installed and tested
โ Proceed to Phase 3: Podman Service Deployment