Interview Prep/Ansible/Security and Secrets

How do you use Ansible for security hardening?

IntermediateProductionSecurity and Secrets
Answer

Encode the baseline as a role applied to every host: SSH settings, password policy, kernel sysctls, auditd rules, file permissions, removal of unneeded packages, firewall defaults. Use well-maintained content as a starting point (the DevSec hardening collection, ansible-lockdown CIS roles) and fork the parts you need.

Run it first in --check --diff on stage, and make each control a variable that can be switched off for a documented exception. Verify with an independent scanner (OpenSCAP, Lynis, InSpec), because "the task ran" is not the same as "the host is compliant".

All Ansible questions Roadmap: Ansible

More on Security and Secrets